Name | Type | is_array | initial_value |
CR_Count1 | integer | No | |
CR_Count2 | integer | No | |
CR_Point | location | No | |
CR_Respawn_Effect | string | No | |
CR_Respawn_Group | group | No | |
CR_Respawn_Time | real | Yes | |
CR_Respawn_Time_Base_Config | real | No | |
CR_Respawn_Time_Level_Config | real | No | |
CR_Transparency | real | Yes | |
CR_Unit | unit | Yes | |
CR_Vertex | real | Yes | |
CR_Vertex_Increase | real | Yes |
//TESH.scrollpos=1
//TESH.alwaysfold=0
//C.R.S BY Lord_Demon_X, AKA Qzarch, AKA Ectelion//
//this is one of the most
//simple creeps respawn system
//It not contain very much feature
//But it can be implented easily
//in any map, the vJass and GUI
//versions are very similar so you
//can use this to move to (v)Jass from GUI
//HOW TO IMPORT THE GUI VERSION:
//Check the "create new variables" in your preference panel
//Copy-paste the folder into your map
//Enjoy your new C.R.S
//HOW TO IMPORT THE VJASS VERSION
//Just copy-paste the trigger into your map
//TESH.scrollpos=0
//TESH.alwaysfold=0
/* This is the C.R.S (Creeps Respawn System)
A very basic system that allow you to easily respawns neutrals monsters
when they are killed, it create a shade of the monster with transparency
and no colors, as the time pass, the shadow gain colors and become more solid
when it reach a totaly solid form it became a "ressurection" of the dead unit.
*/
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