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

Creeps Respawn System v1.01b

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
This is a Creeps Respawn System, like there is so many others.

As his name say: It ''ressurect'' neutrals monsters when they die.

Explanation of the ''ressurection'': When an unit DECAY and not die, the system create an unselectionnable shadow of the unit, which will became more and more visible and brighter.
when the shadow become enought bright, she is replaced with a creeps like herself which can be attacked and killed.

There is just a small problem, because when units decay, their facing seems to always be 0.00 (or 360.00 but it's same) so, the units will always look in the same direction. This is not so important but I said it so, you won't be suprized.

There is a GUI version and a vJass version, because i'm learning it so making this system was a good practice.

Here are the codes:

  • Creeps respawn system GUI Config
    • Evénements
      • Map initialization
    • Conditions
    • Actions
      • -------- the timer before the unit respawns equal to Base_Config + Level_Configxlevel of the unit --------
      • Set CR_Respawn_Time_Level_Config = 5.00
      • Set CR_Respawn_Time_Base_Config = 10.00
      • -------- the effect created when the unit respawn --------
      • Set CR_Respawn_Effect = Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
  • Creeps respawn system GUI Ondeath
    • Evénements
      • Unité - A unit owned by Neutre Hostile Pourrit
    • Conditions
    • Actions
      • Set CR_Count1 = (CR_Count1 + 1)
      • Set CR_Point = (Position of (Decaying unit))
      • Set CR_Vertex[CR_Count1] = 0.00
      • Set CR_Transparency[CR_Count1] = 100.00
      • Set CR_Respawn_Time[CR_Count1] = (CR_Respawn_Time_Base_Config + (CR_Respawn_Time_Level_Config x (Real((Level of (Decaying unit))))))
      • Set CR_Vertex_Increase[CR_Count1] = ((100.00 / CR_Respawn_Time[CR_Count1]) x 0.03)
      • Unité - Create 1 (Unit-type of (Decaying unit)) for Neutre Hostile at CR_Point facing (Facing of (Decaying unit)) degrees
      • Set CR_Unit[CR_Count1] = (Last created unit)
      • Unité - Remove (Decaying unit) from the game
      • Groupe unité - Add CR_Unit[CR_Count1] to CR_Respawn_Group
      • Custom script: call UnitAddAbility( udg_CR_Unit[udg_CR_Count1], 'Aloc' )
      • Unité - Pause CR_Unit[CR_Count1]
      • Animation - Change CR_Unit[CR_Count1]'s animation speed to 0.00% of its original speed
      • Animation - Change CR_Unit[CR_Count1]'s vertex coloring to (0.00%, 0.00%, 0.00%) with 100.00% transparency
      • Custom script: call RemoveLocation(udg_CR_Point)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • (Number of units in CR_Respawn_Group) Egal à 1
        • Alors - Actions
          • Déclencheur - Turn on Creeps respawn system GUI Loop <gen>
        • Sinon - Actions
  • Creeps respawn system GUI Loop
    • Evénements
      • Temps - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CR_Count2) from 1 to (Number of units in CR_Respawn_Group), do (Actions)
        • Boucle - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • CR_Respawn_Time[CR_Count2] Supérieur à 0.00
            • Alors - Actions
              • Set CR_Respawn_Time[CR_Count2] = (CR_Respawn_Time[CR_Count2] - 0.03)
              • Set CR_Vertex[CR_Count2] = (CR_Vertex[CR_Count2] + CR_Vertex_Increase[CR_Count2])
              • Set CR_Transparency[CR_Count2] = (CR_Transparency[CR_Count2] - CR_Vertex_Increase[CR_Count2])
              • Animation - Change CR_Unit[CR_Count2]'s vertex coloring to (CR_Vertex[CR_Count2]%, CR_Vertex[CR_Count2]%, CR_Vertex[CR_Count2]%) with CR_Transparency[CR_Count2]% transparency
            • Sinon - Actions
              • Groupe unité - Remove CR_Unit[CR_Count2] from CR_Respawn_Group
              • Set CR_Point = (Position of CR_Unit[CR_Count2])
              • Effet spécial - Create a special effect at CR_Point using CR_Respawn_Effect
              • Effet spécial - Destroy (Last created special effect)
              • Custom script: call RemoveLocation(udg_CR_Point)
              • Unité - Replace CR_Unit[CR_Count2] with a (Unit-type of CR_Unit[CR_Count2]) using Le nouveau max. de l'unité life and mana
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • Si - Conditions
                  • (CR_Respawn_Group is empty) Egal à TRUE
                • Alors - Actions
                  • Set CR_Count1 = 0
                  • Déclencheur - Turn off (This trigger)
                • Sinon - Actions
[jass=Jass]scope CRS initializer Initializer

globals

private constant real Respawntime_Base = 10
private constant real Respawntime_Level = 5.00
private constant real Timeout = 0.03
private constant string Effect = "Abilities\\Spells\\Undead\\AnimateDead\\AnimateDeadTarget.mdl"

private group Group = CreateGroup()
private integer Count = 0
private timer Timer

private real array Colors
private real array Vertex
private real array Colors_Increase
private real array Remainingtime
private unit array Unit

endglobals

private function Looping takes nothing returns nothing

local integer c = 1
local real x
local real y
local real angle
local integer unit_type

loop
exitwhen c > CountUnitsInGroup(Group)

if Remainingtime[c] > 0.00 then

set Remainingtime[c] = Remainingtime[c] - Timeout
set Colors[c] = Colors[c] + Colors_Increase[c]
set Vertex[c] = Vertex[c] + Colors_Increase[c]

call SetUnitVertexColor(Unit[c], PercentTo255(Colors[c]), PercentTo255(Colors[c]), PercentTo255(Colors[c]), PercentTo255(0.0+Vertex[c]))

else

call GroupRemoveUnit( Group, Unit[c] )

set x = GetUnitX( Unit[c] )
set y = GetUnitY( Unit[c] )
set angle = GetUnitFacing( Unit[c] )
set unit_type = GetUnitTypeId( Unit[c] )

call DestroyEffect( AddSpecialEffect( Effect, x , y ) )
call RemoveUnit(Unit[c])
call CreateUnit( Player( PLAYER_NEUTRAL_AGGRESSIVE ), unit_type, x, y, angle )

if IsUnitGroupEmptyBJ( Group ) == TRUE then

set Count = 0

call PauseTimer( Timer )

endif

endif
set c = c + 1
endloop

endfunction

private function Dying takes nothing returns nothing

local real x = GetUnitX( GetDecayingUnit() )
local real y = GetUnitY( GetDecayingUnit() )
local integer ut = GetUnitTypeId( GetDecayingUnit() )

call RemoveUnit( GetDecayingUnit() )

set Count = Count + 1
set Unit[Count] = CreateUnit( Player( PLAYER_NEUTRAL_AGGRESSIVE ) , ut, x , y , GetUnitFacing( GetDyingUnit() ) )

call UnitAddAbility( Unit[Count], 'Aloc' )
call PauseUnit( Unit[Count], true )

set Colors[Count] = 0.00
set Vertex[Count] = 0.00
set Remainingtime[Count] = Respawntime_Base + (Respawntime_Level * (GetUnitLevel( Unit[Count] ) ) )
set Colors_Increase[Count] = (100 / Remainingtime[Count]) * Timeout

call SetUnitVertexColor( Unit[Count], PercentTo255(0.00), PercentTo255(0.00), PercentTo255(0.00), PercentTo255(0.00) )
call GroupAddUnit( Group, Unit[Count] )

if CountUnitsInGroup( Group ) == 1 then

call TimerStart( Timer, Timeout, true, function Looping )

endif

endfunction

private function Initializer takes nothing returns nothing

local trigger Ondeath = CreateTrigger( )

set Timer = CreateTimer( )

call TriggerRegisterPlayerUnitEvent( Ondeath, Player(PLAYER_NEUTRAL_AGGRESSIVE) ,EVENT_PLAYER_UNIT_DECAY, null )
call TriggerAddAction( Ondeath, function Dying )

endfunction

endscope[/code]


sorry for my bad english and for the unreadable GUI code, it's because I'm french, so if someone could post the english version of the GUI code it would be great.

-v1.01: Uploaded the system
-v1.01b: fixed somes BJs and minors leaks


Keywords:
Creeps, Ressurect, Respawn, Shadow, Demon, Lord_Demon_X, X, Lord, Unicorns
Contents

C.R.S v1.01b (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. Creeps Respawn System v1.01b | Reviewed by Maker | 27th Mar 2013 NEEDS FIX Get rid of the bj (red coloured) functions in the vjass version The system doesn't revive...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.


Creeps Respawn System v1.01b | Reviewed by Maker | 27th Mar 2013
NEEDS FIX


126248-albums6177-picture66522.png


  • Get rid of the bj (red coloured) functions in the vjass version
  • The system doesn't revive units properly, I killed
    the units in the test map and it only revied three of them
  • Creating a unit always leaks. Instead of replacing the unit,
    remove locust, add bear form, order to use bear form, remove bear form,
    hide unit, show unit. Use metamorphosis instead of bear form if
    the unit is a hero
  • Use better indexing
126248-albums6177-picture66524.png
[tr]
 
Level 20
Joined
Jun 27, 2011
Messages
1,864
Well you can just use Reincarnation and set its delay to the number that you want and cd to 0, then voila: a creep respawn system ^^. Anyway, your system looks nice, and i guess i saw a point leak at " Creeps respawn system GUI Ondeath" trigger.

P.S Your image preview at the description isn't working.
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • You should use dynamic indexing, the current indexing loops through inactive instances
  • You create an extra unit for each dying unit, units always leak so you should avoid that
  • Get rid of the bj functions in the vjass version

Personally I'm not a fan of the unit fading in.
 
Level 4
Joined
Nov 13, 2012
Messages
28
Well you can just use Reincarnation and set its delay to the number that you want and cd to 0, then voila: a creep respawn system ^^. Anyway, your system looks nice, and i guess i saw a point leak at " Creeps respawn system GUI Ondeath" trigger.

P.S Your image preview at the description isn't working.

For the image preview, I don't know why this isn't working.

Yeah you're right, there is a point that leak in the Ondeath GUI trigger.
 
Top