Different monster spawn each map

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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.

Different monster spawn each map

Postby Pandut » Tue Jun 12, 2018 5:07 pm

Issue is simple; I have 3 enemies that take the role of the standard DoomImp. I do not want to use a RandomSpawner because each monster has a different aesthetic and wouldn't mesh super well. My question is; how do I go about creating a system where each map it randomly chooses 1 of 3 of these monsters to replace the DoomImp per map? Can I do this in Decorate or would it require ZScript/ACS?

I've looked around but can't seem to find anything relation, nor any examples I could reference. Any help would be appreciateddd.
User avatar
Pandut
help
 
Joined: 23 Mar 2010
Location: A room with a moose.

Re: Different monster spawn each map

Postby Matt » Wed Jun 13, 2018 1:05 am

Might something like this work?

MAPINFO
Code: Select allExpand view
gameinfo{
    addeventhandlers="ImpRambler"
}


ZScript
Code: Select allExpand view
version "3.4" //added after OP reported the error below

class ImpRambler:EventHandler{
    override void WorldLoaded(WorldEvent e){
        int which=random(0,2);
        thinkeriterator impreplacer=thinkeriterator.create("doomimp");
        actor imppp=null;
        array<actor>impppdelend;
        while(imppp=actor(impreplacer.next())){
            class<actor> notimp="chaingunguy";
            if(which==1) notimp="lostsoul";
            else if(which==2) notimp="explosivebarrel";
            imppp.spawn(notimp,imppp.pos);
            impppdelend.push(imppp);
        }
        while(impppdelend.size()>0){
            impppdelend[0].destroy();
            impppdelend.delete(0);
        }
    }
}
Last edited by Matt on Wed Jun 13, 2018 3:10 pm, edited 1 time in total.
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Different monster spawn each map

Postby Pandut » Wed Jun 13, 2018 1:29 pm

I've barely if not 0 experience with Zscript, tried to implement it but ended up with these errors;

Code: Select allExpand view
1Pan-ZRift.pk3:zscriptu/impspawn.zsc, line 1: Parent class EventHandler of ImpRambler not accessible to ZScript version 2.3.0
1Pan-ZRift.pk3:zscriptu/impspawn.zsc, line 3: Type WorldEvent not accessible to ZScript version 2.3.0
1Pan-ZRift.pk3:zscriptu/impspawn.zsc, line 3: Invalid type Type for function parameter
1Pan-ZRift.pk3:zscriptu/impspawn.zsc, line 3: Attempt to override non-existent virtual function WorldLoaded


It's likely I did something wrong, haha.
User avatar
Pandut
help
 
Joined: 23 Mar 2010
Location: A room with a moose.

Re: Different monster spawn each map

Postby Matt » Wed Jun 13, 2018 2:57 pm

Sorry, I never remember to add the version number to the start of the ZScript file:

Code: Select allExpand view
version "3.4"
User avatar
Matt
Putting the XD into *xdeath since 2007
 
Joined: 04 Jan 2004
Location: Gotham City SAR, Wyld-Lands of the Lotus People, Dominionist PetroConfederacy of Saudi Canadia

Re: Different monster spawn each map

Postby Pandut » Wed Jun 13, 2018 3:49 pm

Yep! It works now, thank you so much!
User avatar
Pandut
help
 
Joined: 23 Mar 2010
Location: A room with a moose.


Return to Scripting

Who is online

Users browsing this forum: No registered users and 1 guest