To kill an Archangel

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
User avatar
Leon_Portier
Posts: 62
Joined: Sun Feb 12, 2017 3:30 pm
Location: Dark side of Bavaria

To kill an Archangel

Post by Leon_Portier »

Sometimes it is necessary to kill all Archangles on a map. I´m trying to do that with ACS and ZScript, for some reason it seems to have no effect. I can confirm that the ACS Code is being run on the changing Sector color. Can one help me to see where the error is?

ACS Code

Code: Select all

script "Super_complete" (void) {

	scriptcall("ArchKiller", "FindAndKill"); //Kill all Archangles!
	Thing_Deactivate (29);
	Thing_Activate (30);
	Sector_SetColor(28,0,255,50,0);
}
ZScript code

Code: Select all

class ArchKiller : Actor {
    static void FindAndKill() {
       ThinkerIterator it = thinkeriterator.create("ArchAngel");
	   actor archie;
        while(archie == it.Next()) 
		{ 
			archie.Destroy();  
		}
    }
}
It snuggles in right there in the WAD
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: To kill an Archangel

Post by Mikk- »

Maybe I'm wrong but should it not be

Code: Select all

class ArchKiller : Actor {
    static void FindAndKill() {
       ThinkerIterator it = thinkeriterator.create("ArchAngel");
      actor archie;
        while(archie = it.Next()) 
      { 
         archie.Destroy();  
      }
    }
} 
?

(you used "==" instead of "=" )
User avatar
Leon_Portier
Posts: 62
Joined: Sun Feb 12, 2017 3:30 pm
Location: Dark side of Bavaria

Re: To kill an Archangel

Post by Leon_Portier »

Thanks for the quick reply.
I did what you advised, but that seems to break it.
I get the error message that I´m trying to compare a thinker with a actor.

Code: Select all

Script error, "MAP01.wad:ZSCRIPT" line 6:
Cannot convert Pointer<Class<Thinker>> to Pointer<Class<Actor>>
line 6 is the while

Code: Select all

        while(archie = it.Next()) 
Also, in C++ to compare stuff I always used '==', maybe its different in Zscript.
Is it possible to convert it?
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: To kill an Archangel

Post by Mikk- »

Ah, I see what's missing, there is class cast required:
My apologies - this snippet should work

Code: Select all

static void FindAndKill()
    {
    ThinkerIterator think = ThinkerIterator.Create("ArchAngel");
    actor mo;
    while(mo = Actor(think.Next()))
        {
        mo.Destroy();
        }
    }
 
User avatar
Leon_Portier
Posts: 62
Joined: Sun Feb 12, 2017 3:30 pm
Location: Dark side of Bavaria

Re: To kill an Archangel

Post by Leon_Portier »

Yes! It works! Thank you a lot!
User avatar
Mikk-
Posts: 2274
Joined: Tue Jun 30, 2009 1:31 pm
Location: Somewhere off Kanagawa

Re: To kill an Archangel

Post by Mikk- »

No problem - mind you might not want to use mo.Destroy(); as it flat-out removes the monster from existence. Perhaps the use of mo.Die(null, null); would potentially work more in your favour?
User avatar
Matt
Posts: 9696
Joined: Sun Jan 04, 2004 5:37 pm
Preferred Pronouns: They/Them
Operating System Version (Optional): Debian Bullseye
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia
Contact:

Re: To kill an Archangel

Post by Matt »

The monster in question has a specific DamageMobj override that should prevent that from working. I might update it to allow a force-kill.
User avatar
Leon_Portier
Posts: 62
Joined: Sun Feb 12, 2017 3:30 pm
Location: Dark side of Bavaria

Re: To kill an Archangel

Post by Leon_Portier »

Ja, that works too!
Post Reply

Return to “Scripting”