Jump to content

Maintained Ability Equipping Item


Recommended Posts

Can anyone show me what the script for a modal/maintained ability would look like that would add and equip a special shield when you activate it, and remove the shield when you deactivate it?

If possible, I'd also like to prevent the player from being able to unequip the item themselves.

 

Thank you for any help. I won't be able to release the mod I'm working on until I can get this to work.

Link to comment
Share on other sites

Okay, I think I can add the line that removes the item to the end of the entire script that runs when you deactivate the spell.

The problem is I still don't know what the lines that add, equip and remove the item would look like. The examples I've found seem not to work in the format required for a spell.

 

---Edit---

I got the script to accept now by using this:

object oShield = UT_AddItemToInventory(R"aw_hand_arcanearts.uti");

EquipItem(stEvent.oCaster, oShield);

 

But it doesn't work in-game. The item doesn't get added. I'm certain the name is right.

Here's the whole section:

 

case ABILITY_SPELL_COMBAT_MAGIC:
       {
           eEffects[0] = EffectModifyProperty(PROPERTY_ATTRIBUTE_ATTACK, COMBAT_MAGIC_ATTACK_BONUS + MaxF(GetCreatureSpellPower(stEvent.oCaster)/5.0,0.0) );
           eEffects[0] = SetEffectEngineInteger(eEffects[0], EFFECT_INTEGER_VFX, Ability_GetImpactObjectVfxId(stEvent.nAbility));
           object oShield = UT_AddItemToInventory(R"aw_hand_arcanearts.uti");
           EquipItem(stEvent.oCaster, oShield);            

           // aura of might bonus
           if (HasAbility(stEvent.oCaster, ABILITY_SPELL_AURA_OF_MIGHT) == TRUE)
           {
               float fPower = MaxF(1.0,MinF((GetCreatureSpellPower(stEvent.oCaster) / 7.5f), 10.0f));
               eEffects[0] = EffectEnchantment(10022, FloatToInt(fPower));
               eEffects[1] = EffectModifyProperty(PROPERTY_ATTRIBUTE_ATTACK_SPEED_MODIFIER, -0.15f);
//                eEffects[2] = SetEffectEngineInteger(eEffects[2], EFFECT_INTEGER_VFX, Ability_GetImpactObjectVfxId(ABILITY_SPELL_AURA_OF_MIGHT));
           }

           break;

 

---Edit---

Item export issue... it works now...

I've got more problems though. First, I need to prevent the player from being able to unequip the item, and second, it gives an "item added" message I'd like to avoid.

Link to comment
Share on other sites

Use CreateItemOnObject with bSuppressNotification set to TRUE to avoid the item added message.

 

To prevent the player from unequipping the item, you would probably want to setup an event listener for EVENT_TYPE_UNEQUIP that always re-equips the item.

Awesome, thanks. I looked at the link you provided for suppressing the message, and it turns out the additemtoinventory function I'm already using can use the same flag: link.

The problem is it doesn't give an example of what the line should actually look like. Where and how do I specify the flag?

 

Also, I can try your suggestion on re-equipping the item, but I think there's an easier way. I've read about existing items in the game that cannot be unequipped, such as the "Soldier's Armor" which is part of some quest. The problem is I can't figure out how it's done. It's not a setting on the item, and it's not a script attached directly to the item.

I think it might be something that's done when the item is initially added through script? Or maybe they do what you suggested :tongue:

---Edit---

Aha, I think it may be the bDroppable flag. I'm still having the problem with not know how the line needs to look though. Here's what it currently looks like:

EquipItem(stEvent.oCaster, UT_AddItemToInventory(R"aw_hand_arcanearts.uti"));

 

 

Oh, and for anyone that wants to know how I got the item to unequip after the spell is deactivated, I went to the end of the script where it says "// Remove Effects" and added this section:

if (nAbility == ABILITY_SPELL_COMBAT_MAGIC)

{

UT_RemoveItemFromInventory(R"aw_hand_arcanearts.uti");

}

 

---Edit---

I was given this code by a poster on the official forums:

object oItem = UT_AddItemToInventory(R"aw_hand_arcanearts.uti", 1, OBJECT_INVALID, "", TRUE, FALSE);

EquipItem(stEvent.oCaster, oItem);

 

But for some reason the item can still be unequipped or destroyed even though it is very clearly set to be undroppable.

 

---Edit---

It seems bDroppable determines whether an NPC will drop that item for use after death or not.

It was suggested that I use SetItemIndestructible to make it undroppable, but it can still be unequipped.

I've found out about this armor in the game though called "Guard Uniform"/Disguise, which lists two effects, "Indestructible" and "Cannot be unequipped".

I need to do the same thing that was done with that, but I can't find it in the toolset.

 

---Edit---

Found it! Finally!

use SetItemIndestructible to make the player unable to drop the item, and SetItemIrremovable to prevent the player from unequipping it.

 

Here's my final code for equipping the item:

            object oItem = UT_AddItemToInventory(R"aw_hand_arcanearts.uti", 1, OBJECT_INVALID, "", TRUE, FALSE);
           SetItemIndestructible(oItem, TRUE);
           SetItemIrremovable(oItem, TRUE);
           EquipItem(stEvent.oCaster, oItem);

Link to comment
Share on other sites

  • Recently Browsing   0 members

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