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.
  • Varine Varine:
    I ordered like five blocks for 15 dollars. They're just little aluminum blocks with holes drilled into them
  • Varine Varine:
    They are pretty much disposable. I have shitty nozzles though, and I don't think these were designed for how hot I've run them
  • Varine Varine:
    I tried to extract it but the thing is pretty stuck. Idk what else I can use this for
  • Varine Varine:
    I'll throw it into my scrap stuff box, I'm sure can be used for something
  • Varine Varine:
    I have spare parts for like, everything BUT that block lol. Oh well, I'll print this shit next week I guess. Hopefully it fits
  • Varine Varine:
    I see that, despite your insistence to the contrary, we are becoming a recipe website
  • Varine Varine:
    Which is unique I guess.
  • The Helper The Helper:
    Actually I was just playing with having some kind of mention of the food forum and recipes on the main page to test and see if it would engage some of those people to post something. It is just weird to get so much traffic and no engagement
  • The Helper The Helper:
    So what it really is me trying to implement some kind of better site navigation not change the whole theme of the site
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top