/////////////////////////////////////////////////////////////////////////////
// Real Time Strategy - NWN - Use Mana Pool
//===========================================================================
// By Deva Bryson Winblood.  02/28/2003
/////////////////////////////////////////////////////////////////////////////

void main()
{
    object oPC=GetLastUsedBy();
    object oItem;
    effect eVFX=EffectVisualEffect(VFX_IMP_LIGHTNING_S);
    int nNoneNear=TRUE;
    float fDist;
    if(nNoneNear)
    { // none on ground nearby
    oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_1");
    if (oItem==OBJECT_INVALID)
      oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_2");
    if (oItem==OBJECT_INVALID)
      oItem=GetItemPossessedBy(oPC,"MANA_CRYSTAL_5");
    if (oItem==OBJECT_INVALID)
    { // get Mana Crystal
      ApplyEffectToObject(DURATION_TYPE_INSTANT,eVFX,oPC,1.0);
      if (GetTag(OBJECT_SELF)=="MinorManaPool")
       oItem=CreateItemOnObject("mana_crystal_1",oPC,1);
      else if (GetTag(OBJECT_SELF)=="ManaPool")
       oItem=CreateItemOnObject("mana_crystal_2",oPC,1);
      else if (GetTag(OBJECT_SELF)=="StrongManaPool")
       oItem=CreateItemOnObject("mana_crystal_5",oPC,1);
       DestroyObject(OBJECT_SELF);
       if (GetIsPC(oPC)) SendMessageToPC(oPC,"Now you need to take this crystal back to the mana vault in your lair.");
    } // get mana Crystal
    else
     SendMessageToPC(oPC,"You already have a mana crystal that needs to be taken to the vault.");
   } // none on ground nearby
   else
     SendMessageToPC(oPC,"There is a mana crystal on the ground nearby.  Letting you take the one from this pool and then pick that one up would be cheating.");
}