Jump to content

[LE] I need help with a script that fires when you've killed a certain number of enemies.


Recommended Posts

So i'm trying to write my first array.. I'm familiar with basic scripting and papyrus in the CK. But its time to learn something new.

I have a group of npcs(enemies) that will be attacking the player. When one or two of the enemies are left, another group will spawn and continue attacking.

I'm guessing what I need is a script that checks how many are dead. But havent found any solid examples I could take apart and look at. Any help would be appreciated =)

Link to comment
Share on other sites

You can check when an NPC dies and keep a count, by attaching a script to each NPCs you want to keep track of, something like this:

 

GlobalVariable Property NumberKilled Auto
Int Property NumberToKill Auto

Event OnDeath(Actor akKiller)
NumberKilled.Mod(1)
If NumberKilled.GetValueInt() >= NumberToKill
;do something
EndIf
EndEvent

Link to comment
Share on other sites

Another way to do this only using default vanilla stuff, is :

1) Place an xMarker which i will name "xMarkerCOUNTER", add to it a "defaultCounter" script.

2) Add to each actor you want to count its death a "defaultincrementondeathcounter" script and Link Ref each actor to the "xMarkerCOUNTER".

3) The "xMarkerCOUNTER" will enable an "initially disable xMarker".

4) The actor that will spawn after the npcs death will "Enable Parent" to the xMarker.

The xMarker will get enable by the "xMarkerCOUNTER".


And this can go on forever...


* Be sure to correctly fill the properties of the script in the "xMarkerCOUNTER".

Link to comment
Share on other sites

XMarker Script:

; Attach to XMarker - or sweetroll

	KeyWord Property RegisterKey Auto
	{ Key to register kill }
	
	KeyWord Property ShowKey Auto
	{ Key to show values }

	Int ValidKill 	= 0
	int Kill		= 0

Event OnActivate( ObjectReference QRef )
	If( QRef.HasKeyWord( RegisterKey )
		ValidKill += 1
		
		ElseIf( QRef. HasKeyWord( ShowKey )
			Debug.Notification("Valid Kills: " + ValidKill )
			Debug.Notification("Kills: " + Kills )
		
		Else
		Kill += 1
	EndIf
EndEvent

Actor Script:

; Attach to Actor

	ObjectReference Property QCardinal Auto
	{ Reference to XMarker that hold Kills }
	
	; remember to give this actor KeyWord that
	; make kill valid - otherwise it will be counted as invaild kill

Event OnDeath()
	QCardinal.Activate( self )
EndEvent

i recomend you to create cell where you store all your XMarkers

Activate will always work even if cell is not loaded...

 

well it work for me...

 

 

Actor need to have special KeyWord

otherwise kill will be counted but as normal Kill

 

you can make counter for specific kills for example BossKills, SpecialUnitKills, NormalUnitKills etc.

 

also you can always cast "Activate" with Function Call like i show you with "ShowKey"

so you can use for example kills as power or anything...

; example with attaching to Spell
	
	ObjectReference Property QCardinal Auto
	{ Cardinal Ref. - XMarker that hold kills }
	
	FormList Property QCommandList Auto
	{ list of supporting commanad 
	 - for example:
	  :: set counter to 0 <ID: 0>
	  :: show kills <ID: 1>
	  :: Transform 10 kills to 10 Hp Points <ID: 2>
	}
	
Event OnEffectStart( ... can't remember what should be there xD )
 ; caster and target?... idk xD who cares we dont need them anyway
	QCardinal.Activate( QCommandList.GetAt( 3 ) as ObjectReference )
EndEvent

sry for my potato english :D

You can do anything with XMarkers and Activate :)

 

well KeyWords and Activate are like Pointers and Functions in C++ :D

also by using XMarkers and PlaceAtMe you can make C++ Classes and Objects xD

 

lol...

 

 

Once i did really something really stupid :o

in one of my work administrator block everything on ours computers =_=

 

only CMD console works, so when i was bored i start to write programs in CMD console xD

i made Classes and Objects using ECHO function xD

 

Echo function is to show Text in console window but also can be used to create files etc.

 

Echo set Value = 5 >> NewFile.bat

Echo echo %Value% >> NewFile.bat

Call NewFile.bat

 

but that was stupid idea cause once i made game ( 80.000 chars lenght :o )

and i broke computer xD cause my "game" was creating all time new objects - i just forgot to delete old files

and it was getting bigger and bigger...

 

and after few h of "playing" PC just frezzee xDDDDD

still not sure why but after this frezze it was hard to restart computer

 

maybe because there was only few MB space on disc left??

 

thanks god it works ( restart ) and i delete all my work :o

otherwise i would be forced to pay for broken computer xDDDD

 

 

 

btw. now i broke my Skyrim, idk what i did but Exterior worlds don't want to load

Link to comment
Share on other sites

  • Recently Browsing   0 members

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