Jump to content

gba25

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by gba25

  1. Hello,

     

    I am trying to create spell which conjures armor and equips it to the player. I created magic effect with the following script:

    Scriptname conjureArmorScript extends ActiveMagicEffect  
    
    Armor Property bodyarmor Auto
    Armor Property gauntlets Auto
    Armor Property boots Auto
    Armor Property helmet Auto
    Armor[] Property oldArmor  Auto  
    
    Event OnEffectStart(Actor akTarget, Actor akCaster)
        Actor player = akCaster
        ;saving old armor for equipping after effect is finished;
        oldArmor[0] = player.GetWornForm(0x00000004) as Armor 
        oldArmor[1] = player.GetWornForm(0x00000008) as Armor
        oldArmor[2] = player.GetWornForm(0x00000080) as Armor
        oldArmor[3] = player.GetWornForm(0x00000001) as Armor
    
        ;adding new armor;
        player.Additem(bodyarmor,1)
        player.Additem(gauntlets,1)
        player.Additem(boots,1)
        player.Additem(helmet,1)
        
        ;equip new armor;
        player.EquipItem(bodyarmor,false,true)
        player.EquipItem(gauntlets,false,true)
        player.EquipItem(boots,false,true)
        player.EquipItem(helmet,false,true)
    EndEvent
    
    Event OnEffectFinish(Actor akTarget, Actor akCaster)
        Actor player = akCaster
        
        ;checking old armor and equipping:
        int i = 0
        while i<4
            Armor tmp = oldArmor[i]
            if tmp != None
                player.EquipItem(tmp,false,true)
            endif
        endwhile
        
        ;remove new armor from inventory, this part doesn't work, items still stay in the inventiry;
        player.RemoveItem(bodyarmor,1)
        player.RemoveItem(gauntlets,1)
        player.RemoveItem(boots,1)
        player.RemoveItem(helmet,1)
    EndEvent
    
    
    

    Magic effect is attached to lesser power. When I activate this power it behaves very strangely. First new armor is equipped but after power expires new armor isn't removed from the inventory.

    Can someone tell me what I am doing wrong and how to fix it?

×
×
  • Create New...