• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Import] Respawn System by mckill

Status
Not open for further replies.
Level 13
Joined
Aug 4, 2012
Messages
1,022
http://www.hiveworkshop.com/forums/...-zinc-238822/?prev=search=respawn&d=list&r=20

What I want:
1. Revive hero with the timer (4 * hero level)
2. Respawn Neutral Creeps (Specified Force) with the timer of 60 seconds

Here's my code:
JASS:
scope Revive initializer Timer
    function Go takes nothing returns nothing
        call RespawnSystem.registerEx(GetEnumUnit(), I2R(GetHeroLevel(GetEnumUnit())) * 4, "", GetOwningPlayer(GetEnumUnit()))
        call DisplayTextToPlayer(Player(0), 10, 10, R2S(I2R(GetHeroLevel(GetEnumUnit())) * 4))
    endfunction
    function Detect takes nothing returns nothing
        call ForGroupBJ(GetUnitsInRectAll(GetPlayableMapRect()), function Go)
    endfunction
    function Timer takes nothing returns nothing
        local trigger THIS = CreateTrigger()
        call TriggerRegisterTimerEventSingle(THIS, 1.00)
        call TriggerAddAction(THIS, function Detect)
    endfunction
endscope
 
The red colors, I thought they have their substitutes?

[call RespawnSystem.registerEx(GetEnumUnit(), I2R(GetHeroLevel(GetEnumUnit())) * 4, "", GetOwningPlayer(GetEnumUnit()))
This will fail with units.

Do a check wether picked unit is hero or not and set the timer appropriately. The current approach is flawed with units.
 
Level 13
Joined
Aug 4, 2012
Messages
1,022
The red colors, I thought they have their substitutes?

[call RespawnSystem.registerEx(GetEnumUnit(), I2R(GetHeroLevel(GetEnumUnit())) * 4, "", GetOwningPlayer(GetEnumUnit()))
This will fail with units.

Do a check wether picked unit is hero or not and set the timer appropriately. The current approach is flawed with units.

I don't understand it, those level are too high for me :/ :/
 
JASS:
scope Revive initializer Timer
    function Go takes nothing returns nothing
        if IsUnitHero(GetEnumUnit()) then    
          call RespawnSystem.registerEx(GetEnumUnit(), GetHeroLevel(GetEnumUnit()) * 4, "", GetOwningPlayer(GetEnumUnit()))
        else
          call RespawnSystem.registerEx(GetEnumUnit(), 60, "", GetOwningPlayer(GetEnumUnit())) 
        call DisplayTextToPlayer(Player(0), 10, 10, R2S(I2R(GetHeroLevel(GetEnumUnit())) * 4))
    endfunction
    function Detect takes nothing returns nothing
        call ForGroupBJ(GetUnitsInRectAll(GetPlayableMapRect()), function Go)
    endfunction
    function Timer takes nothing returns nothing
        local trigger THIS = CreateTrigger()
        call TriggerRegisterTimerEventSingle(THIS, 1.00)
        call TriggerAddAction(THIS, function Detect)
    endfunction
endscope

I guess this will work with both targets you want it to do.
Be noted it's sort of copy-paste from yours with the fix and it's pseudocode, so it might not compile properly.

Unless I'm mistaken, this should solve the problem. If not, specify the problems.
 
Level 13
Joined
Aug 4, 2012
Messages
1,022
JASS:
scope Revive initializer Timer
    function Go takes nothing returns nothing
        if IsUnitHero(GetEnumUnit()) then    
          call RespawnSystem.registerEx(GetEnumUnit(), GetHeroLevel(GetEnumUnit()) * 4, "", GetOwningPlayer(GetEnumUnit()))
        else
          call RespawnSystem.registerEx(GetEnumUnit(), 60, "", GetOwningPlayer(GetEnumUnit())) 
        call DisplayTextToPlayer(Player(0), 10, 10, R2S(I2R(GetHeroLevel(GetEnumUnit())) * 4))
    endfunction
    function Detect takes nothing returns nothing
        call ForGroupBJ(GetUnitsInRectAll(GetPlayableMapRect()), function Go)
    endfunction
    function Timer takes nothing returns nothing
        local trigger THIS = CreateTrigger()
        call TriggerRegisterTimerEventSingle(THIS, 1.00)
        call TriggerAddAction(THIS, function Detect)
    endfunction
endscope

I guess this will work with both targets you want it to do.
Be noted it's sort of copy-paste from yours with the fix and it's pseudocode, so it might not compile properly.

Unless I'm mistaken, this should solve the problem. If not, specify the problems.

Alright

EDIT:
Undeclared IsUnitHero, there's no function like that :/ :/
 
Level 13
Joined
Aug 4, 2012
Messages
1,022
Level 13
Joined
Aug 4, 2012
Messages
1,022
TriggerHappy's CreepRespawn System is pretty neat and should solve your problem.

You could actually make the system in GUI as they did in this DotA Template. And to there's this thread from here in The Hive that should be self-explanatory. Note that it revives Heroes only.

I can't import those spell by TriggerHappy's, his UnitDex conflicted with Bribe's UnitIndexer :/ :/
 
Level 13
Joined
Aug 4, 2012
Messages
1,022
Dude, it fixed, I changed Event Timer from Single to Periodic, so it's always check the level of the hero :D :D
JASS:
scope Revive initializer Timer
    function Go takes nothing returns nothing
        if IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) then
            call RespawnSystem.registerEx(GetEnumUnit(), I2R(GetHeroLevel(GetEnumUnit())) * 4, "", GetOwningPlayer(GetEnumUnit()))
        else
            call RespawnSystem.registerEx(GetEnumUnit(), 60, "", GetOwningPlayer(GetEnumUnit()))
        endif
    endfunction
    function Detect takes nothing returns nothing
        call ForGroupBJ(GetUnitsInRectAll(GetPlayableMapRect()), function Go)
    endfunction
    function Timer takes nothing returns nothing
        local trigger THIS = CreateTrigger()
        call TriggerRegisterTimerEventPeriodic(THIS, 0.1) //IS THIS OPTIMAL??
        call TriggerAddAction(THIS, function Detect)
    endfunction
endscope
 
Status
Not open for further replies.
Top