Detecting NPC deaths, then giving player an ability... no cl

Post » Sun Nov 18, 2012 3:19 am

So I've got a perk that simply put, makes it so if you kill 3 enemies within 6 seconds, it gives you a fear ability that lasts for 30 seconds. This fear ability causes a short fear effect on ALL actors you hit with it that can be affected by fear.

But for some reason, on a really low level my script just doesn't seem to work at all.

Here is how my perk is set up:

1. Main perk the player selects. This perk grants a Constant Effect on Self ability to the player, that essentually is a cloak with 20 magnitude (range).

2. This cloak simply casts a spell effect that does nothing but cast a Script effect archetype onto all actors within the above magnitude of the cloak. This is delivered via Concentration -> Aimed, which is required by cloak spells as the delivery method.

3. The script does all the nessicary thinking/work to calculate when NPC's die, when it should cast the fear ability on the player, etc. But it never even gets to that point...

Here's the script that gets casted onto NPC's within cloak range:

Scriptname CPO_ChampionsOnslaughtCasterScript extends activemagiceffectactor PlayerRefactor EnemyRefPerk Property CPO_ChampionsOnslaughtFear AutoKeyword Property WeapTypeBattleaxe AutoGlobalVariable Property CPO_PlayerIsChampOnslaughting AutoGlobalVariable Property CPO_ChampOnslaughtDeathCounter AutoGlobalVariable Property CPO_PlayerHasCOFearCloak AutoQuest Property CPO_ChampOnslaughtAbilityQuest AutoEvent OnEffectStart(Actor akTarget, Actor akCaster)  EnemyRef = akTargetendEventEvent OnDying(Actor akKiller)PlayerRef = Game.GetPlayer()if akKiller == PlayerRef && PlayerRef.WornHasKeyword(WeapTypeBattleaxe)  CPO_ChampOnslaughtDeathCounter.SetValue((CPO_ChampOnslaughtDeathCounter.GetValue() as int) + 1)  if CPO_PlayerIsChampOnslaughting.GetValue() == 0   (CPO_ChampOnslaughtAbilityQuest as CPO_ChampOnslaughtQuest).RegisterForSingleUpdate(6)   CPO_PlayerIsChampOnslaughting.SetValue(1)  endif  if CPO_ChampOnslaughtDeathCounter.GetValue() >= 3 && CPO_PlayerHasCOFearCloak.GetValue() == 0   PlayerRef.AddPerk(CPO_ChampionsOnslaughtFear)   CPO_PlayerHasCOFearCloak.SetValue(1)   Utility.Wait(30)   PlayerRef.RemovePerk(CPO_ChampionsOnslaughtFear)   CPO_PlayerHasCOFearCloak.SetValue(0)  endifendifEndEvent

I can't see any glaring issues. When I test in game, and kill 3 actors with a battleaxe within 6 seconds (much shorter, actually), I check in-game if CPO_PlayerIsChampOnslaughting outputs to "1" like it should as soon as an actor dies, an indicator that the script is engaged, nothing happens and the variable still outputs to "0".

This is indicating that it never even fired despite killing NPC's within range of my cloak. This also indicates my script isn't even firing at the most basic level. I'm sure its a really simple soltuion but I simply cant figure out why this isn't working.

Any help? :(
User avatar
BethanyRhain
 
Posts: 3434
Joined: Wed Oct 11, 2006 9:50 am

Post » Sun Nov 18, 2012 3:30 pm

i think WornHasKeyword will return false on a weapon 100% of the time regardless if that weapon has a keyword (i think it only applies to ARMO objects).

try using GetEquippedWeapon and run HasKeyword on the returned weapon value
User avatar
Schel[Anne]FTL
 
Posts: 3384
Joined: Thu Nov 16, 2006 6:53 pm

Post » Sun Nov 18, 2012 4:23 am

Will try, but I've not had any issues with that before on any of my other scripts. Can't hurt to try though.

I'm wondering if its the OnDying event (I've tried OnDeath too). Being the script is applied via activemagiceffect something tells me that it doesn't detect "ondying" when the actor dies, since maybe activemagiceffect doesn't keep track of such events (as the script is attached to the spell effect, not the NPC)? However usually when that happens I get compile errors, but it compiles clean for me. And I know events like OnHit work with activemagiceffect.
User avatar
Cameron Garrod
 
Posts: 3427
Joined: Sat Jun 30, 2007 7:46 am

Post » Sun Nov 18, 2012 12:03 pm

This seems a case where adding in a few debug messages would likely help enormously. Is the OnDying event being triggered? Is the first "if" statement being passed? Etc. Put debug messages after each, and see what they reveal.
User avatar
Valerie Marie
 
Posts: 3451
Joined: Wed Aug 15, 2007 10:29 am

Post » Sun Nov 18, 2012 4:30 pm

I agree on the debug comments

Also, to simplify testing, I would get rid of the battleaxe condition ... just kill them with anything until you get the script to fire, then sixy it up

(I assume you have actually created the global variables as objects in the CK? I think you must have done or you would get compile errors? ... I think ... !)



And I would do the Utility.Wait(30) then remove perk thing another way

It would be better to register for 30-secs, or something similar, then have another script activate that removes the perk (I think) ... I'm not sure what effect waiting like that is having on the application side of your script.
User avatar
Angela Woods
 
Posts: 3336
Joined: Fri Feb 09, 2007 2:15 pm

Post » Sun Nov 18, 2012 3:04 pm

You know in your script you have a Registerforsingleupdate, where is the OnUpdate event proceeding it? Isn't that required to fire an event after the game has waited?
User avatar
Steve Smith
 
Posts: 3540
Joined: Sat Jun 30, 2007 10:47 am

Post » Sun Nov 18, 2012 4:59 pm

I'll play around with debug messages, though my global vairables (which I have made) kind of act like that as well - since they should be changing almost immediately after death. I'll try moving some around as the very first action - so it'll check if OnDying even happens (I'm thinking it isn't), but it doesn't hurt to try). One possible reason this might not be working is that I'm unsure if scripts attached to spells still exist once an actor dies. I.E. this script is applied via a magic effect to the actor, which detects when the actor dies. However if dieing means all spells they have are dispelled, then theoretically that means the script never fires, because the spell it is attached to disappears. However I've tried testing with "No Death Dispel" enabled in the magic effect that delivers this script, and it didn't change much.

Also, in reguards to the update, it is registering an update in a seperate script. It refers to the quest "ChampOnslaughtAbilityQuest", and Registers for an Update on the "ChampOnslaughtAbility" script within that quest.
User avatar
ILy- Forver
 
Posts: 3459
Joined: Sun Feb 04, 2007 3:18 am

Post » Sun Nov 18, 2012 12:08 pm

I.E. this script is applied via a magic effect to the actor, which detects when the actor dies.
Ah ... now then ... you could well be correct there ... OnDying and Dead happen very quickly ... and on Dead I don't think you can have the NPC run any spells (don't know about OnDying)... So this might be what is happening - Certainly worth your time to test and check
User avatar
Ronald
 
Posts: 3319
Joined: Sun Aug 05, 2007 12:16 am

Post » Sun Nov 18, 2012 1:04 pm

It's certainly the OnDying/Ondeath event that is the problem.

Those are both events of the actor script, and activemagiceffect should not be able to use them, because it does not extend the actor script.

You should probably just run updates for the duration of the spell, checking if the actor's health is <= 0, and if it is, do the stuff you want to do. I'm not sure how you would get the killer like that though.

If you need to use OnDeath/OnDying it has to be in a script that extends actor.

Edit: Oh, I just read that active magic effects receieve events from the actor they're attached to. I don't know, maybe only some of them work.
User avatar
jess hughes
 
Posts: 3382
Joined: Tue Oct 24, 2006 8:10 pm

Post » Sun Nov 18, 2012 3:00 pm

It must be able to work with it since usually if you use an event that a base script doesn't support, it'll not compile. However my script compiles fine.

I think the issue is probably due to the fact that while OnDeath technically may work with active magic effects, it probably practically does not - due to the magic effect going away (and as such, the script) once the actor does die. It seemed like enableing "No Death Dispel" didn't do anything but I'll have to try more tests to see if that in fact is true.

I'm wondering if my magic effect as a whole simply isn't being applied though. I'll have to set up an OnEffectStart event to check for that. That would mean its an error with how my cloak chain is set up. Wouldn't surprise me, since cloak effects are very fickle with what works and what doesn't on them.
User avatar
Vera Maslar
 
Posts: 3468
Joined: Wed Sep 27, 2006 2:32 pm

Post » Sun Nov 18, 2012 3:22 pm

For what it's worth, issue solved.

Did more and more testing, and it turns out the problem wasn't with the script - it was with the delivery of the cloak.

Turns out, you need to have a duration of at least 1 for cloak effects to work... somehow I had accidently set my cloak's effect for this to be at 0 and "no duration", thinking the cloak would always apply the effect as a kind of "constant effect" to people in range, when in reality it simply doesn't apply the cloak at all. So I had to set my duration of the effect the cloak applies to NPC's to 1, which made everything fall in place and work.
User avatar
Spencey!
 
Posts: 3221
Joined: Thu Aug 17, 2006 12:18 am


Return to V - Skyrim