Jump to content


Photo

Rest restrictions mod: where should I start?


  • Please log in to reply
4 replies to this topic

#1 ralessandro634

ralessandro634
  • Member
  • 2 posts

Posted 12 April 2020 - 11:18 AM

Hi everyone, I'm new to this forum so I'm not sure I'm writing in the right place, so apologize if I'm not.

I'd like to create a mod for BG2EE introducing rest restrictions, for example you can't sleep more than once per day or per location.

I'm a software engineer so I can definitely write code, unfortunately I have absolutely 0 experience with modding games and I really don't know where I should start.

Could you please give me some basic instructions on how I could realize the mod I intend, just to get me started?

 

Thanks in advance



#2 jastey

jastey
  • Administrator
  • 3218 posts

Posted 12 April 2020 - 11:38 AM

I have to admit I am not sure how such a mod would be scripted. I know areas can be tagged so resting isn't allowed, but I wouldn't know how to restrict resting to once per day as this would probably involve a timer, but resting is done by pressing the rest party button where I am not sure how to disable it.

#3 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5150 posts

Posted 12 April 2020 - 02:28 PM

Well, I had something to this effect in mind once:


//EE -part


COPY_EXISTING_GLOB ~.*\.are$~ ~override~	 // 

PATCH_IF (REQUIRE_PREDICATE GAME_IS ~bgee bg2ee eet~) BEGIN
	WRITE_SHORT 0x10 (THIS BOR BIT5) //EE only
BUT_ONLY
END


//non-EE
PATCH_IF (PATCH_IF (REQUIRE_PREDICATE GAME_IS ~tob tutu tutu_totsc~) BEGIN
COPY_EXISTING_GLOB "*.are$" "override"	// non-EE
	READ_ ~0x~ ~~
	PATCH_IF ~~ BEGIN
	WRITE ~0x~ ~~ END

	READ_LONG ~0x00c0~ ~inteindex~
	READ_	~%inteindex% + 0x0048~ ~creature~
	PATCH_IF (~%creature%~ = 0 ) BEGIN
	LPF ~~ END
BUT_ONLY
END




    STR_VAR fj_name to the name of the rest interrupts (for editor use only);
    INT_VAR fj_cre_strref0...fj_cre_strref9 to string displayed upon party ambush (default -1);
    STR_VAR fj_cre_resref0...fj_cre_resref9 to creature resref;
    STR_VAR fj_spawn_num to the number of spawned attackers;
    STR_VAR fj_difficulty to the difficulty of the encounter;
    STR_VAR fj_duration to the creature’s duration (default 1000);
    STR_VAR fj_wander_distance to the creature’s random walk distance limit (default 1000);
    STR_VAR fj_mvmt_distance to the creature’s movement distance limit (default 1000);
    STR_VAR fj_max_num to maximum number of spawned creatures;
    STR_VAR fj_enable to whether rest interrupts are enabled (0=no, 1=yes);
    STR_VAR fj_day_prob to probability of daytime ambush;
    STR_VAR fj_night_prob to probability of nightime ambush; 

Of course it's in the middle of development hell, as I haven't gotten around to find a guard that awakens the party with interruption dialog, or if there's already monsters, they interrupt 100% of the times... but that was the original idea for the non-EE game. Meaning you could only rest in inns.

That's with the understanding of this of course, aka Weidu moding. And no, you don't need to know a lot of that stuff, just the primary principles of it...


Edited by The Imp, 12 April 2020 - 02:34 PM.

Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.


#4 ralessandro634

ralessandro634
  • Member
  • 2 posts

Posted 13 April 2020 - 06:31 AM

In SCS there's already an optional component that prevents you from sleeping more than once in the first dungeon. It doesn't disable the rest button, but if you try to rest more than once, you are always ambushed. Probably this the easiest way to script it (location-based restrictions rather than time based). 

 

@The Imp, thanks for the link, that guide is massive, can you recommend which sections should I really know (at least for starting)?



#5 The Imp

The Imp

    Not good, see EVIL is better. You'll LIVE.

  • Member
  • 5150 posts

Posted 13 April 2020 - 07:06 AM

Sections 1, 2, 5, 10, 12... in with diminishing returns... and then you can look at the constructed files after installing for example the SCS's component, the component prints the backups* ... you won't be able to understand the codeitself as it's build fromit's own scripting way, but that shouln't matter. This is as deep hell as you like it to be.

You should then be able to basically use the same way in all the other files. This will of course not work in all files as unfortunately not all the .are'as have native scripts running on the background, and that will be a problematic. Which is why I wouldn't do this with scripting at all, but with a forced monster/guard interruptions during the sleeping.

*The reason why I hate this mod is that it prints files outside the mods own folder, read more about that in there. .. into it's own "workshop" folder, that also contains the backups. To actually be able to read those, you just need to have Near Infinity, a Java tool associated with a game folder. From which you can then open up the ar0602.bcs, as that's the area script the game uses to presumably do this feature.


Yep, Jarno Mikkola. my Mega Mod FAQ. Use of the BWS, and how to use it(scroll down that post a bit). 
OK, desert dweller, welcome to the sanity, you are free to search for the limit, it's out there, we drew it in the sand. Ouh, actually it was still snow then.. but anyways.