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

Minus signs ignored by script?


Pacmasian
 Share

Recommended Posts

I'm trying to fix the Fists Of Steel perks by editing the player's unarmed damage through Self.Modav("Unarmeddamage" Bonus) where Bonus is a complicated variable. I've set it to an OnObjectEquipped event, and it works fine. (Just to be clear, the script is on the Player Actor, not the Perk).

 

The problem is that I also have a Self.Modav("Unarmeddamage" -Bonus) that's on a OnObjectUNequipped event, and it doesn't do anything at all. Now, I know that the minus sign DOES make a difference, cause if I leave the minus out it just adds the bonus again when I unequip. But it absolutely does not actually minus anything when I put the minus in, just stops it from adding twice.

 

Player.getavinfo unarmeddamage returns the same amount before and after unequipping the gauntlets. Am I missing something about maths in papyrus?

Link to comment
Share on other sites

Thanks WillieSea. Unfortunately, I tried that last night and it didn't work either... Actually, it worked once. I was Equipping and Unequipping in-game to test it out, and my unarmed damage was bumped up to ~120, then down to ~100 (one -Bonus worth) and then it didn't go down again. Is my script taking too long to run?

Link to comment
Share on other sites

This is my code, if anyone was wondering. Any help would be appreciated.

Scriptname PACFistsOfSteel extends Actor

Perk Property FistsOfSteel Auto
Perk Property WellFitted Auto
Perk Property MatchingSetHeavy Auto
Perk Property Juggernaut80 Auto
Perk Property Juggernaut60 Auto
Perk Property Juggernaut40 Auto
Perk Property Juggernaut20 Auto
Perk Property Juggernaut00 Auto
Perk Property CustomFit Auto
Perk Property MatchingSetLight Auto
Perk Property AgileDefender80 Auto
Perk Property AgileDefender60 Auto
Perk Property AgileDefender40 Auto
Perk Property AgileDefender20 Auto
Perk Property AgileDefender00 Auto

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		Armor Gauntlets = Game.GetPlayer().GetWornForm(0x00000008) as Armor
		If Game.GetPlayer().HasPerk(FistsOfSteel)
			Int WeightClass = Gauntlets.GetWeightClass()
			If (WeightClass == 0)
				Int ArmorSkill = (Game.GetPlayer().GetAV("HeavyArmor")) as Int
				Float Unison
				Float Matching
				Float ArmorPerk
				If Game.Getplayer().HasPerk(WellFitted)
					Unison = 0.25
					Else
					Unison = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetHeavy)
					Matching = 0.25
					Else
					Matching = 0
				EndIf
				If Game.Getplayer().HasPerk(Juggernaut80)
					ArmorPerk = 1
					ElseIf (Game.Getplayer().HasPerk(Juggernaut60))
					ArmorPerk = 0.8
					ElseIf (Game.Getplayer().HasPerk(Juggernaut40))
					ArmorPerk = 0.6
					ElseIf (Game.Getplayer().HasPerk(Juggernaut20))
					ArmorPerk = 0.4
					ElseIf (Game.Getplayer().HasPerk(Juggernaut00))
					ArmorPerk = 0.2
					Else
					ArmorPerk = 0
				EndIf
				Int Bonus = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkill)*(1+Unison+Matching)*(1+ArmorPerk)) as Int
				Self.ModAV("UnarmedDamage", Bonus)
			ElseIf (WeightClass == 1)
				Int ArmorSkill = (Game.GetPlayer().GetAV("LightArmor")) as Int
				Float Unison
				Float Matching
				Float ArmorPerk
				If Game.Getplayer().HasPerk(CustomFit)
					Unison = 0.25
					Else
					Unison = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetLight)
					Matching = 0.25
					Else
					Matching = 0
				EndIf
				If Game.Getplayer().HasPerk(AgileDefender80)
					ArmorPerk = 1
					ElseIf (Game.Getplayer().HasPerk(AgileDefender60))
					ArmorPerk = 0.8
					ElseIf (Game.Getplayer().HasPerk(AgileDefender40))
					ArmorPerk = 0.6
					ElseIf (Game.Getplayer().HasPerk(AgileDefender20))
					ArmorPerk = 0.4
					ElseIf (Game.Getplayer().HasPerk(AgileDefender00))
					ArmorPerk = 0.2
					Else
					ArmorPerk = 0
				EndIf
				Int Bonus = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkill)*(1+Unison+Matching)*(1+ArmorPerk)) as Int
				Self.ModAV("UnarmedDamage", Bonus)
			EndIf
		EndIf
	EndIf
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		Armor Gauntlets = Game.GetPlayer().GetWornForm(0x00000008) as Armor
		If Game.GetPlayer().HasPerk(FistsOfSteel)
			Int WeightClass = Gauntlets.GetWeightClass()
			If (WeightClass == 0)
				Int ArmorSkill = (Game.GetPlayer().GetAV("HeavyArmor")) as Int
				Float Unison
				Float Matching
				Float ArmorPerk
				If Game.Getplayer().HasPerk(WellFitted)
					Unison = 0.25
					Else
					Unison = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetHeavy)
					Matching = 0.25
					Else
					Matching = 0
				EndIf
				If Game.Getplayer().HasPerk(Juggernaut80)
					ArmorPerk = 1
					ElseIf (Game.Getplayer().HasPerk(Juggernaut60))
					ArmorPerk = 0.8
					ElseIf (Game.Getplayer().HasPerk(Juggernaut40))
					ArmorPerk = 0.6
					ElseIf (Game.Getplayer().HasPerk(Juggernaut20))
					ArmorPerk = 0.4
					ElseIf (Game.Getplayer().HasPerk(Juggernaut00))
					ArmorPerk = 0.2
					Else
					ArmorPerk = 0
				EndIf
				Int Bonus = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkill)*(1+Unison+Matching)*(1+ArmorPerk)) as Int
				Self.ModAV("UnarmedDamage", 0 - Bonus)
			ElseIf (WeightClass == 1)
				Int ArmorSkill = (Game.GetPlayer().GetAV("LightArmor")) as Int
				Float Unison
				Float Matching
				Float ArmorPerk
				If Game.Getplayer().HasPerk(CustomFit)
					Unison = 0.25
					Else
					Unison = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetLight)
					Matching = 0.25
					Else
					Matching = 0
				EndIf
				If Game.Getplayer().HasPerk(AgileDefender80)
					ArmorPerk = 1
					ElseIf (Game.Getplayer().HasPerk(AgileDefender60))
					ArmorPerk = 0.8
					ElseIf (Game.Getplayer().HasPerk(AgileDefender40))
					ArmorPerk = 0.6
					ElseIf (Game.Getplayer().HasPerk(AgileDefender20))
					ArmorPerk = 0.4
					ElseIf (Game.Getplayer().HasPerk(AgileDefender00))
					ArmorPerk = 0.2
					Else
					ArmorPerk = 0
				EndIf
				Int Bonus = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkill)*(1+Unison+Matching)*(1+ArmorPerk)) as Int
				Self.ModAV("UnarmedDamage", 0 - Bonus)
			EndIf
		EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

So I tried it out, and finally got it to remove the bonus upon unequipping gauntlets. (The problem was that I was asking it to calculate what Bonus to take off based on the armor class of the equipped gauntlets, which were obviously just UNequipped). I got around this with a new Int, BonusClass, and it works fine.

 

The only problem is that it doesn't like my maths. I got the formula from the UESP for Armor rating:

 

Armor rating = (base armor rating + item quality) × (1 + 0.4 × (skill + skill effect)/100) × (1 + unison perk† + Matching Set) × (1 + armor perk‡)

 

But when I try it out in-game, it only ever returns the same value. My code is below, I really can't see what is going wrong.

Scriptname PACFistsOfSteel extends Actor

Perk Property FistsOfSteel Auto
Perk Property WellFitted Auto
Perk Property MatchingSetHeavy Auto
Perk Property Juggernaut80 Auto
Perk Property Juggernaut60 Auto
Perk Property Juggernaut40 Auto
Perk Property Juggernaut20 Auto
Perk Property Juggernaut00 Auto
Perk Property CustomFit Auto
Perk Property MatchingSetLight Auto
Perk Property AgileDefender80 Auto
Perk Property AgileDefender60 Auto
Perk Property AgileDefender40 Auto
Perk Property AgileDefender20 Auto
Perk Property AgileDefender00 Auto

Int BonusHeavy
Int NegativeHeavy
Int BonusLight
Int NegativeLight
Int BonusClass

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		Armor Gauntlets = Game.GetPlayer().GetWornForm(0x00000008) as Armor
		If Game.GetPlayer().HasPerk(FistsOfSteel)
			Int WeightClass = Gauntlets.GetWeightClass()
			If (WeightClass == 0)
				Int ArmorSkillHeavy = (Game.GetPlayer().GetAV("HeavyArmor")) as Int
				BonusClass = 0
				Float UnisonHeavy
				Float MatchingHeavy
				Float ArmorPerkHeavy
				If Game.Getplayer().HasPerk(WellFitted)
					UnisonHeavy = 0.25
					Else
					UnisonHeavy = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetHeavy)
					MatchingHeavy = 0.25
					Else
					MatchingHeavy = 0
				EndIf
				If Game.Getplayer().HasPerk(Juggernaut80)
					ArmorPerkHeavy = 2
					ElseIf (Game.Getplayer().HasPerk(Juggernaut60))
					ArmorPerkHeavy = 1.8
					ElseIf (Game.Getplayer().HasPerk(Juggernaut40))
					ArmorPerkHeavy = 1.6
					ElseIf (Game.Getplayer().HasPerk(Juggernaut20))
					ArmorPerkHeavy = 1.4
					ElseIf (Game.Getplayer().HasPerk(Juggernaut00))
					ArmorPerkHeavy = 1.2
					Else
					ArmorPerkHeavy = 1
				EndIf
					BonusHeavy = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkillHeavy)*(1+UnisonHeavy+MatchingHeavy)*(ArmorPerkHeavy)) as Int
					NegativeHeavy = (0-BonusHeavy)
				Self.ModAV("UnarmedDamage", BonusHeavy)
			ElseIf (WeightClass == 1)
				Int ArmorSkillLight = (Game.GetPlayer().GetAV("LightArmor")) as Int
				BonusClass = 1
				Float UnisonLight
				Float MatchingLight
				Float ArmorPerkLight
				If Game.Getplayer().HasPerk(CustomFit)
					UnisonLight = 0.25
					Else
					UnisonLight = 0
				EndIf
				If Game.Getplayer().HasPerk(MatchingSetLight)
					MatchingLight = 0.25
					Else
					MatchingLight = 0
				EndIf
				If Game.Getplayer().HasPerk(AgileDefender80)
					ArmorPerkLight = 2
					ElseIf (Game.Getplayer().HasPerk(AgileDefender60))
					ArmorPerkLight = 1.8
					ElseIf (Game.Getplayer().HasPerk(AgileDefender40))
					ArmorPerkLight = 1.6
					ElseIf (Game.Getplayer().HasPerk(AgileDefender20))
					ArmorPerkLight = 1.4
					ElseIf (Game.Getplayer().HasPerk(AgileDefender00))
					ArmorPerkLight = 1.2
					Else
					ArmorPerkLight = 1
				EndIf
					BonusLight = (Gauntlets.GetArmorRating()*(1+0.004*ArmorSkillLight)*(1+UnisonLight+MatchingLight)*(ArmorPerkLight)) as Int
					NegativeLight = (0-BonusLight)
				Self.ModAV("UnarmedDamage", BonusLight)
			EndIf
		EndIf
	EndIf
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		If (BonusClass == 0)
			Self.ModAV("UnarmedDamage", NegativeHeavy)
		ElseIf (BonusClass == 1)
			Self.ModAV("UnarmedDamage", NegativeLight)
		EndIf
	EndIf
EndEvent
Link to comment
Share on other sites

You display the values in a message you print to the screen.

 

The Show command is one way to do it.

 

For example, show these values before your command that does the calculations.

1. Gauntlets.GetArmorRating()

2. ArmorSkillLight

3. UnisonLight

4. MatchingLight

5. ArmorPerkLight

6. NegativeLight

7. BonusLight

Link to comment
Share on other sites

I tried spacing, but it didn't help.  Spacing in Papyrus doesn't matter except in special cases? Anyway, I tried cutting down my script to help me see where the error is (I have the full copy as a back-up), and for some reason it flat-out refuses to multiply my values.

 

ArmorSkillHeavyBonus calculates correctly as 1.44444 when at 100 Heavy Armor, and GauntletsArmorRatingHeavy returns 18, so why does it only give 19 when I ask them to multiply? It should be at 26.

 

EDIT: All variables are defined outside the Event to make it easier to read. BonusHeavy is a Float.

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		Armor Gauntlets = Game.GetPlayer().GetWornForm(0x00000008) as Armor
		If Game.GetPlayer().HasPerk(FistsOfSteel)
			Int WeightClass = Gauntlets.GetWeightClass()
			If (WeightClass == 0)
				BonusClass = 0
				ArmorSkillHeavy = (Game.GetPlayer().GetAV("HeavyArmor")) as Int
				PercentArmorSkillHeavy = (ArmorSkillHeavy * 0.00444444444) as Float
				ArmorSkillHeavyBonus = (PercentArmorSkillHeavy + 1) as Float
				GauntletsArmorRatingHeavy = Gauntlets.GetArmorRating() as Float
					BonusHeavy = (GauntletsArmorRatingHeavy * ArmorSkillHeavyBonus)
					NegativeHeavy = (0-BonusHeavy)
				Self.ModAV("UnarmedDamage", BonusHeavy)
			EndIf
		EndIf
	EndIf
EndEvent

Event OnObjectUnequipped(Form akBaseObject, ObjectReference akReference)
	If (akBaseObject as Armor).GetSlotMask()==8
		If (BonusClass == 0)
			Self.ModAV("UnarmedDamage", NegativeHeavy)
		EndIf
	EndIf
EndEvent
Edited by Pacmasian
Link to comment
Share on other sites

The variables are defined underneath my Properties:

 

Float PercentArmorSkillHeavy

Float ArmorSkillHeavyBonus

 

It returns no errors when compiling at all, it just gives me 19 in-game.

I had Debug.MessageBox lines in there to check up on the values, and removed them after to keep it clean.

Link to comment
Share on other sites

Well, computers do not just come up with random numbers. So there is a value in your calculation that is not what you think it should be.

 

I would recommend leaving the debug messages in, and comment them if you don't want to see them. I would actually never take them out and that comes from a professional programmer. That way, if you ever need to see the values, you can uncomment them and your good for testing.

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