#include "rtsh_multiplay"

void main()
{
  object oPC=GetPCSpeaker();
  object oTarget=GetLocalObject(oPC,"oTarget");
  location lLoc=GetLocation(oTarget);
  int nParm=GetLocalInt(oPC,"nParm");
  object oCreate;
  int nCost;
  string sRes="";
  int nType=0;
  int nMana=fnGetTeamMana(oPC);
  string sID;
  object oProxy;
  object oWP;
  if (nParm==1)
  { // minor ward
    nCost=25;
    sRes="darkward25";
  } // minor ward
  else if (nParm==2)
  { // ward
    nCost=50;
    sRes="darkward50";
  } // ward
  else if (nParm==3)
  { // major ward
    nCost=100;
    sRes="darkward100";
  } // major ward
  else if (nParm==4)
  { // minor creature
    nCost=10;
    nType=1;
    sRes="darkshadow";
  } // minor creature
  else if (nParm==5)
  { // creature
    nCost=50;
    nType=1;
    sRes="darkshfiend";
  } // creature
  else
  { // major creature
    nCost=500;
    nType=1;
    sRes="darknight";
  } // major creature
  nMana=nMana-nCost;
  fnSetTeamMana(oPC,nMana);
  if (nType==1)
  { // creature
    sID=GetLocalString(oPC,"sTeamID");
    oWP=GetWaypointByTag(sID+"_RESOURCES");
    oProxy=GetObjectByTag(sID+"_PROXY");
    oCreate=CreateObject(OBJECT_TYPE_CREATURE,sRes,lLoc);
    SetLocalString(oCreate,"sTeamID",sID);
    ChangeFaction(oCreate,oProxy);
  } // creature
  else
  { // placeable
    oCreate=CreateObject(OBJECT_TYPE_PLACEABLE,sRes,lLoc);
    SetLocalObject(oCreate,"oMaster",oPC);
  } // placeable
}