OnKill event?

Post » Tue Jun 19, 2012 1:02 pm

Basically I need something like OnDeath, but i need it to listen for when the player kills an actor. i don't want to have to attach an OnDeath to every possible NPC


what i'm trying to accomplish is to write a script that attaches to the player alias that will fire off a conditional function every time the player kills an npc


pseudo code:


Event OnKill (Actor akVictim)

if akVictim.getrace == khajiit

akvictim.additem(khajiitFur)

elseif akVictim.getrace == argonian

akvictim.additem(argonianScales)

endif

endEvent



you get the idea.

i know there is an event called onStoryKillActor, but i don't think that is what i need (but then again i dont fully understand that one so if you have insights please let me know)
User avatar
Natasha Biss
 
Posts: 3491
Joined: Mon Jul 10, 2006 8:47 am

Post » Tue Jun 19, 2012 4:27 pm

There is no event you can use for this, but what you can do is add a perk to the player with an "Add Leveled List On Death" type perk entry that adds a scripted token (a piece of unplayable, and therefore invisible armour) to the inventory of the actor killed by the player, and use an event in the token's script that will run when the token is created/added to an inventory.

Cipscis
User avatar
no_excuse
 
Posts: 3380
Joined: Sun Jul 16, 2006 3:56 am

Post » Wed Jun 20, 2012 2:39 am

interesting....
you gave me an idea. if i try this as a perk/magic effect i could maybe use OnEffectFinish to listen for the victim's death. (like the Soul Trap thing)
User avatar
Umpyre Records
 
Posts: 3436
Joined: Tue Nov 13, 2007 4:19 pm

Post » Wed Jun 20, 2012 2:41 am

Actually, http://www.creationkit.com/ActiveMagicEffect_Script are sent events from the http://www.creationkit.com/Actor_Script on which they're running. Although I think the effect will be dispelled before http://www.creationkit.com/OnDeath_-_Actor is called, you could try listening for http://www.creationkit.com/OnDying_-_Actor.

Cipiscis
User avatar
Kate Norris
 
Posts: 3373
Joined: Mon Nov 27, 2006 6:12 pm

Post » Tue Jun 19, 2012 10:05 pm

onStoryKillActor will probably do what you want.

It'll try and start a radiant quest, so you'll need to add one to the story manager. You can pass the actor killed as quest alias. Then handle the scripting from the RQ and have it complete once you've done.
User avatar
steve brewin
 
Posts: 3411
Joined: Thu Jun 21, 2007 7:17 am

Post » Tue Jun 19, 2012 1:13 pm

you can make a quest and hook it up to the approriate story manager event.
User avatar
Benjamin Holz
 
Posts: 3408
Joined: Fri Oct 19, 2007 9:34 pm

Post » Tue Jun 19, 2012 11:28 pm

onStoryKillActor will probably do what you want. It'll try and start a radiant quest, so you'll need to add one to the story manager. You can pass the actor killed as quest alias. Then handle the scripting from the RQ and have it complete once you've done.


ok i tried this.

i created a new quest. set it to event type Kill Actor

created a new alias to be filled with Victim from above mentioned event, allowed dead

i added debug message "started" on stage 0 fragment - no result

i added debug on attached script of alias with Event OnDeath - no result

i added debug to the main script file attached at the scripts tab using OnStoryKillActor - no result


sorry man i don't understand how this system works. how does the quest event trigger anything? and how does the alias get filled?
User avatar
james kite
 
Posts: 3460
Joined: Sun Jul 22, 2007 8:52 am

Post » Tue Jun 19, 2012 5:50 pm

You need to add an entry under the Story Manager tab in the object window. Double click on Kill Actor and either add your own branch or find a branch that does roughly the same thing. You need to add the quest to the branch, and probably some conditions so it only fires when you need it to fire.

And that should do it. I think. (Not at my CK at the moment)
User avatar
Nice one
 
Posts: 3473
Joined: Thu Jun 21, 2007 5:30 am

Post » Tue Jun 19, 2012 4:32 pm

You may also want to add some conditions on the branch. Its explained in the wiki tutorial section.
User avatar
KiiSsez jdgaf Benzler
 
Posts: 3546
Joined: Fri Mar 16, 2007 7:10 am

Post » Tue Jun 19, 2012 10:51 pm

got it working.

thanks
User avatar
Curveballs On Phoenix
 
Posts: 3365
Joined: Sun Jul 01, 2007 4:43 am

Post » Tue Jun 19, 2012 11:11 pm

this doesnt make any sense.

i set the conditions to fire only if the event victim is of a certain race but it still fires regardless, even if i kill a cow



nevermind, i had the conditions in the wrong order
User avatar
neil slattery
 
Posts: 3358
Joined: Wed May 16, 2007 4:57 am

Post » Wed Jun 20, 2012 1:15 am

wow the story manager is pretty amazing. im definitely going to be using this a lot in the future
User avatar
WTW
 
Posts: 3313
Joined: Wed May 30, 2007 7:48 pm

Post » Tue Jun 19, 2012 11:44 pm

Yeah, it's a great way of making ad-hoc storage for temp effects

People get hung up on the "quest" aspect of it, but it's more an event handler than anything, I think
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Tue Jun 19, 2012 1:14 pm

I have a question regarding using OnStoryKillActor event for such thing. I read on the wiki that you need to check some checkboxes or something to allow an event to start multiple quests but didn't have time to look at everything that's done on those SM nodes in CK. My question is: are the vanilla story manager quests configured so they allow starting together with your new quest without you having to edit something for all of them? I'm affraid that adding such quests will make vanilla quest not to start, or your quest not to start if a vanilla is started.
Thanks
User avatar
Bethany Watkin
 
Posts: 3445
Joined: Sun Jul 23, 2006 4:13 pm

Post » Wed Jun 20, 2012 12:52 am

That checkbox is if you want multiple instances of the same quest running. So you'd tick the box if you wanted to be able to spawn a quest each time the event cropped up. It shouldn't stop any vanilla quests from launching
User avatar
Rude Gurl
 
Posts: 3425
Joined: Wed Aug 08, 2007 9:17 am

Post » Wed Jun 20, 2012 12:02 am

That checkbox is if you want multiple instances of the same quest running.
I strongly doubt you could do that, yet I agree it would be awesome...just think that you can call a function on a quest from a diferent script and you just do it on the quest not some other type of instance, how would you identify the instance you want to work on as each running quest can have different values for the properties and variables? A Quest is already an instance in running or stoped state, it doesn't spawns instances when runs.
So that checkbox must be for an event to be able to lunch multiple quests as I initialy understood from wiki:

Starting Multiple Quests

Typically, once the Story Manager starts a quest from an event, the event is "consumed" and no more quests are started. However, there are two ways to make the Story Manager start multiple quests from a single event:
  • If a Quest Node is marked as "Shares Event", the Story Manager will process another node in its list until it gets to a node that isn't marked as "Shares Event." Be careful how your node tree is structured as you don't want the Story Manager to accidentally process a non-"Shares Event" node before you wanted it to process a "Shares Event" node.
  • If a Quest Node has the "Num quests to start" checked, the Story Manager will attempt to start every quest in the Quest Node up to the number given. The Story Manager will start each valid quest until it either reaches the maximum number of quests to start or runs out of valid quests in the node.
So this is why I ask: is it safe to add a quest using OnStoryKillActor and expect it to run for each kill, or it will not start if another vanilla quest is started or will block vanilla quests from starting unless you modify all the conditions for the vanilla quests...
User avatar
MR.BIGG
 
Posts: 3373
Joined: Sat Sep 08, 2007 7:51 am

Post » Tue Jun 19, 2012 7:56 pm



I strongly doubt you could do that, yet I agree it would be awesome...just think that you can call a function on a quest from a diferent script and you just do it on the quest not some other type of instance, how would you identify the instance you want to work on as each running quest can have different values for the properties and variables? A Quest is already an instance in running or stoped state, it doesn't spawns instances when runs.

So that checkbox must be for an event to be able to lunch multiple quests as I initialy understood from wiki:




Hmmm...





  • Max concurrent quests: Check and enter a number in the corresponding field. The Story Manager will limit the number of quests that can be started from this node, up to the number given. For example, with a Max concurrent quests of 2, the Story Manager will not start another quest from this node if 2 of the quests in this node are running.




You could well be right. I was wondering how I got from an actor back up to his quest alias in cases like that. I may need to re-think for a major chunk of what I had planned.






Starting Multiple Quests



Typically, once the Story Manager starts a quest from an event, the event is "consumed" and no more quests are started. However, there are two ways to make the Story Manager start multiple quests from a single event:



  1. If a Quest Node is marked as "Shares Event", the Story Manager will process another node in its list until it gets to a node that isn't marked as "Shares Event." Be careful how your node tree is structured as you don't want the Story Manager to accidentally process a non-"Shares Event" node before you wanted it to process a "Shares Event" node.

  2. If a Quest Node has the "Num quests to start" checked, the Story Manager will attempt to start every quest in the Quest Node up to the number given. The Story Manager will start each valid quest until it either reaches the maximum number of quests to start or runs out of valid quests in the node.


So this is why I ask: is it safe to add a quest using OnStoryKillActor and expect it to run for each kill, or it will not start if another vanilla quest is started or will block vanilla quests from starting unless you modify all the conditions for the vanilla quests...



Ah, right. I thought you meant vanilla conventional quests, rather than vanilla radiants. Still,



  • If you mark your quest as "shares event" then it won't consume the event, and anything else that would have run will still run anyway.

  • On the other hand, if your quest is fairly specific, you can put conditions on it like "only if the dead actor is my custom NPC and his quest is running" and then it's probably safe to consume the event.

  • if you have a "stacked" branch, then you can add your event to the end. It will only fire if nothing else consumes it, of course, but again, this may be what you want

  • Anything in a "random" branch is probably fairly safe. All you do by consuming the event in slightly reduce the chances of the other events firing



[edit]

don't know what happened to the editor there. Sorry about the mess.
User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am


Return to V - Skyrim