Jump to content

Help with scripting an armor piece


Ezarr

Recommended Posts

Posted

I want to make an armor piece to auto equip when the the wielder's health goes down to a certain value or lower, and to unequip if it goes higher that same value.

 

I dont know if I can get this done just by using the conditions already available in CK. My guess is that it will have to be done by a script (which I dont have much experience with).

 

Any help/tips to accomplish this is very appreciated.

Posted

Probably doable via a spell but depends on how 'time-sensitive' this equipping of armor should be. Built in conditions are 'cheap' but not fast in my experience. They can be fast-ish. They can also be fairly slow. Depends on the current load I think. 

 

At a high level. 

1. Create a constant effect spell. Add it to the player. Set conditions on the spell to 'GetActorValue <= x'. You can use a global variable here to make the threshold health configurable if you wish. 

2. Attach a script to the magic effect. 

 

Event OnEffectStart(Actor akTarget, Actor akCaster)

     PlayerRef.AddItem(SpecialArmor)

     PlayerRef.EquipItem(SpecialArmor)

EndEvent

 

Event OnEffectFinish(Actor akTarget, Actor akCaster)

     PlayerRef.UnEquipItem(SpecialArmor)

     PlayerRef.RemoveItem(SpecialArmor)

EndEvent

 

Actor Property PlayerRef Auto

 

Armor Property SpecialArmor Auto

 

The faster detection method would probably have to be constantly running script checks on health which is fairly undesirable really. 

Posted

Add a perk to the actor that adds a spell with two magic effects under two conditions using GetHealthPercentage.

Add an script for their OnEffectStart event to equip or unequip the armor passed to them via a property.

 

(Spell) Subject.GetHealthPercentage < 0.5 (less than half health)

(Magic Effect) Subject.GetEquipped(MyArmor) == 0

Event OnEffectStart(Actor akTarget, Actor akCaster)
    akTarget.EquipItemEx(MyArmor, preventUnequip = true, equipSound = false)
EndEvent

(Spell) Subject.GetHealthPercentage >= 0.5 (greater than or equal half health)

(Magic Effect) Subject.GetEquipped(MyArmor) == 1

Event OnEffectStart(Actor akTarget, Actor akCaster)
     akTarget.UnequipItemEx(MyArmor, preventEquip = true)
EndEvent

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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