How to Refer to self ?

Post » Wed Jun 20, 2012 5:16 pm

I am trying to attach a script to an actor who's name is id is character2 and another actor whose name is Person2
When either of them die I want to activate character1 or person1 respectively. I wrote this script and attached it to the actors
How ever I think self may not work correctly here as they are not replaced ?



Scriptname ZZDragondead extends Actor
ObjectReference Property Character1 Auto
ObjectReference Property Character2 Auto
ObjectReference Property Person1 Auto
ObjectReference Property Person2 Auto



Event OnDeath(Actor akKiller)

if Self == Character2
Character1.enable()
if (akKiller == Game.GetPlayer())
(Character1 as Actor).startcombat(game.getplayer())
Debug.Trace("Character2 was killed by the player!")
endif
endIf
if Self == Person2
Person1.enable()
if (akKiller == Game.GetPlayer())
(Person1 as Actor).startcombat(game.getplayer())
Debug.Trace("Person2 was killed by the player!")
endif
endIf
endEvent
User avatar
Scott
 
Posts: 3385
Joined: Fri Nov 30, 2007 2:59 am

Post » Wed Jun 20, 2012 8:36 pm

Why don't you just make separate scripts?
User avatar
James Wilson
 
Posts: 3457
Joined: Mon Nov 12, 2007 12:51 pm

Post » Wed Jun 20, 2012 1:56 pm

ScriptName ZZDragondead extends ActorObjectReference Property Character1 AutoObjectReference Property Character2 AutoObjectReference Property Person1 AutoObjectReference Property Person2 AutoEvent OnDeath(Actor akKiller)	If GetBaseObject(Character2)		Character1.Enable()		if (akKiller == Game.GetPlayer())			(Character1 as Actor).StartCombat(Game.GetPlayer())			Debug.Trace("Character2 was killed by the player!")		endif 	ElseIf GetBaseObject(Person2)		Person1.Enable()		if (akKiller == Game.GetPlayer())			(Person1 as Actor).StartCombat(Game.GetPlayer())			Debug.Trace("Person2 was killed by the player!")		endif 	endIf	EndEvent 
Alternatively, you could just attach the same script to separate actors with only two properties, then point said properties accordingly for each instance.
User avatar
Krystina Proietti
 
Posts: 3388
Joined: Sat Dec 23, 2006 9:02 pm

Post » Wed Jun 20, 2012 5:51 pm

Thanks for all the Help. I Had thought about separate scripts but wanted to see if one actor could carry the script where they go thus coming across different actors on their way.
All good stuff... I really want to thank you guys for your suggestions and help.
User avatar
Emma louise Wendelk
 
Posts: 3385
Joined: Sat Dec 09, 2006 9:31 pm


Return to V - Skyrim