Hello!
I’ve another query crop up in my script writing.
I’m trying to implement a very basic quest of Kill X number of enemies to spawn Y enemy.
Now if this was a single player, I think it would be straight forward, using GetLastKiller included in the creatures OnDeath script, to add +1 to the “XenemyKilled” variable.
Once it reached a certain number, Y would spawn.
However, I’m trying to build my quests with a party of PC’s in mind.
I’ve got an #include script function from Lilac Soul that allows party wide variable sets and calls, however it seems impossible to +1? as I get an script error.
Does GetLastKiller() function as I imagine and only works for the PC that strikes the killing blow?
Do Associates (GetMaster) count as Summoned Creatures and Henchmen only, or other party members?
Below is an example of script I’ve currently come up with.
The main issue is if different party members strike the killing blow, the script will call their Variable and +1 to that, and then set the entire party, so it may actually take more than X kills.
Really i’m after a way of adding a plus / minus variable to the entire party after a kill.
I suppose I could do a complex IF script, of if variable = 1, then make it =2, iIF it =3 then make it =4 until it reached the desired amount? Is this the best solution?
Thanks a lot,
Roarthing
object oTarget;
object oSpawn;
// Get the creature who triggered this event.
object oPC = GetLastKiller();
while ( GetMaster(oPC) != OBJECT_INVALID )
oPC = GetMaster(oPC);
// Set party variable.
int nValue = GetLocalInt(oPC, "quest1_1") + 1;
SetLocalIntOnAll(oPC, "q1_1", nValue);
// Abort if the variable is less than 5.
if ( GetPartyInt(oPC, "quest1_1") < 5 )
return;
// Abort if the variable is 1 (i.e. Already spawned BossMonster.)
if ( GetLocalInt(oPC, "quest1_done") == 1 )
return;
// Spawn "BossMonster".