Back to the Vavoom Forum Archives


Forum

Respawning monsters

Thu, 27 Dec 2007 16:21:36

Karnizero

Is there any way to make monsters respawn, after a while they become killed? The respawning time must be set via ACS or something, allowing to make harder monsters to take more time to respawn. Same answer for any other pickable item, such as artifacts, weapons, ammo, etc... Thanks in advice.
Thu, 27 Dec 2007 16:55:12

Janis Legzdinsh

Theoretically it can be simulated using ACS.
Thu, 27 Dec 2007 17:03:02

Crimson Wizard

Simple methods can be seen in original Hexen scripts: This one is from Map02
script 255 OPEN
{
    int var0;

    delay(const:8400);
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(255, T_ETTIN, 128);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(254, T_ETTIN, 0);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(253, T_ETTIN, 0);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(252, T_ETTIN, 0);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(251, T_ETTIN, 0);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(250, T_ETTIN, 128);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(249, T_ETTIN, 128);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(248, T_ETTIN, 128);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(247, T_ETTIN, 96);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(246, T_ETTIN, 128);
    }
    var0 = random(const:0, 1);
    if(var0 == 1)
    {
        Thing_Spawn(245, T_ETTIN, 0);
    }
    restart;
}
This script spawns random number of monsters at specified positions each 8400 tics (240 seconds). Then, if you are not against modding, you may modify progs correspondingly, so that new monsters spawn on same place where dead ones corpses lie. I think nighmare mode does this, though I never looked for this in code, so can't say anything specific. Also items respawn in deathmatch mode, so you can check that part also.
Fri, 28 Dec 2007 00:42:50

Karnizero

@Crimsom Wizard: thanks for the ACS. I am getting new ideas from that code. Really thanks <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D --> But, what i was looking for is to respawn a monster in a given MapSpot, when the previous monster bound to that spot is killed, and after a defined amount of seconds, but not randomly spawns. I have achieved that at GzDoom, using Decorate and ACS. Not much hard. But i think that it can be done using only ACS. The process could be something like this: [color=red:oy4uribh]1.-[/color:oy4uribh] Set a MapSpot Object, with a defined TAG (for example 100) [color=red:oy4uribh]2.-[/color:oy4uribh] Set a Ettin (for example) Monster Object with the MapSpot TAG plus one (for example 101: 100 + 1) [color=red:oy4uribh]3.-[/color:oy4uribh] This monster must have a Thing Action "226: ACS_ExecuteAlways()" [color=red:oy4uribh]4.-[/color:oy4uribh] This Function takes some parameters: -> [color=cyan:oy4uribh]Script Number[/color:oy4uribh]: I think no more explanation needed. -> [color=cyan:oy4uribh]Map Number[/color:oy4uribh]: set to 0, will work at all maps. -> [color=cyan:oy4uribh]Time until respawn[/color:oy4uribh]: Time in seconds until respawn. -> [color=cyan:oy4uribh]Monster ID[/color:oy4uribh]: the identification number of the monster itself. Not the TAG. -> [color=cyan:oy4uribh]MapSpot TAG[/color:oy4uribh]: TAG of the MapSpot where to respawn. With this, we can get also the future Monster TAG (just MapSpot + 1). An example for previous spot and monster: ACS_ExecuteAlways (2, 0, 30, <Ettin_ID>, 100); [color=red:oy4uribh]5.-[/color:oy4uribh] When we kill this monster, we will trigger the Thing Action, calling an unique script with all needed data. The script could be something simillar to this:
script 2 (int seconds, int monstId, int spotTag)
{
    delay (35 * seconds); //The required delay: 35 Tics = 1 second
    Thing_Spawn (..., monstId, spotTag); //Dont remember this function syntax. Must check at WikiDoc.
}
This will ([u:oy4uribh]should[/u:oy4uribh], not tested) work fine, but we need to "duplicate" the Thing Action and all its parameters for the new Ettin we will spawn. Only that is needed for the procedure to work correctly, more than once. The bad point is that standing over the MapSpot object (the player or any other Object), will make the procedure not to work (at GzDoom, Thing_Spawn does not work if something is over the MapSpot). Any way to "duplicate" the Thing Action for the new object? Any question about the explanation? (mainly for my bad english <!-- s:P --><img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz" /><!-- s:P -->) And another last question: What console command "respawn" does? I set that to 1, but i dunno what it really does... Thanks and cya.
Fri, 28 Dec 2007 01:37:19

Firebrand

Respawn console command is used to respawn a killed player, if you use it while playing nothing will really happen, it's not a CVAR, so it won't accept any numbers or anything <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->. This method is quite good for making monsters respawn, why not make the script repeatable after some time? Then when spawning the new monster, give it a TID number and make the script count things with this TID, you would have to use a TID for every monster in the map that would make this thought, but it's better than nothing, right? <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->
Fri, 28 Dec 2007 10:56:24

Crimson Wizard

[quote="Karnizero":2am98dxe]This will ([u:2am98dxe]should[/u:2am98dxe], not tested) work fine, but we need to "duplicate" the Thing Action and all its parameters for the new Ettin we will spawn. spawn new creature with setting a TID to him: Thing_Spawn(tid, type, angle, newtid) first 'tid' is a TID of MapSpot, last parameter - a TID that would be applied to monster. Then... - SetThingSpecial(tid, special, arg1, arg2, arg3, arg4, arg5) Simple. There should be ACS manual in ZDoom WIKI, I believe most of ZDoom specific commands work in Vavoom now as well, and all of the original Hexen's ofcourse.
Sat, 29 Dec 2007 00:54:54

Karnizero

[quote="Crimson Wizard":ds6tc2k8]spawn new creature with setting a TID to him: Thing_Spawn(tid, type, angle, newtid) first 'tid' is a TID of MapSpot, last parameter - a TID that would be applied to monster. Then... - Yes, i already know what paremeters means, but i didnt remember the order of them. [quote="Crimson Wizard":ds6tc2k8]SetThingSpecial(tid, special, arg1, arg2, arg3, arg4, arg5) Simple. There should be ACS manual in ZDoom WIKI, I believe most of ZDoom specific commands work in Vavoom now as well, and all of the original Hexen's ofcourse. Many years without accessing ZDoom Wiki <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: --> But with that function, we can finish the script. Lets supose that the Map Spot has a TAG of 100 The "respawning" script is the script number 2. The Ettin has a TAG of 101, them the Ettin thing action should be: [color=cyan:ds6tc2k8]ACS_ExecuteAlways (2, 0, 30, <Ettin_Number>, 100)[/color:ds6tc2k8] [<Ettin_Number> = ID number for the Ettin thing] And ACS script should be:
script 2 (int seconds, int monstId, int spotTag)
{
    int monsterTAG;
    monsterTAG = spotTag + 1;
    delay (35 * seconds); //Time until respawn
    Thing_Spawn (spotTag, monstId, 0, monsterTAG); //Spawn Thing. Angle = 0.
    SetThingSpecial (monsterTag, 226, 2, 0, seconds, monstID, spotTag); //This is "226:ACS_ExecuteAlways ()"
}
Thanks for sintax tips, [color=red:ds6tc2k8]Crimson Wizard[/color:ds6tc2k8], and yes, the most ACS Vavoom sintax is the same as GzDoom one. I cant tell the same for ZDoom, cause i have not used ZDoom since 2005 or 2006, but probably the same... I have attached a file, containing the sample wad with all this stuff working. I have already tested, and works fine. Also contains the .gwa file and a .bat file for faster running. Now we need to make the script to "erase" the dead body after some seconds, maybe with "Thing_Destroy()", but i am very lazy now. <!-- s:lol: --><img src="{SMILIES_PATH}/icon_lol.gif" alt=":lol:" title="Laughing" /><!-- s:lol: --> Click [u:ds6tc2k8]here[/u:ds6tc2k8] to download sample map.
Sat, 29 Dec 2007 10:24:57

Crimson Wizard

Heh, I like syntax highlighting you use in your post <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) -->
Now we need to make the script to "erase" the dead body after some seconds, maybe with "Thing_Destroy()"
Probably it will work.
Sat, 29 Dec 2007 13:53:14

Karnizero

[quote="Crimson Wizard":2osm82hx]Heh, I like syntax highlighting you use in your post <!-- s;) --><img src="{SMILIES_PATH}/icon_wink.gif" alt=";)" title="Wink" /><!-- s;) --> Being programmer since 1998, makes a person much methodic. <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> [quote="Crimson Wizard":2osm82hx]Probably it will work. Tested with Thing_Destroy(), but not working. I think that is only for damaging and also getting extreme deaths. I have used instead Thing_Remove(), and works fine. Now the script keeps as follows:
script 2 (int seconds, int monstId, int spotTag)
{
    int monsterTAG;
	
    monsterTAG = spotTag + 1;
	
    delay (35); //1 second before deleting corpse
    Thing_Remove (monsterTag); //Remove the corpse. No the special gibbed items

    delay (35 * seconds - 1); //Time until respawn. One second less.
    Thing_Spawn (spotTag, monstId, 0, monsterTAG); //Spawn Thing. Angle = 0.
    SetThingSpecial (monsterTag, 226, 2, 0, seconds, monstID, spotTag); //"226:ACS_ExecuteAlways ()"
}
The only limitations for all this stuff are: [color=red:2osm82hx]1.-[/color:2osm82hx] No item, monster or player should be over the Map Spot where monster will spawn, or Thing_Spawn() will not work. [color=red:2osm82hx]2.-[/color:2osm82hx] If a gibbed monster leaves items (for example, Centaurs leaves shield and sword), those items wont be deleted. But that is not a script limitation. That is a engine issue, also present at GzDoom and ZDoom (and probably any other engine/source). New version for Respawning testing map is now available, letting you all to test new script functionality. Also a small bug has been detected and fixed. Click [u:2osm82hx]here[/u:2osm82hx] to download [color=white:2osm82hx]version 1.1[/color:2osm82hx] - 2 Kb -> .GWA file -> .WAD file -> .BAT easy launcher Any other tip or issue will be wellcome, and happy new year. <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
Sat, 29 Dec 2007 14:11:36

Crimson Wizard

[quote="Karnizero":2ak6krn5]Tested with Thing_Destroy(), but not working. I think that is only for damaging and also getting extreme deaths. I have used instead Thing_Remove(), and works fine. Oops, yeah, that was my mistake. [quote="Karnizero":2ak6krn5][color=red:2ak6krn5]1.-[/color:2ak6krn5] No item, monster or player should be over the Map Spot where monster will spawn, or Thing_Spawn() will not work. I suggest you try following. Every ACS function should return a boolean value, which tells if a function succeeded. So, perhaps you could make a check and if function failed, repeat action (once or some number of times) after short delay, like:
if (! Thing_Spawn(...))
{
   delay(70);
   Thing_Spawn(...), or repeat same script from beginning
}
[quote="Karnizero":2ak6krn5][color=red:2ak6krn5]2.-[/color:2ak6krn5] If a gibbed monster leaves items (for example, Centaurs leaves shield and sword), those items wont be deleted. That's because these are separate objects, not connected to main body anymore. BTW - that looks like a reason for a suggestion to engine Author: maybe these items should be linked somehow to corpse and be removed with it also.
Thu, 03 Jan 2008 10:03:57

Janis Legzdinsh

Better like this
while (!Thing_Spawn(...))
{
   delay(70);
}
That's because these are separate objects, not connected to main body anymore. BTW - that looks like a reason for a suggestion to engine Author: maybe these items should be linked somehow to corpse and be removed with it also.
They are added to the list of dead bodies and will be removed automatically when certain amount of dead bodies are on the level.

Back to the Vavoom Forum Archives