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...

Referencing the attached object in an "ObjectReference" Script?


Penguinchao
 Share

Recommended Posts

So I'm working on a script that is supposed to resemble the bound armor in TESIV. The variant that I'm having trouble with is one designed solely for NPCs. The goal is to have the spell trigger when the NPC goes into combat, and have it automatically dispel when he dies or leaves combat. I have just about everything sorted out, but I don't know how to have the "EquipItem" function reference the actor that the script is attached to.

 

Here's what I have so far:

 

Scriptname VHBoundArmorMythicDawnDeathDispel extends ObjectReference  

;Begin Bound Armour list
Armor Property Helmet  Auto  
Armor Property chest  Auto  
Armor Property boots  Auto  
Armor Property Hands  Auto 
;End Bound Armour list
;Begin Regular Clothes list 
Armor Property Robe  Auto  
Armor Property RobeBoots  Auto  
Armor Property RobeHands  Auto  
;End Bound Armor list
Message Property FailedEquip  Auto  
Int Property Worked  Auto  
SPELL Property ThisSpell  Auto  


Event OnCombatStateChanged(Actor akTarget, int aeCombatState)
	if (aeCombatState == 1)
		SELF.AddItem(Helmet)
		;SELF.EquipItem(Helmet)
		SELF.AddItem(chest)
		;SELF.EquipItem(chest)
		SELF.AddItem(boots)
		;SELF.EquipItem(boots)
		SELF.AddItem(Hands)
		;SELF.EquipItem(Hands)
		SELF.RemoveItem(Robe)
	elseif (aeCombatState == 0)
		;Put the same things as in "OnDying" in this area once bugs worked out
	else
	endif
endEvent

;======================================================
;The functions that have the semicolons are the ones that aren't working. Since they couldn't work, I nulled them for the time being
;so that the script could compile as-is. I'm wanting the person that this script is attached to to equip the items in those
;circumstances.
;======================================================


Event OnDying(Actor akTarget, Actor akCaster)
		SELF.RemoveItem(Helmet)
		SELF.RemoveItem(chest)
		SELF.RemoveItem(boots)
		SELF.RemoveItem(Hands)
		SELF.AddItem(Robe)
		;EquipItem(Robe)
		;EquipItem(RobeHands)
		;EquipItem(RobeBoots)
endEvent

Edited by Penguinchao
Link to comment
Share on other sites

This script is not a spell script. So, how is this script attached in your mod?

 

I would probably try and use the 'onEquipped' function to grab the actor reference. Then convert the actor reference to an object reference and store that in a property which you can use again later.

Link to comment
Share on other sites

Sorry, I described that wrong. It's supposed to appear that there is a spell being cast, but there really isn't one (that way the NPC is forced to "cast" when entering combat). The script is attached to a person, and when they enter combat, they are given and equip certain armour, then that armor is removed and their old clothes equipped out of combat.

 

So do you mean like have each piece of clothing equip the old clothing when it's taken off?

 

Such as attach this to each piece of clothing?

 

 

 

Event OnUnequipped(Actor akActor)
akActor.AddItem(OtherClothesProperty, 2, true)

akActor.EquipItem(OtherClothesProperty)

akActor.RemoveItem(ThisPieceofClothingProperty, 1, true)

endEvent

EDIT:

Thanks a million! Got it to work; I'll post the series of working scripts in the repository in a bit for anybody that wants them :)

EDIT 2:

Ran into another problem; I'll post if I find a fix :)

Edited by Penguinchao
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...