bencebence Posted August 19, 2011 Share Posted August 19, 2011 Hey everyone!I have a question.I'm making a script, that should add an item after I kill an NPC. So one item after each NPCs.scn MyScriptName short killednpcs short doonce Begin GameMode set killednpcs to GetPCMiscStat 6 if killednpcs == 1 && DoOnce == 0 player.additem MyItem set DoOnce to 1 endif endBut I don't want to repeat this till endless numbers. How can I easily make it just check that I've killed another NPC and add an item?Thanks in advance,bencebence Link to comment Share on other sites More sharing options...
HeyYou Posted August 19, 2011 Share Posted August 19, 2011 You want it to increment each time you kill and NPC? Use a counter, and increment that each time an npc is killed, (stat changes) compare current counter, to number killed, (they should be equal) if not equal, increment counter, add item. Link to comment Share on other sites More sharing options...
bencebence Posted August 19, 2011 Author Share Posted August 19, 2011 (edited) So you mean something like this?scn MyScriptName short killednpcs short doonce float killednpcs1 Begin GameMode set killednpcs to GetPCMiscStat 6 set killednpcs1 to GetPCMiscStat 6 if killednpcs == killednpcs1 && doonce == 0 return elseif killednpcs1 == (killednpcs)+1 player.additem MyItem endif end Edited August 19, 2011 by bencebence Link to comment Share on other sites More sharing options...
lgpmichael Posted August 19, 2011 Share Posted August 19, 2011 If this is for a specific group of NPC's, you could simply add an ondeath condition to the NPC script Begin OnDeath player.additem MyItem 1 End Unless this is for every single NPC, in which case, something like your code: scn MyScriptName short killednpcs short lastkillednpcs short diff Begin GameMode set killednpcs to GetPCMiscStat 6 set diff to killednpcs - lastkillednpcs if ( diff>0 ) player.additem MyItem diff set lastkillednpcs to killednpcs endif end That will add the number of items equal to the number of NPCs killed. Link to comment Share on other sites More sharing options...
fg109 Posted August 19, 2011 Share Posted August 19, 2011 I think he actually meant something like this: scn examplescript short doOnce short itemcount short killcount Begin GameMode if (doOnce == 0) set doOnce to 1 set killcount to GetPCMiscStat 6 endif if (killcount < GetPCMiscStat 6) set itemcount to (GetPCMiscStat 6) - killcount set killcount to GetPCMiscStat 6 Player.AddItem MyItem itemcount endif End Link to comment Share on other sites More sharing options...
Recommended Posts