HoS_PRC8/_mod/_module/nss/lupg_create_unit.nss
Jaysyn904 04165202c0 Initial upload
Initial upload
2024-11-25 19:36:07 -05:00

58 lines
1.8 KiB
Plaintext

// lupg_create_unit - Create upgrade unit
#include "rtsh_multiplay"
void main()
{
object oPC=GetPCSpeaker();
int nParm=GetLocalInt(oPC,"nParm");
string sID=GetLocalString(oPC,"sTeamID");
object oWP=GetWaypointByTag(sID+"_upgrade_spawn");
object oCreature;
object oItem;
string sReq=GetLocalString(oPC,"sUpgReqItem");
int nN;
int nCost;
string sRes;
if (GetStringLength(sReq)>0)
{ // consume item
oItem=GetItemPossessedBy(oPC,sReq);
DestroyObject(oItem);
} // consume item
if (sID=="SPID")
{ // spider team upgrades
nN=fnGetTeamMana(oPC);
if (nParm==1) { nCost=100; sRes="spidrid1"; }
else if (nParm==2) { nCost=150; sRes="spidrid2"; }
nN=nN-nCost;
fnSetTeamMana(oPC,nN);
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oWP));
} // spider team upgrades
else if (sID=="DWF")
{ // dwarf team upgrades
if (nParm==1) { nCost=200; sRes="dwfupg1"; }
else if (nParm==2) { nCost=300; sRes="dwfupg2"; }
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oWP));
AssignCommand(oCreature,TakeGoldFromCreature(nCost,oPC,TRUE));
} // dwarf team upgrades
else if (sID=="UND")
{ // undead
nN=fnGetTeamMana(oPC);
if (nParm==1) sRes="undupg1";
else if (nParm==2) sRes="undupg2";
nCost=10;
nN=nN-nCost;
fnSetTeamMana(oPC,nN);
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oWP));
} // undead
else if (sID=="UNC")
{ // unclean
nN=fnGetTeamMana(oPC);
if (nParm==1) sRes="uncupg1";
else if (nParm==2) sRes="uncupg2";
nCost=20;
nN=nN-nCost;
fnSetTeamMana(oPC,nN);
oCreature=CreateObject(OBJECT_TYPE_CREATURE,sRes,GetLocation(oWP));
} // unclean
}