The script below froze the game, while it spawned a multitude of the same creature around the player, when I’d only like just one to spawn. It’s an old script I pulled from somewhere, duct-tapped it together, and voila!
Player enters a trigger near flowers. A flower releases a gas spore that has a chance to paralyze the player. During that moment, vines from the same flower spawn (a hostile creature), and attacks the player. Except, well, take a look at the screen shot.
Clearly something bad is happening in the while loop, but I’m not clear as to where to put a stop to the loop so only one hostile vine from the flower is spawned in.
void ActionCreate(string sCreature, location lLoc)
{
CreateObject(OBJECT_TYPE_CREATURE, sCreature, lLoc);
}void main()
{
object oEnt = GetEnteringObject();object oMold = GetNearestObjectByTag("YellowMusk", oEnt); object oMold2 = GetNearestObjectByTag("YellowMusk2", oEnt); if(GetIsObjectValid(oMold2) && (!GetIsObjectValid(oMold) || GetDistanceBetween(oEnt, oMold2) < GetDistanceBetween(oEnt, oMold))) { oMold = oMold2; } if(!GetIsObjectValid(oMold) || GetDistanceBetween(oEnt, oMold) > 3.5) { DestroyObject(OBJECT_SELF); return; } if(GetLocalInt(oMold, "DoOnce")) { DestroyObject(OBJECT_SELF); return; } FloatingTextStringOnCreature("Flowers on the plant puff out a cloud of dust!", oEnt); location lSelf = GetLocation(oMold); effect eSpores = EffectVisualEffect(VFX_FNF_GAS_EXPLOSION_NATURE); ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eSpores, lSelf); effect eSpore = EffectParalyze(); object oSpore = GetFirstObjectInShape(SHAPE_SPHERE, 4.0, lSelf, TRUE); if ( ! FortitudeSave( oEnt, 17, SAVING_THROW_TYPE_MIND_SPELLS ) ) { while(GetIsObjectValid(oSpore)) { ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eSpore, oSpore, 18.0f); oSpore = GetNextObjectInShape(SHAPE_SPHERE, 4.0, lSelf, TRUE); object oCreature = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC); if (GetHasSpellEffect(SPELL_INVISIBILITY, GetFirstPC())) return; string sCreature = "musk001"; location lLoc = GetLocation(GetFirstPC()); object oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "musk001", lLoc); SetPlotFlag(GetNearestObjectByTag("MuskVines"), FALSE); DestroyObject(GetNearestObjectByTag("MuskVines")); } } SetLocalInt(oMold, "DoOnce", TRUE); DestroyObject(oMold); DestroyObject(OBJECT_SELF);
}
Thanks!
FP!