Author Topic: Problem With Recharging Staves  (Read 1199 times)

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #30 on: January 08, 2013, 10:59:16 am »


               

Lightfoot8 wrote...

if (~GetItemCharges(oStaff) & 1 ) SetItemCharges(oStaff,GetItemCharges(oStaff)+1); will stop the staff from losing all charges and keep him from having to go through the process of delayed iProp removal and re addition to get the staff to have charges again. 

It does hinge on the assumption that the staff started with more then three charges though.   If the Item started with only 2 or three charges the SetIsDestroyable(FALSE));   would not happen in time to save the staff.   If I was 100%  on him using TBS I would have added the OnAquite  section to the script fragment.    But with out him posting his script or *cough*  asking for more information, I just posted the fast solution.   Since the staff is starting with (assumption) more then three charges.  


Thanks guys 'Posted

First of all, just to clear things up, I am a girl, so that would be her scripts.

Here are a couple of the scripts I made, with the earlier fix added to them. The staves and lute all start with 49 charges, and set at 2 charges per use.

Staff of Elements:


// Staff of Elements Script
#include "x2_inc_switches"
void main()
{
if(GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE)
{
    int nType;
    object oEventItem = GetItemActivated();
    object oActTarget = GetItemActivatedTarget();
    location lActTarget = GetItemActivatedTargetLocation();
    object oActivator = GetItemActivator();
    object oPC = oActivator;
    if (~GetItemCharges(oEventItem) & 1 ) SetItemCharges(oEventItem,GetItemCharges(oEventItem)+1);
    AssignCommand(oEventItem,SetIsDestroyable(FALSE));
    // The target must be a certain type of object.
    nType = GetObjectType(oActTarget);
    if ( nType != OBJECT_TYPE_CREATURE )
    {
        SendMessageToPC(oActivator, "Target must be a creature!");
        return;
    }
    // If the PC has more than 39 levels of wizard.
    if ( GetLevelByclass(class_TYPE_WIZARD, oPC) > 39 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 39 levels of sorcerer.
    else if ( GetLevelByclass(class_TYPE_SORCERER, oPC) > 39 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 39 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 39 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(2.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(3.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
 
    // Else if the PC has more than 29 levels of wizard.
    else if ( GetLevelByclass(class_TYPE_WIZARD, oPC) > 29 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 29 levels of sorcerer.
    else if ( GetLevelByclass(class_TYPE_SORCERER, oPC) > 29 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 29 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 29 )
    {
        // Have the item activator cast Bolt, Elements.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.00, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(1.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else if the PC has more than 19 levels of wizard.
    else if ( GetLevelByclass(class_TYPE_WIZARD, oPC) > 19 )
    {
        // Have the item activator cast Bolt, Shards.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 19 levels of sorcerer.
    else if ( GetLevelByclass(class_TYPE_SORCERER, oPC) > 19 )
    {
        // Have the item activator cast Bolt, Shards.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    // Else, if the PC has more than 19 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 19 )
    {
        // Have the item activator cast Bolt, Shards.
        AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_FIRE, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE));
        DelayCommand(0.20, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_COLD, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.40, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_ACID, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.60, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_LIGHTNING, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
        DelayCommand(0.80, AssignCommand(oActivator, ActionCastSpellAtObject(SPELLABILITY_BOLT_SHARDS, oActTarget, METAMAGIC_ANY, TRUE, 0, PROJECTILE_PATH_TYPE_DEFAULT, TRUE)));
    }
    else
    {
        // Send a message to the player's chat window.
        SendMessageToPC(oPC, "You do not have the required class level to use this item.");
    }
}
}

The Lute of Happiness:

// Lute of Happiness
#include "x2_inc_switches"
void main()
{
if(GetUserDefinedItemEventNumber() == X2_ITEM_EVENT_ACTIVATE)
{
effect eVFX;
effect eEffect;
effect eDamage;
int nType;
object oEventItem = GetItemActivated();
object oActTarget = GetItemActivatedTarget();
location lActTarget = GetItemActivatedTargetLocation();
object oActivator = GetItemActivator();
object oPC = oActivator;
  if (~GetItemCharges(oEventItem) & 1 ) SetItemCharges(oEventItem,GetItemCharges(oEventItem)+1);
  AssignCommand(oEventItem,SetIsDestroyable(FALSE));
  // If the PC targets an object.
  if ( GetIsObjectValid(oActTarget) )
  {
    // The target must be a certain type of object.
    nType = GetObjectType(oActTarget);
    if ( nType != OBJECT_TYPE_CREATURE )
    {
        SendMessageToPC(oActivator, "Target must be a creature.");
        return;
    }
    // If the PC has more than 39 levels of bard.
    if ( GetLevelByclass(class_TYPE_BARD, oPC) > 39 )
    {
        // Cause damage.
        eDamage = EffectDamage(d100(10), DAMAGE_TYPE_SONIC);
        eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oActTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oActTarget);
    }
    // Else, if the PC has more than 34 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 34 )
    {
        // Cause damage.
        eDamage = EffectDamage(d100(8), DAMAGE_TYPE_SONIC);
        eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oActTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oActTarget);
    }
    // Else, if the PC has more than 29 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 29 )
    {
        // Cause damage.
        eDamage = EffectDamage(d100(6), DAMAGE_TYPE_SONIC);
        eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oActTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oActTarget);
    }
    // Else, if the PC has more than 24 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 24 )
    {
        // Cause damage.
        eDamage = EffectDamage(d100(5), DAMAGE_TYPE_SONIC);
        eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oActTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oActTarget);
    }
    // Else, if the PC has more than 19 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 19 )
    {
        // Cause damage.
        eDamage = EffectDamage(d100(4), DAMAGE_TYPE_SONIC);
        eVFX = EffectVisualEffect(VFX_FNF_SOUND_BURST);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oActTarget);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX   , oActTarget);
    }
    else
    {
        // Have the item activator say something.
        AssignCommand(oActivator, SpeakString("You do not have the required bard level."));
    }
  }
  // If the PC targets a location. An epic bard song occurs for all party members.
  else
  {
    // If the PC has more than 39 levels of bard.
    if ( GetLevelByclass(class_TYPE_BARD, oPC) > 39 )
    {
        object oParty = GetFirstFactionMember(oPC);
        while(GetIsObjectValid(oParty))
      {
        if(GetArea(oPC)==GetArea(oParty))
      {
        // Apply some effects.
        eEffect = ExtraordinaryEffect(EffectAttackIncrease(5));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectACIncrease(5, AC_DODGE_BONUS));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectConcealment(50));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectDamageReduction(15, DAMAGE_POWER_PLUS_TWENTY));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectDamageShield(20, DAMAGE_BONUS_2d12, DAMAGE_TYPE_SONIC));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectImmunity(IMMUNITY_TYPE_SNEAK_ATTACK));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectSpellResistanceIncrease(50));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectTemporaryHitpoints(500));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        // Apply a visual effect.
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_BARD_SONG));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oActivator, 300.0);
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_PROT_PREMONITION));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oParty, 300.0);
      }
        oParty = GetNextFactionMember(oPC);
      }
    }
    // Else, if the PC has more than 29 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 29 )
    {
        object oParty = GetFirstFactionMember(oPC);
        while(GetIsObjectValid(oParty))
      {
        if(GetArea(oPC)==GetArea(oParty))
      {
        // Apply some effects.
        eEffect = ExtraordinaryEffect(EffectACIncrease(5, AC_DODGE_BONUS));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectConcealment(50));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectDamageReduction(10, DAMAGE_POWER_PLUS_SIXTEEN));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectDamageShield(10, DAMAGE_BONUS_1d10, DAMAGE_TYPE_SONIC));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectSpellResistanceIncrease(45));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        // Apply a visual effect.
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_BARD_SONG));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oActivator, 300.0);
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_PROT_PREMONITION));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oParty, 300.0);
      }
        oParty = GetNextFactionMember(oPC);
      }
    }
    // Else, if the PC has more than 19 levels of bard.
    else if ( GetLevelByclass(class_TYPE_BARD, oPC) > 19 )
    {
        object oParty = GetFirstFactionMember(oPC);
        while(GetIsObjectValid(oParty))
      {
        if(GetArea(oPC)==GetArea(oParty))
      {
        // Apply some effects.
        eEffect = ExtraordinaryEffect(EffectACIncrease(5, AC_DODGE_BONUS));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectConcealment(50));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        eEffect = ExtraordinaryEffect(EffectSpellResistanceIncrease(40));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eEffect, oParty, 300.0);
        // Apply a visual effect.
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_BARD_SONG));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oActivator, 300.0);
        eVFX = ExtraordinaryEffect(EffectVisualEffect(VFX_DUR_PROT_PREMONITION));
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVFX, oParty, 300.0);
      }
        oParty = GetNextFactionMember(oPC);
      }
    }
    else
    {
        // Have the item activator say something.
        AssignCommand(oActivator, SpeakString("You do not have the required bard level."));
    }
  }
}
}
               
               

               


                     Modifié par Sadira of Tyr, 08 janvier 2013 - 11:05 .
                     
                  


            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #31 on: January 08, 2013, 05:59:52 pm »


               

Sadira of Tyr wrote...

Thanks guys 'Posted

First of all, just to clear things up, I am a girl, so that would be her scripts.

Here are a couple of the scripts I made, with the earlier fix added to them. The staves and lute all start with 49 charges, and set at 2 charges per use.


I think you missed a bit from the discussion.  Let's go over a few points

1) The plot flag prevents destruction, but prevents selling and other uses including part modification
2) The destroyable flag prevents destruction, but can cause bugs and unexpected replication especially with part modification.
3) An odd number of charges is meaningless.  On an item's last use the GUI selection is disabled (until the rest after charge replenishment) even if the remaining charges are 1 (when this occurs the item is also scheduled to be destroyed unless it is protected).  If you want at least one charge maintained, you can set the charges to one in the script that fires when they reach zero.
4) 0 charge per use or unlimited uses per day can guarantee that the item will not be destroyed if they are listed after the charge consuming properties on the item.
               
               

               


                     Modifié par WhiZard, 08 janvier 2013 - 06:01 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #32 on: January 09, 2013, 12:38:12 am »


               

WhiZard wrote...

I think you missed a bit from the discussion.  Let's go over a few points

1) The plot flag prevents destruction, but prevents selling and other uses including part modification
2) The destroyable flag prevents destruction, but can cause bugs and unexpected replication especially with part modification.
3) An odd number of charges is meaningless.  On an item's last use the GUI selection is disabled (until the rest after charge replenishment) even if the remaining charges are 1 (when this occurs the item is also scheduled to be destroyed unless it is protected).  If you want at least one charge maintained, you can set the charges to one in the script that fires when they reach zero.
4) 0 charge per use or unlimited uses per day can guarantee that the item will not be destroyed if they are listed after the charge consuming properties on the item.


I wanted the staves to be craftable, so setting them to plot is not what I wanted. I see what you mean about the destroyable flag, since crafting destroys the object and creates a new one. That would create a whole lot of extras staves to sell. I knew what you meant before I posted the scripts, but I had not had time to remove the line with the SetIsDestroyable.

From what I noticed about cast spell properties, they are listed in alphabetical order, so the order in which you add the properties would not make a difference. All of the staves and lute use cast spell: activate item long range, which will come before the 0 charges light spell property.

So to fix my scripts, I should just remove the line with the SetIsDestroyable. The line before it will keep the staves with an odd number of charges, and the light spell at 0 charges should keep them from being destroyed. I had tested them like this, before adding the SetIsDestroyable, and they did not get destroyed, but I did have to rest to have the charges restored. So I guess there really were no unresolved issues.

Thank you though, for letting me know how the rules work for items with charges getting destroyed. I did make one wand with a similiar script, which I could not add any 0 charges spells to it. I guess I could leave the SetIsDestroyable on that, since wands cannot be crafted anyways.
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #33 on: January 09, 2013, 04:11:16 am »


               

Sadira of Tyr wrote...
From what I noticed about cast spell properties, they are listed in alphabetical order, so the order in which you add the properties would not make a difference. All of the staves and lute use cast spell: activate item long range, which will come before the 0 charges light spell property.


Looks that way, I remember once reversing the order but can't figure out how I did that.

Okay, adding by script positions the new cast spell at the top, so copying the properties and transfering them to a new item should reverse the order.
               
               

               


                     Modifié par WhiZard, 09 janvier 2013 - 04:29 .
                     
                  


            

Legacy_Sadira of Tyr

  • Sr. Member
  • ****
  • Posts: 299
  • Karma: +0/-0
Problem With Recharging Staves
« Reply #34 on: January 09, 2013, 11:08:26 am »


               Well, I have fixed the scripts, by just removing the SetIsDestroyable line. I left the cast spell properties as they are, in alphabetical order. I tested one of the staves, and it did not get destroyed when it went down to one charge. I was also able to craft it without any problems. I guess this means I can consider the staves fixed, and move on to something else.

Thank you for helping me. 'Posted