Saturday, 21 March 2009

About torches, light and visual effects.

Okay, obvious we can't use the function
ApplyEffectToObject(int nDurationType, effect eEffect, object oTarget, float fDuration=0.0f) when it comes to Items. Please prove me wrong but it just does not work. To be fair, no one has claimed it would... It means that the torches and other handheld light sources I use in ZRtGUE will eventually fail, making the game really hard and boring to play. It's not a show stopper but it's like a show noone reasonably sane wants to sit through.

So I picked up my old idea about deleting the item evertime the player un-equips it and re-create the same item fresh. So if the torch vfx and light dies the player just have to re-equip it to make it work again. Maybe it'll even prevent it from failing. One drawback is that if you have the item in a quickslot it'll be removed. That one I can accept.

The problem with this and the reason I dropped the idea was that sometimes the item was lost during creation. I believe it could be beacuse of that the creation took longer that the delayed destruction of the item. So I made a modification to my little script by assigning the creation to the Players action queue:

void CloneItem(object oPC, object oItem)
{
string sItem = GetResRef(oItem);
CreateItemOnObject(sItem, oPC, 1, "", FALSE);
}

void main()
{
// * See to that the Player has a fine new working torch after unequip
object oPC = GetPCItemLastUnequippedBy();
object oItem = GetPCItemLastUnequipped();
AssignCommand(oPC, ClearAllActions());
AssignCommand(oPC, CloneItem(oPC, oItem));
DestroyObject(oItem, 0.05, FALSE);
}

No comments: