• 🏆 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!

Rebirth System

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: deepstrasz
This is a system I made when playing around with structs. Once a unit dies, a dummy is spawned at his location. If the dummy isn't killed, the original unit will be revived after X seconds.

For League of Legends players it's like an Anivia passive.



JASS:
struct List
    integer size = 0
    integer array data[99]
    
    public static method create takes nothing returns List
        local thistype this = thistype.allocate()
        return this
    endmethod
    
    public method Add takes integer i returns nothing
        set data[size] = i
        set size = size + 1
    endmethod
    
    public method Remove takes integer id returns nothing
        local integer i = 0
        local integer j = 0
        loop
            exitwhen i >= size
            if data[i] == id then
				set j = i
                loop
                    exitwhen j >= size
                    set data[j] = data[j + 1]
                    set j = j + 1
                endloop
            set size = size - 1
			set j = 0
            set i = size + 1 
            endif
            set i = i + 1
        endloop
    endmethod
endstruct

JASS:
globals
	List instances
	integer debugCounter = 0
endglobals

struct Rebirth
	static constant integer DUMMY_TYPE = 'h000'
	static constant real DUMMY_DURATION = 5
	static constant string respawnEffect = "Abilities\\Spells\\Items\\AIsm\\AIsmTarget.mdl"
	
	integer u
	unit deadUnit
	location l
	real counter
	unit egg
	
	
	static method onInit takes nothing returns nothing
		set instances = List.create()
	endmethod
	
	static method create takes unit u returns thistype
		local thistype this = thistype.allocate()
		set this.u = GetUnitTypeId(u)
		set this.counter = 0
		set this.deadUnit = u
		set this.l = GetUnitLoc(u)
		set this.egg = CreateUnitAtLoc(GetOwningPlayer(u), DUMMY_TYPE, this.l, 0)
		call instances.Add(this)
		return this
	endmethod
	
	method destroy takes nothing returns nothing
		set this.u = 0
		call RemoveLocation(this.l)
		call instances.Remove(this)
		call this.deallocate()
	endmethod
	
	method Update takes nothing returns nothing
		set debugCounter = debugCounter + 1
		set this.counter = this.counter + 0.03
		if this.counter > DUMMY_DURATION then
			call KillUnit(this.egg)
			call AddSpecialEffectLoc(respawnEffect, this.l)
			if IsUnitIdType(this.u, UNIT_TYPE_HERO) == false then
				call CreateUnitAtLoc(Player(0), this.u, this.l, 0)
				call this.destroy()
			else
				call ReviveHeroLoc(this.deadUnit, this.l, false)
				call this.destroy()
			endif
		endif
	endmethod
endstruct
  • update
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Custom script: local integer i = instances.size
      • Custom script: loop
      • Custom script: exitwhen i == 0
      • Custom script: set i = i - 1
      • Custom script: call Rebirth( instances.data[i]).Update()
      • Custom script: endloop





Keywords:
rebirth, respawn, system, MUI, Chaosy
Contents

Just another Warcraft III map (Map)

Reviews
15th Feb 2015 IcemanBo: map is updateable again. 04:42, 1st Mar 2015 Maker: The code is not acceptable.

Moderator

M

Moderator

15th Feb 2015
IcemanBo: map is updateable again.

04:42, 1st Mar 2015
Maker: The code is not acceptable.
 
Top