System Creep Revival

TheDeadFight

New Member
Reaction score
1
I hope useful :D

in GUI :

Trigger:
  • Revive
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Owner of (Triggering unit)) Equal to Neutral Hostile) and (((Triggering unit) is Summoned) Not equal to True)
    • Actions
      • Custom script: local string udg_CreepType
      • Custom script: local location udg_CreepPoss
      • Custom script: set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetDyingUnit()))
      • Custom script: set udg_CreepPoss = GetUnitLoc(GetDyingUnit())
      • Set CreepPoss = (Position of (Dying unit))
      • Wait 10.00 game-time seconds
      • Unit - Create 1 (Unit-type(CreepType)) for Neutral Hostile at CreepPoss facing (Random angle) degrees
      • Set CreepType = <Empty String>
      • Custom script: call RemoveLocation(udg_CreepPoss)


in JASS :

create both of this variable :
Code:
Variable Name		Variable Type

CreepPoss			Point
CreepType			String
JASS:
function Trig_Revive_Func006001 takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction

function Trig_Revive_Func006002 takes nothing returns boolean
    return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) != true )
endfunction

function Trig_Revive_Conditions takes nothing returns boolean
    if ( not GetBooleanAnd( Trig_Revive_Func006001(), Trig_Revive_Func006002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Revive_Actions takes nothing returns nothing
    local string udg_CreepType
    local location udg_CreepPoss
    set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetDyingUnit()))
    set udg_CreepPoss = GetUnitLoc(GetDyingUnit())
    set udg_CreepPoss = GetUnitLoc(GetDyingUnit())
    call PolledWait( 10.00 )
    call CreateNUnitsAtLoc( 1, String2UnitIdBJ(udg_CreepType), Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_CreepPoss, GetRandomDirectionDeg() )
    set udg_CreepType = ""
    call RemoveLocation(udg_CreepPoss)
endfunction

//===========================================================================
function InitTrig_Revive takes nothing returns nothing
    set gg_trg_Revive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Revive, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Revive, Condition( function Trig_Revive_Conditions ) )
    call TriggerAddAction( gg_trg_Revive, function Trig_Revive_Actions )
endfunction
 

Laiev

Hey Listen!!
Reaction score
188
You don't need to get GUI version and convert it to jass just to give a jass version :nuts:


1 - why you create globals variable to use in locals?

2 - [ljass]set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetDyingUnit()))[/ljass]
[ljass]set udg_CreepPoss = GetUnitLoc(GetTriggerUnit())[/ljass]
Set CreepPoss = (Position of (Dying unit))

to

[ljass]set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetTriggerUnit()))[/ljass]
[ljass]set udg_CreepPoss = GetUnitLoc(GetTriggerUnit())[/ljass]
Set CreepPoss = (Position of (Triggering Unit))


3 - If you make a jass version, use coordination instead location
 

Chaos_Knight

New Member
Reaction score
39
You don't need to get GUI version and convert it to jass just to give a jass version :nuts:


1 - why you create globals variable to use in locals?

2 - [ljass]set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetDyingUnit()))[/ljass]
[ljass]set udg_CreepPoss = GetUnitLoc(GetTriggerUnit())[/ljass]
Set CreepPoss = (Position of (Dying unit))

to

[ljass]set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetTriggerUnit()))[/ljass]
[ljass]set udg_CreepPoss = GetUnitLoc(GetTriggerUnit())[/ljass]
Set CreepPoss = (Position of (Triggering Unit))


3 - If you make a jass version, use coordination instead location


I think it's to many BJs. As Laiev said, no mean to convert to JASS. It doesnt because it becomes JASS. Not "good" JASS. Because of all the BJs. I didnt like this. :(
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
Your JASS version is just a converted GUI to JASS with no touching.

JASS:
function Trig_Revive_Func006001 takes nothing returns boolean
    return ( GetOwningPlayer(GetTriggerUnit()) == Player(PLAYER_NEUTRAL_AGGRESSIVE) )
endfunction

function Trig_Revive_Func006002 takes nothing returns boolean
    return ( IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) != true )
endfunction

function Trig_Revive_Conditions takes nothing returns boolean
    if ( not GetBooleanAnd( Trig_Revive_Func006001(), Trig_Revive_Func006002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Revive_Actions takes nothing returns nothing
    local string udg_CreepType
    local location udg_CreepPoss
    set udg_CreepType = UnitId2StringBJ(GetUnitTypeId(GetDyingUnit()))
    set udg_CreepPoss = GetUnitLoc(GetDyingUnit())
    set udg_CreepPoss = GetUnitLoc(GetDyingUnit())
    call PolledWait( 10.00 )
    call CreateNUnitsAtLoc( 1, String2UnitIdBJ(udg_CreepType), Player(PLAYER_NEUTRAL_AGGRESSIVE), udg_CreepPoss, GetRandomDirectionDeg() )
    set udg_CreepType = ""
    call RemoveLocation(udg_CreepPoss)
endfunction

//===========================================================================
function InitTrig_Revive takes nothing returns nothing
    set gg_trg_Revive = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Revive, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddCondition( gg_trg_Revive, Condition( function Trig_Revive_Conditions ) )
    call TriggerAddAction( gg_trg_Revive, function Trig_Revive_Actions )
endfunction


This one will be better
No need for any requirement variables stuff.

JASS:
scope Revive initializer I
    globals
        private constant player OWNER = Player(PLAYER_NEUTRAL_AGGRESSIVE) //~Owner of dying unit

        private constant real   TIME  = 5.0 //~Time until the creep revives
    endglobals

    private function C takes nothing returns boolean
        return GetOwningPlayer(GetTriggerUnit()) == OWNER and IsUnitType(GetTriggerUnit(), UNIT_TYPE_SUMMONED) != true
    endfunction

    private function A takes nothing returns nothing
        local unit u = GetDyingUnit()
        local real x = GetUnitX(u)
        local real y = GetUnitY(u)
        local integer i = GetUnitTypeId(GetDyingUnit())

        call TriggerSleepAction(TIME)
        call CreateUnit(OWNER,i,x,y,GetRandomInt(0,360))

        set u = null
    endfunction

    //===========================================================================
    private function I takes nothing returns nothing
        local trigger g = CreateTrigger()
        local integer i = 0
        loop
            call TriggerRegisterPlayerUnitEvent(g,Player(i),EVENT_PLAYER_UNIT_DEATH,null)
            set i = i+1
            exitwhen i == bj_MAX_PLAYER_SLOTS
        endloop
        call TriggerAddCondition(g,Condition(function C))
        call TriggerAddAction(g,function A)
        set g = null
    endfunction
endscope
 

Nherwyziant

Be better than you were yesterday :D
Reaction score
96
I didn't notice [ljass]GetUnitTypeId(GetDyingUnit())[/ljass]^_^. Since I made that integer first before the unit. ^^

EDIT: and just replace getdyng with GetTriggerUnit()
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Here's an even better version, without a wait :D

JASS:
scope CreepRevive initializer Init

    globals
        private constant player REVIVE_OWNER = Player( 12 ) // This is &quot;Neutral Hostile&quot; <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink    ;)" loading="lazy" data-shortname=";)" />
        private constant real REVIVE_TIME = 10.
        
        private hashtable ReviveHash
    endglobals
    
    private struct ReviveData
        unit u
        
        real x
        real y
        
        integer id
        
        static method create takes unit u returns thistype
            local thistype this = thistype.allocate()
            local timer t
            
            set this.u = u
            set this.x = GetUnitX( u )
            set this.y = GetUnitY( u )
            set this.id = GetUnitTypeId( u )
            
            static if LIBRARY_TimerUtils then
                set t = NewTimer()
                
                call SetTimerData( t, this )
            else
                set t = CreateTimer()
                
                call SaveInteger( ReviveHash, GetHandleId( t ), 0, this )
            endif
            
            call TimerStart( t, REVIVE_TIME, false, function thistype.Revive )
            
            return this
        endmethod
        
        private static method Revive takes nothing returns nothing
            local thistype this
            local timer t = GetExpiredTimer()
            
            static if LIBRARY_TimerUtils then
                set this = GetTimerData( t )
                
                call ReleaseTimer( t )
            else
                set this = LoadInteger( ReviveHash, GetHandleId( t ), 0 )
                
                call PauseTimer( t )
                call DestroyTimer( t )
            endif
            
            call CreateUnit( REVIVE_OWNER, this.id, this.x, this.y, GetRandomReal( 0., 360. ) )
            
            call this.destroy()
            
            set t = null
        endmethod
        
    endstruct

    private function Conditions takes nothing returns boolean
        return IsUnitType( GetTriggerUnit(), UNIT_TYPE_SUMMONED ) != true and IsUnitType( GetTriggerUnit(), UNIT_TYPE_STRUCTURE ) != true
    endfunction

    private function Actions takes nothing returns nothing
        local unit u = GetTriggerUnit()
        
        call ReviveData.create( u )
        
        set u = null
    endfunction

//===========================================================================
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        local integer i = 0
        
        call TriggerRegisterPlayerUnitEvent( t, REVIVE_OWNER, EVENT_PLAYER_UNIT_DEATH, null )
    
        call TriggerAddCondition( t, Condition( function Conditions ) )
        call TriggerAddAction( t, function Actions )
        
        set ReviveHash = InitHashtable()
    endfunction
    
endscope


Though you really should try to instead save the creeps positions when they enter the map (Or if they are pre-placed, save it at map init :D) as if a creeps follows you around the map, and you kill it, it shouldn't appear there, but where he started running after you ;)

I'll try to work something up ;)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      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