Respawning Creeps - comments please

AceHart

Your Friendly Neighborhood Admin
Reaction score
1,504
The interesting stuff first:

Code:
Init
    Events
        Time - Elapsed game time is 1.00 seconds
    Conditions
    Actions
        Set RespawnRegions[1] = R Respawn 1 <gen>
        Set RespawnRegions[2] = R Respawn 2 <gen>
        Set RespawnRegions[3] = R Respawn 3 <gen>
        Set RespawnRegions[4] = R Respawn 4 <gen>
        Set RespawnRegions[5] = R Respawn 5 <gen>
        For each (Integer A) from 1 to 5, do (Actions)
            Loop - Actions
                Unit Group - Pick every unit in (Units in RespawnRegions[(Integer A)]) and do (Actions)
                    Loop - Actions
                        Unit - Set the custom value of (Picked unit) to (Integer A)
                        Unit Group - Add (Picked unit) to SpawnGroups[(Integer A)]


Death
    Events
        Unit - A unit owned by Neutral Hostile Dies
    Conditions
    Actions
        Set DeathUnit = (Triggering unit)
        Set DeathIndex = (Custom value of DeathUnit)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Triggering unit) is in SpawnGroups[DeathIndex]) Equal to True
            Then - Actions
                Trigger - Run DeathInGroup <gen> (ignoring conditions)
            Else - Actions


DeathInGroup
    Events
    Conditions
    Actions
        Unit Group - Remove DeathUnit from SpawnGroups[DeathIndex]
        Unit - Create 1 (Unit-type of DeathUnit) for Neutral Hostile at (Center of RWellHidden <gen>) facing Default building facing degrees
        Unit - Set the custom value of (Last created unit) to DeathIndex
        Unit Group - Add (Last created unit) to Graveyard[DeathIndex]
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                (Number of units in SpawnGroups[DeathIndex]) Equal to 0
            Then - Actions
                Countdown Timer - Start RespawnTimers[DeathIndex] as a One-shot timer that will expire in (Random real number between 20.00 and 50.00) seconds
            Else - Actions


Respawn1
    Events
        Time - RespawnTimers[1] expires
    Conditions
    Actions
        Wait until (RespawnInProgress Equal to False), checking every 2.00 seconds
        Set RespawnIndex = 1
        Trigger - Run Respawn <gen> (ignoring conditions)


Respawn2
    Events
        Time - RespawnTimers[2] expires
    Conditions
    Actions
        Wait until (RespawnInProgress Equal to False), checking every 2.00 seconds
        Set RespawnIndex = 2
        Trigger - Run Respawn <gen> (ignoring conditions)


...repeat with timers 3 to 5


Respawn
    Events
    Conditions
    Actions
        Set RespawnInProgress = True
        Set RespawnRegion = RespawnRegions[RespawnIndex]
        Wait until ((All units of (Units owned by Player 1 (Red)) are in (Region centered at (Center of RespawnRegion) with size (2500.00, 2500.00))) Equal to False), checking every 3.00 seconds
        Unit Group - Pick every unit in Graveyard[RespawnIndex] and do (Actions)
            Loop - Actions
                Unit - Move (Picked unit) instantly to (Random point in RespawnRegion), facing (Position of Tinkerbell 0025 <gen>)
                Unit Group - Add (Picked unit) to SpawnGroups[RespawnIndex]
                Unit Group - Remove (Picked unit) from Graveyard[RespawnIndex]
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Random integer number between 1 and 4) Equal to 2
                    Then - Actions
                        Unit - Add Wander (Neutral) to (Picked unit)
                    Else - Actions
        Set RespawnInProgress = False



The boring part:

Select and remember all Creeps within a set of regions.
Once a region is empty, respawn them after expiration of some randomized timer


The question part:

What I don't like here, is that it requires a "well hidden" region,
unreachable by the player,
to keep the dead creeps until their respawning time has come.

No idea what happens if two or more timers expire at exactly the same time.

One trigger per timer seems a waste of space...


So, any comments welcome.
What's your preferred way of doing this?
Improvements?
Anything?



Hoping to read you soon,
AceHart
 
Heres a concept for you to play with.

Ditch the regions.

Create a Unit Group, ARRAY, called seomthing like DeadGroups[]

A unit dies
Unit Group - Add (dying unit) to DeadGroups[custom value of (dying unit)]

Revive
Unit Group - Pick all units in DeadGroup[x] and do
--Unit - Create 1 (unit type of(picked unit)) for player x at location HERE
--Set custom value of (last created unit) to x
Unit Group - Clear DeadUnits[x]
 
Units don't have a custom value, unless you set one.
So, at the very least, the regions are required for the original placement...

That said, there is a reason why I create a unit in some remote spot on "a unit dies".
The reason being:
If you put a "dying unit" into a unit-group, said group will get empty over time...
just wait long enough.
Dead units are, sooner or later, removed from the game, and from your group.

At least, that's what happened to me :)

So, I recreate a new one and keep it until needed.


Hm...


Thoughtfully yours
AceHart
 
I set it when it revived. Up to you initally to set it, note I only have 5 lines of code out of it all.

How bout something like this, that waits for your good ol' spawn condition

Unit - A unit dies

local unit type OurType
local integer OurNumber
Wait for condition (spawnrightnow=true)
create 1 (OurType) for player x at HERE
set custom value of last created unit = OurNumber
destroy OurType
destroy OurGroup

There would be a seperate instance fired for each dying unit. No, it doesn't take more memory than an array or region storage. Same. Local variables don't share with eachother, so its okay.

Just set the spawnrightnow = 1 and blamo, they will all unload?

I can help you with the custom scripts.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    we were down for a minute - think a log file or something got too big
    +1
  • Ghan Ghan:
    The alerts say it was down for a while unfortunately.
  • Ghan Ghan:
    Didn't know what was going on while I was at work.
  • Ghan Ghan:
    Disk filled up with logs. Fixed now.
    +1
  • The Helper The Helper:
    not a problem at all thanks for getting us back up
  • The Helper The Helper:
    I think the bots are finding a way to get through the anubis
  • The Helper The Helper:
    Happy Wednesday Everyone! Hope everyone has a Fantastic Day!
    +1
  • The Helper The Helper:
    Yeah, stats are showing big bot influx like 12k page views.
  • Wizard Wizard:
    :wave:
    +1
  • Ghan Ghan:
    TH changed his avatar again. 6 more weeks of summer.
    +3
  • Wizard Wizard:
    lol
    +1
  • The Helper The Helper:
    Guys just a heads up I am going to be shutting the site down soon. I am just waiting on the NUON people to decide whether they want to transfer forum data and keep the discord. My email is [email protected] for anyone that wants to keep in touch and I have a facebook too. I will make an official post later. Love you guys and will miss everyone!
    +1
  • V-SNES V-SNES:
    Sent a pm @The Helper
  • Stephen Stephen:
    Oh no - please don't lose the Nuon content
    +1
  • The Helper The Helper:
    Someone email AtariAge and see if they want me to transfer the forum data over to it
  • Ghan Ghan:
    Could probably keep NUON stuff around here if we wanted.
  • Ghan Ghan:
    Hmm what to do about the World Editor site though?
  • Stephen Stephen:
    I'd rather personally just own a backup of the Nuon data than see it go to AtariAge honestly. If it gets enshittified as per usual, or if some of the "regular" Jaguar folks get there, it's not gonna be fun
  • The Helper The Helper:
    There will be a github of the forum data so the NUON Forum Data I guess would be available there
  • The Helper The Helper:
    World Editor is technically Ryoko stuff not mine you guys can keep that I am not in that even
  • jonas jonas:
    :( end of an era :(
  • The Helper The Helper:
    Dont think of it as an end jonas - think of it as a beginning, because really my friend that is what it is.
  • A Andyoyo:
    Thank you for the hard work over the years. It did not go unnoticed.

The Helper Discord

Staff online

  • Ghan
    Administrator - Servers are fun

Members online

Affiliates

Hive Workshop NUON Dome World Editor Tutorials
Back
Top