// acquire item - if in gaseous form immediately drop the item
int fnCountCrystals(object oPC)
{ // fnCountCrystals
  int nC=0;
  object oItem=GetFirstItemInInventory(oPC);
  string sTag;
  while(oItem!=OBJECT_INVALID)
  { // count
    sTag=GetTag(oItem);
    if (sTag=="MANA_CRYSTAL_1"||sTag=="MANA_CRYSTAL_2"||sTag=="MANA_CRYSTAL_5")
      nC++;
    if (nC>1) return 5;
    oItem=GetNextItemInInventory(oPC);
  } // count
  return 1;
} // fnCountCrystals()

void fnPickedUpCrystal(object oItem,object oPC)
{ // picked up a mana crystal
  object oPool;
  string sTag=GetTag(oItem);
  string sRes=GetResRef(oItem);
  if (fnCountCrystals(oPC)>1)
  { // too many crystals destroy it and create a mana pool
    SendMessageToPC(oPC,"You may only carry one mana crystal at a time.");
    DestroyObject(oItem);
    sTag=GetStringRight(sTag,1);
    if (sTag=="1") sRes="minormanapool";
    else if (sTag=="2") sRes="manapool";
    else if (sTag=="5") sRes="strongmanapool";
    oPool=CreateObject(OBJECT_TYPE_PLACEABLE,sRes,GetLocation(oPC));
    if (oPool==OBJECT_INVALID) oPool=CreateObject(OBJECT_TYPE_ITEM,sRes,GetLocation(oPC));
  } // too many crystals destroy it and create a mana pool
  else
  {
    ExecuteScript("rts_save_player",oPC);
  }
} // fnPickedUpCrystal()

void fnPickedUpPower(object oPC,object oItem)
{
  effect eVFX;
  string sID=GetLocalString(oPC,"sTeamID");
  int nNum=VFX_DUR_FLAG_BLUE;
  if (sID=="UNC") nNum=VFX_DUR_FLAG_GOLD;
  else if (sID=="UND") nNum=VFX_DUR_FLAG_PURPLE;
  else if (sID=="SPID") nNum=VFX_DUR_FLAG_RED;
  eVFX=EffectVisualEffect(nNum);
  if (GetItemPossessor(oItem)==oPC)
  { // has item
    ApplyEffectToObject(DURATION_TYPE_TEMPORARY,eVFX,oPC,5.0);
    DelayCommand(5.0,fnPickedUpPower(oPC,oItem));
  }
} // fnPickedUpPower()

void main()
{
  object oItem=GetModuleItemAcquired();
  object oPC=GetModuleItemAcquiredBy();
  object oNew;
  string sTag;
  string sRes;
  if (GetIsPC(oPC)==TRUE)
  { // acquired by
    if (GetLocalInt(oPC,"nVampMist")==TRUE||GetLocalInt(oPC,"bWZGaseous")==TRUE)
    { // gaseous form cannot pick up items
      oNew=CreateObject(OBJECT_TYPE_ITEM,GetResRef(oItem),GetLocation(oPC),GetItemStackSize(oItem));
      DestroyObject(oItem);
      SendMessageToPC(oPC,"You may not pickup items while in gaseous form.");
    } // gaseous form cannot pick up items
    sTag=GetTag(oItem);
    sRes=GetResRef(oItem);
    if (sTag=="MANA_CRYSTAL_1"||sTag=="MANA_CRYSTAL_2"||sTag=="MANA_CRYSTAL_5")
    {
      fnPickedUpCrystal(oItem,oPC);
    }
    if (sTag=="rts_powerres")
    { // picked up the power reservoir
      fnPickedUpPower(oPC,oItem);
    } // picked up the power reservoir
    else if (GetStringLeft(sRes,4)=="rts_")
      ExecuteScript("rts_save_player",oPC);
    else if (sTag=="soultoken"||sRes=="soultoken")
      ExecuteScript("rts_save_player",oPC);
  } // acquired by

}