Modify Stats on Equip

Post » Mon Jun 18, 2012 6:37 pm

I have been reading different things and trial and error all morning. So it's time to ask for help.

I am trying to increase the players walking speed when he equips boots and then resets back to normal after he unequips them. This is the script I have now
Scriptname Apostlespeed extends ObjectReference
Armor Property ApostleBoots Auto

Event OnObjectequipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject as Armor
Debug.Trace("This actor just equipped a piece of armor!")
endIf
Game.GetPlayer().ModActorValue("speedmult", 300)
endEvent
Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
if akBaseObject as Armor
Debug.Trace("This actor just unequipped a piece of armor!")
endIf
Game.GetPlayer().ModActorValue("speedmult", -300)
endEvent

I have tried adding the boots as an objectreference and the armor in the properties. I am kind of confused on how the syntax should look for this (Event OnObjectequipped(Form akBaseObject, ObjectReference akReference)). I have seen it done like this in some examples but I am not exactly sure.

Any help will be much appreciated!
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am

Post » Mon Jun 18, 2012 12:48 pm

Okay I figured it out, if anyone is interested in doing this I will explain. Instead of using the Onobjectequipped I used the OnEquipped instead. So my script now looks likes this:
Scriptname Apostlespeed extends ObjectReference
Armor Property ApostleBoots Auto

Event OnEquipped(Actor akActor)
if akActor == Game.GetPlayer()
Game.GetPlayer().ModActorValue("speedmult", 300)
endif
endEvent
Event OnUnequipped(Actor akActor)
if akActor == Game.GetPlayer()
Game.GetPlayer().ModActorValue("speedmult", -300)
endif
endEvent

So essentially the 1st line (Event OnEquipped...) is activating everytime the item is equipped on an actor. The 2nd line asks the item if the actor who equipped it is the player, and if it is to activate the next portion of the script. The 3rd line tells the game to add the attribute to the player. This attribute can be anything seen here www(dot)creationkit(dot)com/Actor_Value_List . Anyway that was my quick explanation of the script, because I was having problems understanding it at first. I hope my explanation helped someone.
User avatar
Code Affinity
 
Posts: 3325
Joined: Wed Jun 13, 2007 11:11 am


Return to V - Skyrim