Respawn creeps.

Crazy_Dead

New Member
Reaction score
24
Your trigger isn't going to work if the triggering unit disappears from the game by decay, Lifee. Furthermore, that trigger example leaks more than just a location and will cause the game to lag.

A system isn't something that takes only one line of GUI. We'll first be able to help you on this subject once you are willing to accept that there is work and a learning process involved in making a map.

@Next Post by Lifee

1st: Your trigger leaks.
2nd: Check Quote.
 

apostolis

New Member
Reaction score
1
i tried both .When i put time for example 3 sec just to see if its working its working but when i put 300 sec they never respawn
 

Seprest

New Member
Reaction score
15
After the wait time create 1 temporary point will be set to a random point in a desired region. Check if there are no units in the area, if there isn't spawn the a unit of type of dying unit. Destroy temp points.

Wouldn't that be fine for a simple creep respawn trigger?

You may also want to create some code to check what region the unit should spawn in.
 

apostolis

New Member
Reaction score
1
it seems that when a creep is not been respawned(for any reazon) blocks all the respawns that must be done.I dont get it thought but i thing thats the reason why its not working
 

OneBadPsycho

10100111001
Reaction score
93
A simple respawn system could look like this:

First we set the creep respawn points, using their own unique custom value.
Code:
Creep Setup
    Events
        Map initialization
    Conditions
    Actions
        Set [COLOR="Red"]TempGroup[/COLOR] = (Units owned by [COLOR="SeaGreen"]Player owning your creeps![/COLOR])
        Unit Group - Pick every unit in [COLOR="Red"]TempGroup[/COLOR] and do (Actions)
            Loop - Actions
                Set [COLOR="Red"]Integer[/COLOR] = ([COLOR="Red"]Integer[/COLOR] + 1)
                Unit - Set the custom value of (Picked unit) to [COLOR="Red"]Integer[/COLOR]
                Set [COLOR="Red"]CreepLoc[/COLOR][[COLOR="Red"]Integer[/COLOR]] = (Position of (Picked unit))
        Custom script:   call DestroyGroup(udg_[COLOR="Red"]TempGroup[/COLOR])

Then we make a trigger, which checks for the owner, whenever a unit dies.
Code:
Respawn
    Events
        Unit - A unit Dies
    Conditions
        (Owner of (Dying unit)) Equal to [COLOR="SeaGreen"]Player owning your creeps![/COLOR]
    Actions
        Wait [COLOR="SeaGreen"]Respawn Time[/COLOR] seconds
        Unit - Create 1 (Unit-type of (Dying unit)) for (Owner of (Dying unit)) at [COLOR="Red"]CreepLoc[/COLOR][(Custom value of (Dying unit))] facing Default building facing degrees
        Unit - Set the custom value of (Last created unit) to (Custom value of (Dying unit))

I have marked variables with red and constants with green. You will only need to change these.

You will need the following variables:

TempGroup - Unit Group Variable
Integer - Integer Variable
CreepLoc - Point Array Variable
 

Inflicted

Currently inactive
Reaction score
63
surely for your trigger :Creep Setup: you would want it every second and not at initialisation? cos what if he creates new units?
 

OneBadPsycho

10100111001
Reaction score
93
surely for your trigger :Creep Setup: you would want it every second and not at initialisation? cos what if he creates new units?

Create new units where? If he use the palette in the editor they will automatically be counted in this.

If he create them using a trigger he just adds the following below the unit creation:
Code:
Set [COLOR="Red"]Integer[/COLOR] = ([COLOR="Red"]Integer[/COLOR] + 1)
Unit - Set the custom value of (Last created unit) to [COLOR="Red"]Integer[/COLOR]
Set [COLOR="Red"]CreepLoc[/COLOR][[COLOR="Red"]Integer[/COLOR]] = (Position of (Last created unit))
 

Inflicted

Currently inactive
Reaction score
63
well i dont know his map - but maybe he has a building and trains units or something, your trigger works off initialisation, so yeah i dont thing thatd work for training or hiring. but easily fixable i gues
 

Bogrim

y hello thar
Reaction score
154
Just a small note, there's no reason to use "Dying unit". Just use Triggering unit. The unit that activates the event will always be the triggering unit, and all the event responses that correspond to triggering unit are completely pointless.
 

OneBadPsycho

10100111001
Reaction score
93
Just a small note, there's no reason to use "Dying unit". Just use Triggering unit. The unit that activates the event will always be the triggering unit, and all the event responses that correspond to triggering unit are completely pointless.

It shouldn't matter much.



are both natives and if he uses dying unit, he wouldn't get confused later, even if Triggering Unit is faster.
 

Bogrim

y hello thar
Reaction score
154
Furthermore, you should save the integer of the unit type locally in that trigger, OneBadPsycho, or you'll still be at the risk of no unit being created at respawn. That would be adding
Trigger:
  • Custom script: local integer i = GetUnitTypeId(GetTriggerUnit())

as the first line in the trigger, create a unit-type variable named something like "Temp_Type", adding
Trigger:
  • Custom script: set udg_Temp_Type = i

after the wait and then create a unit-type of the variable instead.
 

OneBadPsycho

10100111001
Reaction score
93
Could you explain exactly why ? :eek:

This, for instance, works:

JASS:
globals
    real Respawn_Time = 30
    location array CreepLoc
endglobals

scope Respawn initializer Init

private function Conditions takes nothing returns boolean
    return GetOwningPlayer(GetDyingUnit()) == Player(9)
endfunction

private function Actions takes nothing returns nothing
    local unit re
    call TriggerSleepAction(Respawn_Time)
    set re = CreateUnitAtLoc(GetOwningPlayer(GetDyingUnit()), GetUnitTypeId(GetDyingUnit()), CreepLoc[GetUnitUserData(GetDyingUnit())], GetRandomReal(1, 360))
    call SetUnitUserData(re, GetUnitUserData(GetDyingUnit()))
    set re = null
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer lint = 0
    loop
        call TriggerRegisterPlayerUnitEvent(t, Player(lint), EVENT_PLAYER_UNIT_DEATH, null)
        set lint = lint + 1
        exitwhen lint == 11
    endloop    
    call TriggerAddCondition(t, Condition(function Conditions))
    call TriggerAddAction(t, function Actions)
    set t = null
endfunction

endscope


This is going off topic.
 

Bogrim

y hello thar
Reaction score
154
Could you explain exactly why ? :eek:
While triggerunit is a local variable that will persist through any wait period, it is still just a handle and if the unit itself disappears from the game (for any reason, such as decay, being the target of a Raise Dead-type spell or removed by a trigger) before the handle is used, the game cannot retrieve the necessary information. For this same reason, you saved the location variables in the map initialization rather than as an attached variable to the unit.
 

tooltiperror

Super Moderator
Reaction score
231
@OneBadPsycho - Of course, you could attach the data to a struct so you don't have to use the hideous TSA. And make it MUI. You also shouldn't be changing unit values, since it will ruin indexers. And you don't need any globals. You could also use a function called RespawnTime to get the time you need, and possibly add an argument to it so different units have different respawn times.

Uses Key Timers.

JASS:
 library Respawn initializer onInit uses KT
  private function RespawnTime takes nothing returns real
      return 60.00
  endfunction
  struct Data
     integer rawcode
     player owner
     real x
     real y
       private static method create takes unit u returns thistype
           local thistype this=thistype.allocate()
           set this.rawcode=GetUnitTypeId(u)
           set this.owner=GetOwningPlayer(u)
           set .x=GetUnitX(u)
           set .y=GetUnitY(u)
           return this
       endmethod
  endstruct
  private function callback takes nothing returns boolean
     local Data data=KT_GetData() // I forget how to inline this.
     call CreateUnit(data.owner,data.int,data.x,data.y,0)
     return true
  endfunction
  private function Action takes nothing returns nothing
      local Data data=Data.create(GetUnitTypeId(GetTrigerUnit()))
      call KT_Add(function callback,data,RespawnTime())
  endfunction
  private function onInit takes nothing returns nothing
      local trigger t=CreateTrigger()
      local integer int=BJ_MAX_PLAYERS+1
        loop
          set int=int-1
          call TriggerRegisterPlayerUnitEvent(t,Player(int),EVENT_PLAYER_UNIT_DEATH,null)
          exitwhen lint==0
        endloop    
      call TriggerAddAction(t,function Action)
      set t=null
  endfunction
 endlibrary


Untested, of course.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top