Author Topic: Cool DM Potions...  (Read 467 times)

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Cool DM Potions...
« on: February 08, 2014, 10:48:53 am »


               Basically you create this script in your module, save it under whatever name you want (remember the name!), then create potions (1 for each type of spell), and give them a cool name (like Potion of Infinite Heals), then of course change the tagname of the potion to the name you saved this script under...  This will give you potoins that never run out...  (Infinite Uses)

Obviously this is for DMs Only...   ':wizard:'


//  gen_potion   (Tagbased Scripted Item!)
////////////////////////////////////////////////////////////////////////////////
// Created by:   Genisys / Guile
// Created on:   2/08/2014
///////////////////////////////////////////////////////////////////////////////
/*
  Essentially this tagbased item script is very powerful!
  It was designed for DMs Only!!!
  Basically you create a potion, give it the tagname "gen_potion"
  When the PC / DM acquires the item, the potion is set to Infinite Uses!
*/
///////////////////////////////////////////////////////////////////////////////
//Required Include (DO NOT TOUCH!)
#include "x2_inc_switches"
#include "x2_inc_itemprop"
////////////////////////////////////////////////////////////////////////////////

// Returns the FIRST Item Property only!
itemproperty GetFirstProp(object oItem);

// -----------------------------------------------------------------------------
// oItem was acquired (by a PC, DM, or NPC / Monster)
// Run by the module.
void OnAcquire(object oItem, object oAcquiredBy, object oTakenFrom, int nStackSize)
{
 itemproperty iProp = GetFirstProp(oItem);

 int nProp = GetItemPropertySubType(iProp);

 itemproperty ipNew = ItemPropertyCastSpell(nProp,
 IP_CONST_CASTSPELL_NUMUSES_UNLIMITED_USE);

 IPSafeAddItemProperty(oItem, ipNew, 0.0,
 X2_IP_ADDPROP_POLICY_REPLACE_EXISTING);

}

// -----------------------------------------------------------------------------
// oItem was activated ("activate item" or "unique power").
// Run by the module.
void OnActivate(object oItem, object oActTarget, location lActTarget, object oActivator)
{
   // Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem was equipped by a PC.
// Run by the module.
void OnEquip(object oItem, object oEquippedBy)
{
   // Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem is a weapon that just hit a target, or it is the armor of someone who
// was just hit by someone else's weapon.
// Run by the caster.
void OnHit(object oItem, object oHitTarget, object oCaster)
{
   // Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// Someone cast a spell at oItem.

// Run by the caster.
int OnSpellCast(object oItem, int nSpell, object oCaster)
{
  // Enter code to execute when this event happens

  return FALSE; //Necessary return (Do this !)
}


// -----------------------------------------------------------------------------
// oItem was unacquired/lost (by a PC or NPC).
// Run by the module.
void OnUnacquire(object oItem, object oLostBy)
{
   // Enter code to execute when this event happens
}


// -----------------------------------------------------------------------------
// oItem was unequipped by a PC.
// Run by the module.
void OnUnequip(object oItem, object oUnequippedBy)
{
   // Enter code to execute when this event happens
}


//////////////////////////////////////////////////////////////////////////////
// ##### WARNINING:: DON'T TOUCH ANYTHING BELOW THIS LINE!!! #### ///////////
////////////////////////////////////////////////////////////////////////////

// The main function.
void main()
{
   int nEvent = GetUserDefinedItemEventNumber();

   // Spells might continue to their spell scripts. All other events are
   // completely handled by this script.
   if ( nEvent != X2_ITEM_EVENT_SPELLCAST_AT )
       SetExecutedScriptReturnValue();

   // Determine which event triggered this script's execution.
   switch ( nEvent )
   {
       // Item was acquired.
       case X2_ITEM_EVENT_ACQUIRE:
               OnAcquire(GetModuleItemAcquired(), GetModuleItemAcquiredBy(),
                         GetModuleItemAcquiredFrom(), GetModuleItemAcquiredStackSize());
               break;

       // Item was activated ("activate item" or "unique power").
       case X2_ITEM_EVENT_ACTIVATE:
               OnActivate(GetItemActivated(), GetItemActivatedTarget(),
                          GetItemActivatedTargetLocation(), GetItemActivator());
               break;

       // Item was equipped by a PC.
       case X2_ITEM_EVENT_EQUIP:
               OnEquip(GetPCItemLastEquipped(), GetPCItemLastEquippedBy());
               break;

       // Item is a weapon that just hit a target, or it is the armor of someone
       // who was just hit.
       case X2_ITEM_EVENT_ONHITCAST:
               OnHit(GetSpellCastItem(), GetSpellTargetObject(), OBJECT_SELF);
               break;

       // A PC (or certain NPCs) cast a spell at the item.
       case X2_ITEM_EVENT_SPELLCAST_AT:
               if ( OnSpellCast(GetSpellTargetObject(), GetSpellId(), OBJECT_SELF) )
                   SetExecutedScriptReturnValue();
               break;

       // Item was unacquired.
       case X2_ITEM_EVENT_UNACQUIRE:
               OnUnacquire(GetModuleItemLost(), GetModuleItemLostBy());
               break;

       // Item was unequipped by a PC.
       case X2_ITEM_EVENT_UNEQUIP:
               OnUnequip(GetPCItemLastUnequipped(), GetPCItemLastUnequippedBy());
               break;
   }
}

itemproperty GetFirstProp(object oItem)
{
itemproperty iProp = GetFirstItemProperty(oItem);
while(GetIsItemPropertyValid(iProp))
{
  return iProp; // Stop at the first property...
  iProp = GetNextItemProperty(oItem);
}
return iProp;
}
               
               

               


                     Modifié par _Guile, 08 février 2014 - 10:51 .