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

Need help finishing script to equip item.


Durai
 Share

Recommended Posts

So after much trial and error I created a script that allows me to enjoy playing as a Werewolf. The problem is the stat increases remain permanent unless the amulet I scripted is re-equipped. Right now I'm trying to figure out a way to equip the amulet right after my character reverts from being a Werewolf. Here's what I have so far:


Scriptname WerewolfAmulet002 extends ObjectReference


Race Property WerewolfBeastRace Auto

GlobalVariable Property WasWerewolf Auto

Armor Property Amulet Auto


float BaseHealth

float BaseDResist

float BaseUnarmed

float BaseMResist

float BaseHealRate


Function BaseHealth (Actor TargetActor)

		BaseHealth = TargetActor.GetBaseActorValue("Health") as Float

EndFunction


Function BaseDResist (Actor TargetActor)

		 BaseDResist = TargetActor.GetBaseActorValue("DamageResist") as Float

EndFunction


Function BaseUnarmed (Actor TargetActor)

		 BaseUnarmed = TargetActor.GetBaseActorValue("UnarmedDamage") as Float

EndFunction


Function BaseMResist (Actor TargetActor)

		BaseMResist = TargetActor.GetBaseActorValue("MagicResist") as Float

EndFunction


Event OnEquipped(Actor akActor)

		BaseHealth(akActor)

		BaseDResist(akActor)

		BaseUnarmed(akActor)

BaseMResist (akActor)

		if akActor == Game.Getplayer()

						Game.GetPlayer().ForceAV("Health", BaseHealth)

						Game.GetPlayer().ForceAV("DamageResist", BaseDResist)

						Game.GetPlayer().ForceAv("UnarmedDamage", BaseUnarmed)

		 	 Game.GetPlayer().ForceAV("MagicResist", BaseMResist)

		endif

endEvent


Event OnUnequipped(Actor akActor)

		If akActor == Game.GetPlayer()

				If Game.GetPlayer().GetRace()==WerewolfBeastRace

						Game.GetPlayer().ModAV("Health", 100)

						Game.GetPlayer().ModAV("DamageResist", 200)

						Game.GetPlayer().ModAV("UnarmedDamage", 25)

		 Game.GetPlayer().ModAV("MagicResist", 35)

				EndIf

		EndIf

EndEvent

If anyone with scripting knowledge can lend me a hand, I'd be very grateful. I'm so close, I'd really hate to give up now.

P.S. there is a weird glitch where if the amulet is dropped, picked up, re-equipped and then I transform, all my stats are thrown out of whack. Anyone know why?

Link to comment
Share on other sites

1. Lets start by cleaning the code up. User functions are not required to do what you want since your only doing it once, and its one line of code.

2. In your OnEquipped block of code, you force the values to change, whether they are a werewolf or not. I do not understand why you do this, why not just mod the actor value with a negative number to remove your 'enhancements' when the amulet is 'UnEquipped'?


Game.GetPlayer().ModAV("Health", -100)
[/code]
[code]
Scriptname WerewolfAmulet002 extends ObjectReference

Race Property WerewolfBeastRace Auto
GlobalVariable Property WasWerewolf Auto
Armor Property Amulet Auto

float BaseHealth
float BaseDResist
float BaseUnarmed
float BaseMResist
float BaseHealRate

Event OnEquipped(Actor akActor)
BaseHealth = akActor.GetBaseActorValue("Health") as Float
BaseDResist = akActor.GetBaseActorValue("DamageResist") as Float
BaseUnarmed = akActor.GetBaseActorValue("UnarmedDamage") as Float
BaseMResist = akActor.GetBaseActorValue("MagicResist") as Float

if akActor == Game.Getplayer()
Game.GetPlayer().ForceAV("Health", BaseHealth)
Game.GetPlayer().ForceAV("DamageResist", BaseDResist)
Game.GetPlayer().ForceAv("UnarmedDamage", BaseUnarmed)
Game.GetPlayer().ForceAV("MagicResist", BaseMResist)
endif
endEvent

Event OnUnequipped(Actor akActor)
If akActor == Game.GetPlayer()
If Game.GetPlayer().GetRace()==WerewolfBeastRace
Game.GetPlayer().ModAV("Health", 100)
Game.GetPlayer().ModAV("DamageResist", 200)
Game.GetPlayer().ModAV("UnarmedDamage", 25)
Game.GetPlayer().ModAV("MagicResist", 35)
EndIf
EndIf
EndEvent

Link to comment
Share on other sites

  • 5 weeks later...

In my experience, forceav perma sets the av, while modav is temporary and shows up in the ui as red when the modded av is less than the base av and green when more than base. So, I am in agreement with WillieSea. IMHO you should try a function that uses modav to change your values. Pass the function a param that lets it know you are either equipping or unequipping and then just call the function from your onEquip and onUnEquip event.

I'm at work, so can't compile/test, but maybe something like this.


Scriptname WerewolfAmulet002 extends ObjectReference

Race Property WerewolfBeastRace Auto

GlobalVariable Property WasWerewolf Auto

Armor Property Amulet Auto

float BaseHealth

float BaseDResist

float BaseUnarmed

float BaseMResist

float BaseHealRate

float Property HealthMod Auto ; 100

float Property DResistMod Auto ; 200

float Property UnarmedMod Auto ; 25

float Property MResistMod Auto ; 35

float Porperty HRateMod Auto ; ??

int isWerewolfBeastRace

int isActorPlayer

Event OnEquipped(Actor akActor)

modAV(akActor) 

endEvent

Event OnUnequipped(Actor akActor)

modAV(akActor)

EndEvent

Function modAV(Actor akActor)

{Augments Base Actor Values if Player is in WerewolfBeastRace Form.}

    if isActorPlayer(akActor)

  setBaseAV(akActor)

  akActor.ModAV("Health", BaseHealth + (isWerewolfBeastRace(akActor) * HealthMod))

  akActor.ModAV("DamageResist", BaseDResist + (isWerewolfBeastRace(akActor) * DResistMod))

  akActor.ModAv("UnarmedDamage", BaseUnarmed + (isWerewolfBeastRace(akActor) * UnarmedMod))

  akActor.ModAV("MagicResist", BaseMResist + (isWerewolfBeastRace(akActor) * MResistMod))

  akActor.ModAV("HealRate", BaseHealRate + (isWerewolfBeastRace(akActor) * HRateMod))

endif

EndFunction

Function isWerewolfBeastRace(Actor akActor)

isWerewolfBeastRace = -1

If akActor.GetRace()==WerewolfBeastRace

  isWerewolfBeastRace = 1

End If

EndFunction

Function isActorPlayer(Actor akActor)

isActorPlayer = 0

if akActor == Game.getPlayer()

  isActorPlayer = 1

endif

End Function

Function setBaseAV(Actor akActor)

BaseHealth = akActor.GetBaseActorValue("Health") as Float

BaseDResist = akActor.GetBaseActorValue("DamageResist") as Float

BaseUnarmed = akActor.GetBaseActorValue("UnarmedDamage") as Float

BaseMResist = akActor.GetBaseActorValue("MagicResist") as Float

EndFunction

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