I wanted to make a script to damage the PC continuously with cold damage when in certain areas, like HotU did in Cania.
At first, I just ripped that script from the original campaign, but it damaged the entire PC faction, including animal companions, and it broke my heart because you can’t equip them to withstand that and it’s awful.
So I made a script that only damages the PC and henchmen, and also does no damage when resting (because the only way to rest is next to a campfire, so it doesn’t make sense to still be cold).
Here’s the script in question:
void main()
{
object oPC = GetFirstPC();
object oHen = GetAssociate(ASSOCIATE_TYPE_HENCHMAN, oPC);
if (!(GetArea(oPC) == OBJECT_SELF)) return;
if (GetIsResting(oPC)) return;
int iDamage = Random(5) + 1;
effect eAreaCold = EffectDamage(iDamage,DAMAGE_TYPE_COLD);
effect eVis = EffectVisualEffect(VFX_COM_HIT_FROST);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eAreaCold,oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oPC);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eAreaCold,oHen);
ApplyEffectToObject(DURATION_TYPE_INSTANT,eVis,oHen);
}
It works okay, even though it has nothing to do with the HotU script (that had some fancy special functions and whatnot) but it had a weird side effect: it worked all the time, whether the PC was in the area or not (that’s why I added the GetArea(opC) bit) - I guess it’s because the area exists all the time, so its heartbeat is called all the time?
And that got me thinking - is this a problem? I heard many times that heartbeats are to be avoided because of the resource usage, but I don’t see another way of doing this well. The script is used in two areas. Single Player only.
Is that okay? Or is there a better way?