Jump to content

[SCRIPTING] Checking a Death


Recommended Posts

Hi everyone, I'm VERY new to scripting. I would like to know how I can check the death of an NPC remotely. The problem I am having is that I don't want to attach the script to an actor for compatibility reasons - as this actor is a vanilla NPC. If anyone could tell me (in simple terms) what I would need to do, I would be very grateful. I have been thinking of remotely adding a spell effect to the NPC from elsewhere, and then using a ActiveMagicEffect on that effect to do stuff when the actor dies. Honestly though, this is all above me.

 

Any help at all is appreciated. If you can add examples so I can learn (I'm a visual person) that would be dandy.

 

Many thanks.

Link to comment
Share on other sites

This is way way out of my capability, but could you not set up a quest that has that character as an alias and then attach a script to that alias ? Or is that just as 'incompatible' as attaching it to the base actor ?

Link to comment
Share on other sites

I thought about that, but that is why I am asking because I have no idea. You mean like this?:

 

http://www.creationkit.com/index.php?title=SM_Event_Node

 

I just want to get if the actor is dead and then do stuff if they are. Maybe I'll have say 5 people and I want to see if they are dead. I guess I could add a counter and when that counter reaches 5, the quest will stop running. I basically only started trying to script last night. I think my logic may be sound, but it's just executing it correctly that I'm struggling with.

Link to comment
Share on other sites

You can check for the alive/dead state of any actor on any running script anywhere with IsDead()

If Amren.IsDead() ; is actor dead?
; do dead stuff here
Else 
; do other non-dead stuff here
Endif

Or if the actor is in a reference alias that has a script attached you can use the On Death event


Event OnDeath(Actor akKiller)
; game has noticed actor has just died so do stuff here, akKiller is the actor who did the killing
EndEvent

you don't need a script though you can just use a condition function on a specific reference or simply subject if attached to a reference alias. :thumbsup:

 

http://i.imgur.com/7mVlvEP.png

Edited by soupdragon1234
Link to comment
Share on other sites

  On 5/4/2016 at 1:35 PM, arronus said:

Thank you. I'm going to have to read more into ReferenceAlias because I'm currently assuming it allows you to do stuff with NPCs without affecting their base?

 

Yes exactly, think of it as a box that the actor sits inside, you can attach scripts, ai packages, factions, keywords etc to the box without compromising the actor within. :wink:

Edited by soupdragon1234
Link to comment
Share on other sites

Okay I'm a bit stuck here because I wanted to have a go at the ReferenceAlias option. I went to the wiki but I can't find any information really. So I have an ObjectReference script and I want the player to activate this. When activated, if the NPC isn't dead, it should shows a messagebox; otherwise it shows a menu. I can't use IsDead from the ObjectReference script because it says it doesn't exist. Now, I need to check if someone's dead and report that value to my object. I'm going to go and say an alias should be setup from a quest? I have no idea how to set this up though really.

Edited by Guest
Link to comment
Share on other sites

An activator that checks for an actor to be dead?

Scriptname lalala extends ObjectReference

Actor Property MyTargetActor Auto
{point this in ck to the actor in question, if this was an objectreference you would have to cast to actor later}
Message Property MyMessage Auto
{fill with the message to show}

Event OnActivate(ObjectReference akActionRef)
If MyTargetActor.IsDead()
  MyMessage.Show()
Else
;maybe do something if he is not dead? another message? if not then remove else
Endif
EndEvent
Edited by FrankFamily
Link to comment
Share on other sites

  • Recently Browsing   0 members

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