Jump to content

Script to tell if the player is wearing any armor


Recommended Posts

I think I managed to do what I wanted, but I've yet to test it. Here's the script:

scn 01DraconianScales

begin gamemode
	
	if Player.GetRace == Draconian
		Player.AddSpell AbRaceDraconianShield
	endif

	if Player.GetArmorType == 0
		Player.RemoveSpell AbRaceDraconianShield
	endif

	if Player.GetArmortype == 1
		Player.RemoveSpell AbRaceDraconianShield
	endif
end
Edited by lordbevan1
Link to comment
Share on other sites

 

I think I managed to do what I wanted, but I've yet to test it. Here's the script:

scn 01DraconianScales

begin gamemode
	
	if Player.GetRace == Draconian
		Player.AddSpell AbRaceDraconianShield
	endif

	if Player.GetArmorType == 0
		Player.RemoveSpell AbRaceDraconianShield
	endif

	if Player.GetArmortype == 1
		Player.RemoveSpell AbRaceDraconianShield
	endif
end

Glad for you if it works but always start your editor ID's and script names with letters, otherwise your game will be unstable.

Link to comment
Share on other sites

GetArmorType cannot be called on an actor. It needs to be called on a wearable item, preferably an armor, to work.

 

I for one would likely use GetArmorRating rather than running a loop through all items the actor wears via GetEquippedItems and check their armor type then sum it up. But depending on the actual intention the latter might as well be the only feasible way.

Link to comment
Share on other sites

  • 3 weeks later...

Does wearing a shield or not make a problem? Because GetArmorRating sounds like the perfect tool for the job, "but" it will also return a value > 0 when wearing only a shield and a 1-hand weapon.

 

Otherwise, yes, looping through all GetEquippedItems and checking the armor type of each via GetArmorType, provided it's not a weapon or similar, would be the other option. At the end of the loop you'll know if you wear any armor or not, and shields can be excluded.

 

I can provide an example script for the loop, too, if you need it.

Link to comment
Share on other sites

Yes, I know. Sorry, if I expressed myself poorly.

 

I was asking whether in detecting if you're wearing armor holding a shield should count as wearing armor or not, too, because that's how the most simple solution, the GetArmorRating function works. It returns values > 0 when you're not wearing any armor but holding a shield and have your 1-hand weapon out. If that's no problem in your detection and the shield spell should only apply while not wearing any armor "or" shield, then go for GetArmorRating first. It will return "0" when neither is the case, and your shield spell can apply.

Link to comment
Share on other sites

  • 4 weeks later...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...