I have been slowly putting together my own resting script using old code from my previous work and from some of the helpful topics on this forum. I am interested in the concept of only permitting full HP replenishment if the player possesses a ration item, otherwise they would regain less, say only 75% of their maximum.
NWN1 had SetCurrentHitpoints, but I don’t see this in the NWN2 function list. Is it hidden away in an include file or do I need to get spicy with one of the similar functions?
It’s a kludge, but it could work, considering it can all occur under a fade to black scene. Thank you, I will try it. If anyone else has thoughts, chime in, i’ll go with the best looking outcome
As @Dustin_Offal says, I gave a lot of consideration into creating a robust rest system that required food to rest, or the Create Food & Water prayer, of course.
The system is also designed for MP, which considers when players may require different rest periods dictated by time passed. It took a lot of work to get right, but now offers a system where players must consider their needs ahead of time to add more tactical play and avoid the rest, spell recover, “rinse and repeat” exercise.
If you want to check out how it works, try out the module and there is some info in the manuals available too.
The kludge works just fine. I will be elaborating on the system some more, so I’ll be interested to see what you came up with, as it seems we have the same goal in mind.
Here’s a modified version of the old one we had from way back:
/*
Place on the module's OnPlayerRest event.
Checks for and removes one food item from the party when resting.
If there is no food item, partymembers with more than 25% damage will heal only to 75% of their max,
and partymembers with less than or equal to 25% damage won't heal at all.
Assumes the food items have their localint "rest_food" set to 1.
*/
int TakeFood(object oPC)
{
object oFM = GetFirstFactionMember(oPC, FALSE);
object oItem;
while (GetIsObjectValid(oFM))
{
oItem = GetFirstItemInInventory(oFM);
while (GetIsObjectValid(oItem))
{
if (GetLocalInt(oItem, "rest_food"))
{
DestroyObject(oItem);
return TRUE;
}
oItem = GetNextItemInInventory(oFM);
}
oFM = GetNextFactionMember(oPC, FALSE);
}
return FALSE;
}
void DoNoFoodRest(object oPC)
{
int nMax, nCurrent, nQuarter, nReduced;
object oFM = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oFM))
{
nMax = GetMaxHitPoints(oFM);
nCurrent = GetLocalInt(oFM, "CurrentHP");
nQuarter = nMax / 4;
nReduced = nMax - nQuarter;
if (nCurrent < nReduced) // has more than 25% damage
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nQuarter), oFM);
DelayCommand(4.0f, AssignCommand(oFM, SpeakString("I'm hungry!")));
SendMessageToPC(oPC, GetName(oFM) + " can heal only to 75% of max without food.");
}
else if (nCurrent < nMax) // has less than or equal to 25% damage
{
ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(nMax - nCurrent), oFM);
DelayCommand(4.0f, AssignCommand(oFM, SpeakString("I'm hungry!")));
SendMessageToPC(oPC, GetName(oFM) + " can heal no higher than their current HP without food.");
}
else // has no damage so do nothing
{
}
oFM = GetNextFactionMember(oPC, FALSE);
}
}
void main()
{
object oPC = GetLastPCRested();
int nRestEvent = GetLastRestEventType();
if (GetIsResting(oPC) && nRestEvent == REST_EVENTTYPE_REST_STARTED)
{
object oIP = CreateObject(OBJECT_TYPE_PLACEABLE, "plc_ipoint ", GetLocation(oPC));
// do not remove this space ^
// Playsound does not work on the same object while it is animating. So play it off of an ipoint.
DelayCommand(0.2f, AssignCommand(oIP, PlaySound("as_pl_snoringm1", TRUE)));
FadeToBlack(oPC, FADE_SPEED_FAST, 16.0f);
SetPlotFlag(oIP, FALSE);
DestroyObject(oIP, 6.2f);
object oFM = GetFirstFactionMember(oPC, FALSE);
while (GetIsObjectValid(oFM))
{
SetLocalInt(oFM, "CurrentHP", GetCurrentHitPoints(oFM));
oFM = GetNextFactionMember(oPC, FALSE);
}
}
if (nRestEvent == REST_EVENTTYPE_REST_FINISHED)
{
if (!TakeFood(oPC))
{
DoNoFoodRest(oPC);
}
else
{
DelayCommand(4.0f, FloatingTextStringOnCreature("<color=lime>You are fully rested!", oPC, FALSE));
}
}
}
Thanks for digging that out @travus
I have managed to merge this together with what I came up with, all running perfectly.
Along with HP recovery checks, there are elements of the zonal system from the MERP stuff, but this time it will be to define zones in areas where resting is not possible - think really dumb areas like high traffic parts of hostile areas, making camp in front of the enemy, etc.
Added a time advance per rest of 6 hours
Free resting override for Inns (you can “buy” a ForceRest)
Thanks for the help folks. I have leanred a lot about resting scripts in a short space of time. I feel slightly less hopeless as a result
I offer these as possible considerations … just as observations.
Rest has generally been considered an 8 hour period rather than 6. (Although, I just went to find a resource regarding this and found that the resource has been removed. New rulings, I guess.)
If you are considering MP support, bear in mind that you might advance time for each player pressing the rest button (unless conditions set). My workaround was to separate the direct connection between pressing “R” and the passing of time, but to require time to pass before a PC could rest again. (This is the more complex part, but can be ignored if not catering for MP. )
As such, it is the passing of time that dictates when food is required, which is closely related to the rest requirement. (This is where the newer rest GUI in a later DLC allowed us to work with time and rest more easily. Although, I had to rework it to work with MP usage by players.)
The above assumes free form resting (in the field) rather than at an inn or tavern, where it is assumed everyone in the party rests at the same time.
I had in mind to post you to a great resource link on rules for resting, which also went into details about penalties for not resting, etc, (which I also included), but that site no longer has these pages. Probably a backlash of the WotC debacle that happened a few months back. A shame …
EDIT: I even just tried to find the same information elsewhere online, and surprisingly, I can find no detailed information on the D&D 3.5E resting system anywhere like I had it available before. So now, it looks like I will have to start rummaging through my DM Guide again! This is definitely a blow for convenience and speed.
If it is of any interest, I wrote a blog post on this topic once:
NB: The system has been improved and finalized since this time of posting.
I’m not planning any MP support. I have supported it previously but I get the sense there is not much interest in this. I am plodding away at this project in infrequent bursts, so I’m reluctant to invest time in something I’m not sure will get picked up. That said, I’m not totally sure where I’m going with this thing anyway. It’s currently a project of homebrew self-indulgence, similar style to my previous work (MERP adaptations) but this time I control everything lore-wise. Whether it amounts to something I’ll put out is an unknown. I like what I’ve done so far though.
I often see 8 hours as the standard. I’ll see how it plays. I simply have to change a number in the script.
The food/ration rationale came about due to the setting of the campaign (desert). I started out requiring a water ration to be posessed by the PC, but I since changed this to any food/drink item. Time since last ration is interesting and I will look over your stuff if I decide to expand upon the system.
Great article @GCoyote . I have encountered plenty of rest systems that have brought out a tirade of expletives. For me it’s all about fun and ease of use. You’re going to do a lot of resting, so for me any restrictions need to seem reasonable and not feel like a chore. Better still, any heavy restrictions could do with some novel ways around them. I liked your suggestions about survival and class based solutions to a tricky resting situation, for example. Great stuff