44 lines
1.1 KiB
Plaintext
44 lines
1.1 KiB
Plaintext
////////////////////////////////////////////////////////////////////////////
|
|
// Real Time Strategy - NWN - Count Units
|
|
//==========================================================================
|
|
// By Deva Bryson Winblood. 02/26/2003
|
|
////////////////////////////////////////////////////////////////////////////
|
|
|
|
void main()
|
|
{
|
|
object oMod=GetModule();
|
|
object oMe=OBJECT_SELF;
|
|
int nCount=0;
|
|
int nDigits=1;
|
|
string sTag=GetTag(oMe);
|
|
string sPre;
|
|
string sMain;
|
|
object oC;
|
|
string sUnit;
|
|
int nTeamNum;
|
|
int nL;
|
|
int nUnits;
|
|
int nUnit;
|
|
if (StringToInt(GetStringRight(sTag,2))>0) nDigits=2;
|
|
sPre=GetStringLeft(sTag,nDigits);
|
|
if (GetIsPC(oMe)) sPre=GetLocalString(oMe,"sTeamID");
|
|
sMain=sPre+"_UnitCount";
|
|
nTeamNum=GetLocalInt(oMod,sPre+"_num");
|
|
nUnits=GetLocalInt(oMod,"nTeamU"+IntToString(nTeamNum));
|
|
nUnit=0;
|
|
while(nUnit<nUnits&&nUnits!=0)
|
|
{ // count
|
|
sUnit=sPre+IntToString(nUnit);
|
|
nUnit++;
|
|
nL=0;
|
|
oC=GetObjectByTag(sUnit,nL);
|
|
while(oC!=OBJECT_INVALID)
|
|
{
|
|
nCount++;
|
|
nL++;
|
|
oC=GetObjectByTag(sUnit,nL);
|
|
}
|
|
} // count
|
|
SetLocalInt(oMod,sMain,nCount);
|
|
}
|