Script to track when the player kills an actor (of a certain

Post » Sun Nov 18, 2012 12:05 am

Hey guys. I'm working on my hunting mod, and got to grips with some globals last week to create my fetch quests (Collect 10 somethings (X/10)). This was done attaching a script to the player alias to detect when they collected a pelt into their inventory. It was really daunting at first, but I understood it in the end and it works great. The reason I've explained this is because I think my next scripting challenge once again lies with quest aliases.

Now what I'd like to do is track when the player kills a wolf (GetIsRace) or a deer, or both. When the player kills one of these animals, it increases the golabl by 1. When the final count is reached, stage is complete.

I already have the knowledge of using variables and increasing them when a condition is met etc. What I'm struggling with is tracking the player killing these animals. If it was a unique actor, it'd be a simple case of attaching an OnDeath script to them. But because it's kill any wolf out of all wolves, I'm stumped. I thought maybe I could create an alias to all wolves, but I'm not sure how that would work either. There also doesn't seen to be an OnKill event either, which I could attach to the player.

If anyone can help me conquer this next hurdle I'd be really grateful :smile:

EDIT:

A video of my work with globals is here: http://www.youtube.com/watch?v=hVjtWpJHH1M
User avatar
Alex Vincent
 
Posts: 3514
Joined: Thu Jun 28, 2007 9:31 pm

Post » Sun Nov 18, 2012 4:54 am

Have a look at some of the Dark Brotherhood quests or any quest that has an objective of killing an NPC.
User avatar
Bambi
 
Posts: 3380
Joined: Tue Jan 30, 2007 1:20 pm

Post » Sun Nov 18, 2012 2:39 am

Story Manager is the "easiest" way to do it ... But not so easy if you have never done any SM stuff before. (That's SM ... not S & M!! :ooo: )

http://www.creationkit.com/Story_Manager

Have a read, then look at the events ... KillActor, being the one you want ... There is at least 1 more tutorial on the wiki

(be prepared ... at first it is as hard as hell to understand what you need to put where to get it to work ... once you have figured it, it is a great tool, though) :)
User avatar
Angus Poole
 
Posts: 3594
Joined: Fri Aug 03, 2007 9:04 pm

Post » Sun Nov 18, 2012 12:16 pm

Thanks guys. Hopefully all the people who have helped me will read this, but I just wanted to say thank you to everyone who's helped me get to grips with the CK, scripting, and all that stuff. I literally had no idea just a couple of months ago how to do anything, and now I'm doing things I never thought I'd be able to do (scripting wise). Thank you guys, seriously. Here is the WiP mod of all my hard work. You're all thanked in the mod description. Cheers! :D

http://skyrim.nexusmods.com/mods/18866
User avatar
Fiori Pra
 
Posts: 3446
Joined: Thu Mar 15, 2007 12:30 pm

Post » Sun Nov 18, 2012 6:52 am

Now what I'd like to do is track when the player kills a wolf (GetIsRace) or a deer, or both. When the player kills one of these animals, it increases the golabl by 1. When the final count is reached, stage is complete.

I'm doing something very similiar, here is the code snippet (realize, I tried to cut out parts you wouldn't need so this is not the EXACT functioning code. I apologize if I cut something I shouldn't have.):

Event OnCombatStateChanged(Actor akTarget, int aeCombatState)If aeCombatState == 0  ;Okay, we were fighting, see if it's dead now  If akTarget.IsDead()   If akTarget.IsInFaction(archEnemyFaction)	archEnemyKills += 1	AdjustRelationship("ThalmorKill")   Else	AdjustRelationship("Kill")   EndIf  EndIfEndIfendEvent

I have also tracked wolves and this worked fine. Basically, whatever faction you put in it tracks. Let me know if you have any questions.

Note: My code actually stores the Actor when combat starts because I use it in other events, I don't remember if I needed to do that here, so if the code doesn't work quite right, that may be the reason.
User avatar
Danny Blight
 
Posts: 3400
Joined: Wed Jun 27, 2007 11:30 am

Post » Sun Nov 18, 2012 12:18 pm

I'm doing something very similiar, here is the code snippet (realize, I tried to cut out parts you wouldn't need so this is not the EXACT functioning code. I apologize if I cut something I shouldn't have.):

Event OnCombatStateChanged(Actor akTarget, int aeCombatState)If aeCombatState == 0  ;Okay, we were fighting, see if it's dead now  If akTarget.IsDead()   If akTarget.IsInFaction(archEnemyFaction)	archEnemyKills += 1	AdjustRelationship("ThalmorKill")   Else	AdjustRelationship("Kill")   EndIf  EndIfEndIfendEvent

I have also tracked wolves and this worked fine. Basically, whatever faction you put in it tracks. Let me know if you have any questions.

Note: My code actually stores the Actor when combat starts because I use it in other events, I don't remember if I needed to do that here, so if the code doesn't work quite right, that may be the reason.

That looks like it'll do the job Sollar thank you :smile: So it's a variable inside the script that does the counting.

It would be a lot easier if there was an OnKill event. Similar to OnDeath. Oh well, thanks again dude :smile:

EDIT: So that script goes onto the player as an alias in a quest? Same as our other script to update global based on inventory?
User avatar
Emma Louise Adams
 
Posts: 3527
Joined: Wed Jun 28, 2006 4:15 pm

Post » Sun Nov 18, 2012 12:26 pm

That looks like it'll do the job Sollar thank you :smile: So it's a variable inside the script that does the counting.

It would be a lot easier if there was an OnKill event. Similar to OnDeath. Oh well, thanks again dude :smile:

EDIT: So that script goes onto the player as an alias in a quest? Same as our other script to update global based on inventory?
Yes, I track with a variable... actually, it's stored in an unused ActorValue "Fame", since it relates to the animals relationship with the player.

Attach that event to the Actor you want to track... so if you are tracking what the player kills, yes, I'd use a player alias.
User avatar
Mel E
 
Posts: 3354
Joined: Mon Apr 09, 2007 11:23 pm

Post » Sun Nov 18, 2012 9:37 am


Yes, I track with a variable... actually, it's stored in an unused ActorValue "Fame", since it relates to the animals relationship with the player.

Attach that event to the Actor you want to track... so if you are tracking what the player kills, yes, I'd use a player alias.

Thanks man I'll give it a go :)
User avatar
Reven Lord
 
Posts: 3452
Joined: Mon May 21, 2007 9:56 pm

Post » Sun Nov 18, 2012 6:43 am

Thanks very much for the credit :) This is a good little community that's provided a lot of help to a lot of people. Hope that continues for a long while yet

Congrats on your release and luck for the upgrades you want to make. Looks an impressive piece of work with 60+ Nexus-endorsemants and over 4000 DLs, so doing well. I'll give it a whirl when I'm back in game, after Beth has (fingers crossed) fixed the Dialogue issue.

Again, very well done - Always good to see them released :)
User avatar
Alberto Aguilera
 
Posts: 3472
Joined: Wed Aug 29, 2007 12:42 am


Return to V - Skyrim