Something like ThingCount("StealthDoomImp",0) perhaps?
I've already tried that, and since it needs an integer instead of a string, it doesn't work, of course

Virgil: I have used the thingcount function plenty of times. What I'm looking for is a function like thingcount, but it will take an actor name string out of the list you get when you type dumpclasses actor in the console, instead of the pre-defined integer constants in zdefs.acs.int spawn(str actorType, fixed x, fixed y, fixed z, opt int tid, opt int angle);
Spawns an actor at a specific location on the map. For a list of things you can spawn, type dumpclasses actor
Code: Select all
int DLevelScript::DoThingCount (const TypeInfo * kind, int tid)
{
AActor *actor;
int count = 0;
if (tid)
{
FActorIterator iterator (tid);
while ( (actor = iterator.Next ()) )
{
if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind)))
{
count++;
}
}
}
else
{
TThinkerIterator<AActor> iterator;
while ( (actor = iterator.Next ()) )
{
if (actor->health > 0 &&
(kind == NULL || actor->IsA (kind)))
{
count++;
}
}
}
return count;
}
int DLevelScript::ThingCount (int type, int tid)
{
AActor *actor;
const TypeInfo *kind;
int count = 0;
if (type >= MAX_SPAWNABLES)
{
return 0;
}
else if (type > 0)
{
kind = SpawnableThings[type];
if (kind == NULL)
return 0;
}
else
{
kind = NULL;
}
return DoThingCount(kind, tid);
}
int DLevelScript::ThingCountName (const char * type, int tid)
{
const TypeInfo * info = NULL;
if (type != NULL && type[0]!=0)
{
info = TypeInfo::FindType (type);
if (info == NULL && type[0]!=0)
{
Printf ("ACS: I don't know what %s is.\n", type);
}
}
return DoThingCount(info, tid);
}
Code: Select all
case PCD_THINGCOUNTNAME:
STACK(2) = ThingCountName (FBehavior::StaticLookupString (STACK(2)), STACK(1));
sp--;
break;
Code: Select all
function int T_GetNumForName ( str Classname ) //nostalgia ;)
{
switch(Classname)
{
case "ZombieMan": return T_ZOMBIE;
case "ShotgunGuy": return T_SHOTGUY;
case "ChaingunGuy": return T_CHAINGUY;
case "DoomImp": return T_IMP;
case "Demon": return T_DEMON ;
case "Spectre": return T_SPECTRE;
case "LostSoul": return T_LOSTSOUL;
case "Cacodemon": return T_CACODEMON;
case "PainElemental": return T_PAINELEMENTAL;
case "Fatso": return T_MANCUBUS;
case "Revenant": return T_REVENANT;
case "Archvile": return T_VILE;
case "BaronOfHell": return T_BARON;
case "HellKnight": return T_HELLKNIGHT;
case "Cyberdemon": return T_CYBERDEMON;
case "Arachnotron": return T_ARACHNOTRON;
// case "ADecorateMons": return 123; //like so, just to be clear
}
print(s:"What the hell is a ",s:Classname, s:" , eh?"); //error you get if you spell it wrong.
return 0;
}
function int StringThingCount ( str Classname, int TID )
{
return ThingCount(T_GetNumForName(Classname), TID);
}