Author Topic: Weapon Charges  (Read 326 times)

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Weapon Charges
« on: September 03, 2011, 08:29:37 pm »


               So, I made a weapon that has 5 charges, with 2 charges per use for a unique spell it casts, but unless i make it a plot it keeps disappearing when it hits 1 charge left. Also, it gets rechaged with 2 charges (1 more effective use) every time a certain enemy is killed. However, although the charge amount in the description changes the amount of uses will not => Maybe because it is a plot, or maybe because I used the item until it had 1 charge left (zero uses) then recharged it and it didn't work.
Please help me with this!



Here's the script for the unique power self only:


#include "x2_inc_switches"
void main()
{
object oPC = GetItemActivator();
int nEvent = GetUserDefinedItemEventNumber();
switch (nEvent)
   {
   case X2_ITEM_EVENT_ACTIVATE:
{
    location lCenter = GetLocation(oPC);
    object oDagger = GetItemActivated();
    effect eTimeStopVFX = EffectVisualEffect(VFX_FNF_TIME_STOP);
    effect eGlobe = EffectVisualEffect(VFX_DUR_GLOBE_INVULNERABILITY);
    effect eParalyze = EffectCutsceneParalyze();
    effect eImmobilize = EffectCutsceneImmobilize();
       eParalyze = SupernaturalEffect(eParalyze);
       eImmobilize = SupernaturalEffect(eImmobilize);
    ApplyEffectToObject(DURATION_TYPE_INSTANT, eTimeStopVFX, oPC);
    object oTarget = GetFirstObjectInShape(SHAPE_SPHERE, 10.0f, lCenter, OBJECT_TYPE_CREATURE);
    while(GetIsObjectValid(oTarget))
     {
      if (oTarget == oPC)
        {
        // do nothing
        }
      else
        {
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eParalyze, oTarget, 12.0);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eImmobilize, oTarget, 12.0);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eGlobe, oTarget, 12.0);
        ApplyEffectToObject(DURATION_TYPE_TEMPORARY, EffectVisualEffect(VFX_DUR_FREEZE_ANIMATION), oTarget, 12.0);
        }
        oTarget = GetNextObjectInShape(SHAPE_SPHERE, 10.0f, lCenter, OBJECT_TYPE_CREATURE);
     }
}
                   break;
   case X2_ITEM_EVENT_EQUIP:
ExecuteScript("eq_"+GetTag(GetPCItemLastEquipped()), OBJECT_SELF); break;
   case X2_ITEM_EVENT_UNEQUIP:
ExecuteScript("ue_"+GetTag(GetPCItemLastUnequipped()), OBJECT_SELF); break;
   case X2_ITEM_EVENT_ACQUIRE:
ExecuteScript("aq_"+GetTag(GetModuleItemAcquired()), OBJECT_SELF); break;
   case X2_ITEM_EVENT_UNACQUIRE:
ExecuteScript("ua_"+GetTag(GetModuleItemLost()), OBJECT_SELF); break;
   case X2_ITEM_EVENT_SPELLCAST_AT:
ExecuteScript("sp_"+GetTag(GetModuleItemLost()), OBJECT_SELF); break;
   case X2_ITEM_EVENT_ONHITCAST:
ExecuteScript("on_"+GetTag(GetModuleItemLost()), OBJECT_SELF); break;
   }
}


and here is the ondeath script of the dudes getting killed

void main()
{
object oPC = GetLastKiller();
 object oWeaponRight = GetItemInSlot(INVENTORY_SLOT_RIGHTHAND, oPC);
 object oWeaponLeft = GetItemInSlot(INVENTORY_SLOT_LEFTHAND, oPC);
 int nDaggerChargeRight = GetItemCharges(oWeaponRight);
 int nDaggerChargeLeft  = GetItemCharges(oWeaponLeft);
if (GetTag(oWeaponRight) == "daggeroftime")
 {
  if (nDaggerChargeRight < 5)
   {
    SetItemCharges(oWeaponRight, nDaggerChargeRight+2);
   }
 }
else if (GetTag(oWeaponLeft) == "daggeroftime")
 {
  if (nDaggerChargeLeft < 5)
   {
    SetItemCharges(oWeaponLeft, nDaggerChargeLeft+2);
   }
 }
}Thanks again, DITB

[P.S.- For those of you who noticed it in the scripts, yes, this is the 'Dagger of Time' from the prince of persia games 'Posted]
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Weapon Charges
« Reply #1 on: September 03, 2011, 09:01:53 pm »


               Thats the way how its work. Possibilities are:
- set odd charges count and set each use to consume 2 charges
- increase charge if remaining charges are 1 and next time it happens set weapon plot and decrease charges to 0
               
               

               
            

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Weapon Charges
« Reply #2 on: September 03, 2011, 09:10:36 pm »


               Thanks for the pointers:
-That's what I did, the lowest charge amount it ever has is 1, since it starts at an odd amount (5) and uses an even amount (2).
-I'm not sure what you mean by the second point
               
               

               
            

Legacy_DITB123

  • Newbie
  • *
  • Posts: 18
  • Karma: +0/-0
Weapon Charges
« Reply #3 on: September 03, 2011, 09:11:39 pm »


               Thanks for the pointers:
-That's what I did, the lowest charge amount it ever has is 1, since it starts at an odd amount (5) and uses an even amount (2).
-I'm not sure what you mean by te second point
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
Weapon Charges
« Reply #4 on: September 03, 2011, 10:42:58 pm »


               

DITB123 wrote...

So, I made a weapon that has 5 charges, with 2 charges per use for a unique spell it casts, but unless i make it a plot it keeps disappearing when it hits 1 charge left. Also, it gets rechaged with 2 charges (1 more effective use) every time a certain enemy is killed. However, although the charge amount in the description changes the amount of uses will not => Maybe because it is a plot, or maybe because I used the item until it had 1 charge left (zero uses) then recharged it and it didn't work.
Please help me with this!


You can add another item cast spell property with 0 charges per use (like cure minor wounds) and this would fix the item disappearing part.

The inability to use added charges can be solved by resting.