191 lines
6.0 KiB
Plaintext
191 lines
6.0 KiB
Plaintext
// uc_a_create - Unit Creation Version 2 - Create the unit(s)
|
|
// By Deva Bryson Winblood. 04/10/2005
|
|
#include "uc_h"
|
|
|
|
void fnSetAction(object oMe,string sRaid,int nCmd,int nTactics,object oPC)
|
|
{ // PURPOSE: Set The units initial commands, and tactics
|
|
int nN;
|
|
object oOb;
|
|
vector vV;
|
|
location lLoc;
|
|
object oMod=GetModule();
|
|
string sID;
|
|
int nInstanceID=GetLocalInt(oMod,"nInstanceID");
|
|
SetLocalInt(oMe,"nIID",nInstanceID); // used to help with loading saved games
|
|
//////// set commands
|
|
if (nCmd==3||nCmd>8)
|
|
{ // guard
|
|
nN=0;
|
|
if (nCmd==3)
|
|
{ // where you currently stand
|
|
oOb=GetArea(oMe);
|
|
SetLocalObject(oMe,"oGArea",oOb);
|
|
vV=GetPosition(oMe);
|
|
SetLocalFloat(oMe,"fGX",vV.x);
|
|
SetLocalFloat(oMe,"fGY",vV.y);
|
|
SetLocalFloat(oMe,"fGZ",vV.z);
|
|
} // where you currently stand
|
|
if (nCmd==9) nN=5;
|
|
else if (nCmd==10) nN=4;
|
|
else if (nCmd==11) nN=1;
|
|
else if (nCmd==12) nN=2;
|
|
else if (nCmd==13) nN=3;
|
|
SetLocalInt(oMe,"nMState",2);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
SetLocalInt(oMe,"nParm",nN);
|
|
sID=GetLocalString(oMe,"sTeamID");
|
|
if (nCmd>10&&nCmd<14)
|
|
{ // set location
|
|
lLoc=GetLocalLocation(oMod,"lGuard"+IntToString(nN)+"_"+sID);
|
|
SetLocalLocation(oMe,"lLocation",lLoc);
|
|
} // set location
|
|
SetLocalInt(oMod,"bHasCreatedGuardUnits"+sID,TRUE);
|
|
} // guard
|
|
else if (nCmd==1)
|
|
{ // stand
|
|
SetLocalInt(oMe,"nMState",7);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
} // stand
|
|
else if (nCmd==2)
|
|
{ // follow 3 meters
|
|
SetLocalInt(oMe,"nMState",5);
|
|
SetLocalObject(oMe,"oDestWP",oPC);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
DeleteLocalInt(oMe,"nFollowDist"); // follow 3 meters
|
|
SetLocalInt(oMe,"nRun",TRUE);
|
|
SetLocalInt(oMe,"nGNBRun",TRUE);
|
|
} // follow 3 meters
|
|
else if (nCmd==4)
|
|
{ // guard lair
|
|
SetLocalInt(oMe,"nMState",11);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
sID=GetLocalString(oMe,"sTeamID");
|
|
SetLocalInt(oMod,"bHasCreatedGuardUnits"+sID,TRUE);
|
|
} // guard lair
|
|
else if (nCmd==6)
|
|
{ // recon
|
|
SetLocalInt(oMe,"nMState",14);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
SetLocalObject(oMe,"oDestWP",oPC);
|
|
SetLocalInt(oMe,"nParm",3);
|
|
SetLocalInt(oMe,"nRun",TRUE);
|
|
SetLocalInt(oMe,"nGNBRun",TRUE);
|
|
} // recon
|
|
else if (nCmd==7)
|
|
{ // control point capture
|
|
SetLocalInt(oMe,"nMState",18);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
SetLocalInt(oMe,"nRun",TRUE);
|
|
SetLocalInt(oMe,"nGNBRun",TRUE);
|
|
sID=GetLocalString(oMe,"sTeamID");
|
|
SetLocalInt(oMod,"bHasCreatedCaptureUnits"+sID,TRUE);
|
|
} // control point capture
|
|
else if (nCmd==8)
|
|
{ // power reservoir recover
|
|
SetLocalInt(oMe,"nMState",23);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
SetLocalInt(oMe,"nRun",TRUE);
|
|
SetLocalInt(oMe,"nGNBRun",TRUE);
|
|
} // power reservoir recover
|
|
else if (nCmd==5)
|
|
{ // raid attack
|
|
SetLocalInt(oMe,"nMState",17);
|
|
DeleteLocalInt(oMe,"nSState");
|
|
SetLocalString(oMe,"sTeamToRaid",sRaid);
|
|
SetLocalInt(oMe,"nParm",1);
|
|
SetLocalInt(oMe,"nRun",TRUE);
|
|
SetLocalInt(oMe,"nGNBRun",TRUE);
|
|
} // raid attack
|
|
//////// set tactics
|
|
if (nTactics!=1)
|
|
{ // not default
|
|
if (nTactics==2)
|
|
{ // melee
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","melee");
|
|
} // melee
|
|
else if (nTactics==3)
|
|
{ // ranged
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","ranged");
|
|
} // ranged
|
|
else if (nTactics==4)
|
|
{ // hold
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","hold");
|
|
} // hold
|
|
else if (nTactics==5)
|
|
{ // stealth
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","stealth");
|
|
} // stealth
|
|
else if (nTactics==6)
|
|
{ // flee
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","flee");
|
|
} // flee
|
|
else if (nTactics==7)
|
|
{ // caster
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","caster");
|
|
} // caster
|
|
else if (nTactics==8)
|
|
{ // support
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","support");
|
|
} // support
|
|
else if (nTactics==9)
|
|
{ // summon
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","summon");
|
|
} // summon
|
|
else if (nTactics==10)
|
|
{ // bioware
|
|
SetLocalInt(oMe,"bCOMBAT_AI_ON",TRUE);
|
|
SetLocalString(oMe,"sCOMBAT_AI_TYPE","bioware");
|
|
} // bioware
|
|
} // not default
|
|
} // fnSetAction()
|
|
|
|
|
|
void main()
|
|
{
|
|
object oPC=GetPCSpeaker();
|
|
int nNumber=GetLocalInt(oPC,"nUCNumber");
|
|
int nQty=GetLocalInt(oPC,"nUCQuantity");
|
|
int nCmd=GetLocalInt(oPC,"nUCCmd");
|
|
int nParm=GetLocalInt(oPC,"nParm");
|
|
int nN;
|
|
string sS;
|
|
object oUnit;
|
|
effect eE=EffectVisualEffect(VFX_FNF_SUMMON_MONSTER_1);
|
|
string sID=GetLocalString(oPC,"sTeamID");
|
|
string sRes;
|
|
object oDest=GetLocalObject(oPC,"oCreateUnit");
|
|
location lLoc=GetLocation(oDest);
|
|
string sRaid=GetLocalString(oPC,"sRaid");
|
|
object oProxy=GetObjectByTag(sID+"_PROXY");
|
|
DeleteLocalInt(oPC,"nUCNumber");
|
|
DeleteLocalInt(oPC,"nUCQuantity");
|
|
DeleteLocalInt(oPC,"nUCCmd");
|
|
DeleteLocalInt(oPC,"nParm");
|
|
DeleteLocalString(oPC,"sRaid");
|
|
DestroyObject(oDest);
|
|
TakeResourceCost(oPC,nNumber,nQty);
|
|
sRes=GetUnitResRef(sID,nNumber);
|
|
sRes=GetStringUpperCase(sRes);
|
|
if (sRes=="UND1"||sRes=="UND17"||sRes=="UND20"||sRes=="UND21"||sRes=="UND24") eE=EffectVisualEffect(90);
|
|
if (sRes=="SPID1") eE=EffectVisualEffect(VFX_DUR_WEB);
|
|
nN=0;
|
|
while(nN<nQty)
|
|
{ // create units
|
|
oUnit=CreateObject(OBJECT_TYPE_CREATURE,sRes,lLoc);
|
|
ChangeFaction(oUnit,oProxy);
|
|
DelayCommand(0.1,ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY,eE,GetLocation(oUnit),3.0));
|
|
SetLocalString(oUnit,"sTeamID",sID);
|
|
SetLocalInt(oUnit,"nUnitNum",nNumber);
|
|
fnSetAction(oUnit,sRaid,nCmd,nParm,oPC);
|
|
nN++;
|
|
} // create units
|
|
}
|