Jump to content

DOWNLOAD MODS

Are you looking for something shiny for your load order? We have many exclusive mods and resources you won't find anywhere else. Start your search now...

LEARN MODDING

Ready to try your hand at making your own mod creations? Visit the Enclave, the original ES/FO modding school, and learn the tricks of the trade from veteran modders...

JOIN THE ALLIANCE

Membership is free and registering unlocks image galleries, project hosting, live chat, unlimited downloads, & more...

Script Help - trying to force equip an item on dead or dying NPC


llocke1127
 Share

Recommended Posts

I'm trying to create a simple effect, but the application isn't really working.
 

Scriptname glowingdeath extends Actor

Armor Property Glow01 Auto
Sound Property buzzing Auto

Event OnDying(Actor akKiller)		

   self.EquipItem(Glow01)		
   nt instanceID1 = buzzing.play(self)     		
   Utility.Wait(30.0)		
   self.RemoveItem(Glow01)		
   Sound.StopInstance(instanceID1)

endEvent

This is the basis of what I want my script to accomplish. When the victim dies, I want a glowing effect to surround them for 30 seconds via an equipped item. It's important that the effect is via equipped item and not using shaders, there will be more to this mod when I work out all the kinks.

HOW IT WORKS:

The above script works BEAUTIFULLY when applied directly to an NPC's papyrus script. The effect is completely lost when I try to apply it to all actors.

HOW IT'S NOT WORKING:

To apply to all actors, I modified a simple perk (lighthands pickpocket rank 1) to add the Glow01 object as a leveled loot item to any victim I kill. This works, however, the Glow01 object is NEVER equipped, and I can't find the proper modifiers to equip it to my victims actively.

BACKWARDS NON-WORKING SCRIPT:
 

Scriptname glowingdeath extends ObjectReference

Armor Property Glow01 Auto
Sound Property buzzing Auto
Actor Property PlayerREF Auto

Event OnInit()		

   PlayerREF.EquipItem(Glow01)		
   int instanceID1 = buzzing.play(PlayerREF)     		
   Utility.Wait(30.0)		
   PlayerREF.RemoveItem(Glow01)		
   Sound.StopInstance(instanceID1)

endEvent

The above code is applied directly to the item, Glow01's papyrus script. When the victim dies, it adds the glow to my character and not my victim. Exactly what I don't want, but from a programmer standpoint, it proves the OnDeath function works when scripted on an equipable item.

The first issue is, no matter what I replace PlayerREF with {self akKiller akVictim} I can't find the right value to identify the VICTIM is the one who needs Glow01 equipped, not the player.

The second issue is, OnDeath() may not be the proper tool for this job. I've tried several others {OnDying(), OnItemAdded(), OnHit(), a dozen more that I can't recall} and they don't produce any results.

SHORT VERSION:

A: We can modify above code to force victim actor to equip the item. The problem here is I simply don't know how to reference a victim.

B: Find a different event type that will accomplish the same effect.


Thanks for your time, and I appreciate any help or advice anyone can offer.

Thanks. (edited to fix code format)

Edited by llocke1127
Link to comment
Share on other sites

Use onstorykillactor to start a quest. With new quest alias filled by event data victim and attach script to alias.

 

 

Something like below should do.

Scriptname glowingdeath extends Referencealias

Armor Property Glow01 Auto
Sound Property buzzing Auto

Event Oninit()        

getactorreference().EquipItem(Glow01)        
nt instanceID1
= buzzing.play(self)         
Utility.Wait(30.0)        
getactorreference().RemoveItem(Glow01)        
Sound.StopInstance(instanceID1)

endEvent

Edited by schatten
Link to comment
Share on other sites

Thanks for the response. 

 

I tried adding in a quest + a reference, but nothing seems to trigger the effect still.  The reference menu is way too picky to apply to "every" NPC that the player kills.  The issues stands that the editor has no conceivable way to target reference whatever NPC i just killed, regardless of race/type/etc.  If anyone has a solution for this I'd be grateful, or an easier way to reference NPCs that the player has no relation to other than killing them (leveled bandits for example).

 

 

 

Alternatively - I have a glow spell, when cast on target it causes them to glow for 30 seconds, exactly as effect above describes.  I've tried adding this as a perk "Cast On HIt" (like bullsye paralyze perk) but it still won't trigger the spell.  Is it possible to run a script to fire off the glow spell for anyone who has the Glow01 object in their inventory?

 

Thanks

Link to comment
Share on other sites

You didn't read what I wrote. ;)

 

You need to create a new quest, start via onstorykilled event (One condition if killer is player?). Add a new alias, fill type from event victim. Then you know when and who the player killed. Don't forget to stop the quest afterwards.

 

http://www.creationkit.com/Bethesda_Tutorial_Story_Manager

http://www.creationkit.com/Quest_Data_Tab

http://www.creationkit.com/Alias#Fill_Type:

Link to comment
Share on other sites

Ok, it makes a lot more sense when you put it that way.  I had no idea what an onstorykilled event was, but the links & quick explanation really helped clear that up.

 

I now have a working script that does exactly what I want, which is to equip the glow effect on whatever I kill for 30 seconds.  The problem I'm still facing is the quest either:

 

1.  Runs once and done; leaving glow on first kill for 30 seconds and no kills afterward

2.  Runs only while another victim isn't glowing; I can kill multiple targets and they glow, I just have to wait for the 30 second script to be done before the quest will start itself up again.

 

Any possible solutions to this you can think of?  I've been researching and fiddling all night, but haven't been able to make it run on more than one victim at a time.

 

 

Thanks for the help

Link to comment
Share on other sites

Hmmm...

I guess you can attach a script to the alias, this script adds a new spell ability or unplayable item/object to the alias, then stops the quest.

 

The flow would be:

1. Quest starts once you kill someone.

2. Quest alias is filled and the script is attached

3. Alias script adds a spell ability/object to victim

4. Quest is stopped

 

This would mean that the spell ability or object is still on the victim even after the quest is stopped.

You have to stop the quest as the SM only starts quests that are not running.

Link to comment
Share on other sites

Interesting.

 

Followed these steps and managed everyone to glow, even if they're killed within a second of eachother.  The glow doesn't automatically unequip from the actor though - once glowing they glow forever.  The quest script ends before the utility.wait(30) can do its business.

 

 

The next step would be to destroy the item itself.  I can run a script [ extends ObjectReference, event OnInit() ], the instant the item Glow01 appears in the world, regardless of who it's on.  No matter how many people have Glow01 equipped their onInit() runs unique to each victim.

 

Despite this, removeItem() / dropitem() / destroyitem() / etc. don't work.  The item also can't be naturally destoryed through Destructible Item menu.  The reference to the victim is also invalid since we quit the quest the instant it equipped Glow01 to the victim.

 

I think we're hitting a dead end on the equip item/unequip item for the glow effect.  I'll take another stab at it later using spell effects instead I think.

 

 

Thanks for all the help and input.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...