Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
  • 0
AveryRe

How can I tell if a specific monster type is killed in ACS?

Question

I don't mean a thing by TID. For example, if I wanted to be able to tell if ANY non-specific Imp was killed on the map, then display a messaging saying "Player has killed an Imp!".

 

Thanks in advance!

Edited by AveryRe

Share this post


Link to post

3 answers to this question

Recommended Posts

  • 1

I'm not sure there is a direct way of obtaining that information in ACS, but what you could do is assign a Thing Special to each monster, that executes a script with a parameter that supplies the type of monster that was killed. By default the activator of the script will be the player that killed the monster.

 

To assign the specials to the monsters, you could do:

a) If you are making a new map, assign the specials in the editor by selecting all monsters of a specific type and assigning the special accordingly

b) Make replacements for the monsters in decorate, and assign the specials when they spawn according to the type.

c) Use SetActivator & Thing_ChangeTID and CheckActorClass/GetActorClass to loop through all the actors in the map and assign thing specials accordingly. (But this method also requires messing with actor TIDs, which may become an issue if the map makes use of any TIDs)

 

See:

https://zdoom.org/wiki/SetThingSpecial

https://zdoom.org/wiki/Thing_SetSpecial

https://zdoom.org/wiki/Thing_executed_specials

https://zdoom.org/wiki/MAPINFO/Map_definition#ActivateOwnDeathSpecials

https://zdoom.org/wiki/Actor_properties#Activation

 

However if you give each monster a thing special, whatever special they had prior to that will be replaced. So in case you plan to use this with existing maps/mods, it might cause issues with maps/mods that already make use of thing specials.

 

 

Share this post


Link to post
  • 1

Check this: https://zdoom.org/wiki/CheckActorClass

 

From that link:

#define NUM_CLASSES       18

str monster_class[NUM_CLASSES] = {
  "Arachnotron", "Archvile", "BaronOfHell",
  "Cacodemon", "ChaingunGuy", "Cyberdemon",
  "Demon", "DoomImp", "Fatso",
  "HellKnight", "LostSoul", "PainElemental",
  "Revenant", "ShotgunGuy", "Spectre",
  "SpiderMastermind", "WolfensteinSS", "ZombieMan"  
};

script 1 (int tid)
{
  int class_index = -1;

  if (!tid && ActivatorTID())
    tid = ActivatorTID();

  for (int i=0; i<NUM_CLASSES; i++)
    if (CheckActorClass(tid, monster_class[i]))
      class_index = i;
 
  if (class_index > -1)
    PrintBold(s:"Look out for the ", s:monster_class[class_index], s:"!");
  else
    PrintBold(s:"Look out for the... wait, what is that?");
}

A more simpler approach:

script 1 (int tid)
{
  if (CheckActorClass(tid, "DoomImp"))
    print(s:"It's an Imp!");
  else
    print(s:"Not an Imp!");
}

Notice that you can use strings.

Edited by R4L

Share this post


Link to post
  • 0

Sorry for being a bit slow, I'm coming from a Python background mostly, I'm understanding how to reference these classes, but how for example would I set up a function to "fire" every time an Imp is killed, and return the player who did so. I.e getting the killing player as the activator, but still returning the type of monster they had killed.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×