Jump to content

Script to tell if the player is wearing any armor


Recommended Posts

Well, that took me quite some time to come back to here again... Let's see if I can whip something up.

 

array_var arItems
array_var arIterator
short bWearsArmor
ref rItem
 
Begin GameMode ;could also be one of the spell script block types
    ...
    let arItems := player.GetEquippedItems ;could also be some other reference than player
    let bWearsArmor := 0
    ForEach arIterator <- arItems
        let rItem := arIterator["value"]
        If rItem.IsArmor
            let bWearsArmor := 1
            Break
        EndIf
    Loop
    let arItems := ar_Null ;clean up, necessary?
    ;here bWearsArmor is either 1 or 0
    ...
End

Turns out my initial suggestion GetArmorType wasn't exactly the best choice for this (returning either 0 or 1 but both meaning it is an armor, thus only working on armors to begin with). IsArmor seems to be a much better fit here.

 

That should tell you if you wear any armor "and" exclude shields. Or so I hope. Else it'd just need a check for rItem being a shield combined with a Continue to just ignore it and go on.

 

Now, I don't know why your spells sometimes won't cast, but I also don't know your current script. I assume it's inside your recently released plugin? If so, I can grab it and take a look as soon as my free time allows for it again.

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 year later...

Is it still like the first script you posted, all at once within the same game mode frame? If it's a Draconian, the spell gets added, if it's wearing armor, the spell gets removed?
I'm not sure how exactly the game works in this regard, but it's pretty likely this way will just cause the spell to constantly appear and disappear, perhaps even unnoticeably fast.

Some do once conditions or states could help, or maybe even a re-structuring, like:

...
let bIsDraconian := 0
If Player.GetRace == Draconian
    let bIsDraconian := 1
EndIf
...
let bHasSpell := 0
If Player.HasSpell AbRaceDraconianShield
    let bHasSpell := 1
EndIf
...
; use fancy loop code from above to set bWearsArmor
...
If bIsDraconian == 1 && bHasSpell == 0 && bWearsArmor == 0
    Player.AddSpell AbRaceDraconianShield
Else
    Player.RemoveSpell AbRaceDraconianShield
EndIf
...

That's a lot more code than necessary, but I think you'll easier see what I'm aiming at with 3 boolean variables and 1 setting code each.

Link to comment
Share on other sites

  • 2 weeks later...

Ok I think I get what your wanting. How about a Magic script that sets a ref and a variable for each equipment slot

 

Then set them each using the getequippedobject function in the Begin ScriptEffectStart Block

 

In the Begin ScriptEffectUpdate Block use the isarmor on each ref to set the Variables to allow a toggle for the OnScriptEffectFinish Block Set up a timer for the spell and have it dispel at a set time

Edited by CountryRoberts
Link to comment
Share on other sites

  • Recently Browsing   0 members

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