Jump to content

Repeating Script


bencebence

Recommended Posts

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
end

But 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

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

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 by bencebence
Link to comment
Share on other sites

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

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...