- Joined
- Feb 3, 2009
- Messages
- 3,292
Hello, I'd like to request a leak check on the bellow spell.
It needs to be completely leak free as it's used a lot in the map.
It needs to be completely leak free as it's used a lot in the map.
JASS:
scope Combo initializer InitTrig_Illusion_Slash
// SETTINGS
globals
private constant integer dummy_id = 'h00R' // the ID of the dummy unit
private constant integer spell_id = 'A006' // the ID of the spell
private constant real anim_delay = 1.00 // the delay before the dummy dies
private constant integer red = 100 // the color red of the dummy
private constant integer green = 100 // the color green of the dummy
private constant integer blue = 100 // the color blue of the dummy
private constant integer alpha = 75 // the color transparency of the dummy
private constant integer red_c = 255 // the color red of the caster
private constant integer green_c = 255 // the color green of the caster
private constant integer blue_c = 255 // the color blue of the caster
private constant integer alpha_c = 100 // the color transparency of the caster
private constant real tag_red = 100 // the text tag color : red
private constant real tag_green = 10 // the text tag color : green
private constant real tag_blue = 10 // the text tag color : blue
private constant string animation = "slam" // the animation the dummy will play
private constant boolean attack = true // is the spell a attack?
private constant boolean ranged = false // is the spell ranged?
private constant attacktype atk_type = ATTACK_TYPE_CHAOS // the attack type of the dummy damage
private constant damagetype dmg_type = DAMAGE_TYPE_NORMAL // the damage type of the dummy damage
private constant weapontype wep_type = WEAPON_TYPE_WHOKNOWS // the weapon type of the dummy damage
private constant boolean enable_texttag = true // if set to true, it will show the damage dealt by the dummy
private constant string special_effect = "Abilities\\Spells\\Orc\\MirrorImage\\MirrorImageCaster.mdl"
private constant string attachment_point = "origin" // this is where the above special effect is placed
private real array extra_damage // set the extra damage bellow in function Settings
private integer array chance // set the chance bellow in function Settings
endglobals
function Settings takes nothing returns nothing
// set the chances:
set chance[1] = 20
set chance[2] = 25
set chance[3] = 30
set chance[4] = 35
// set the extra damage values
set extra_damage[1] = 25
set extra_damage[2] = 50
set extra_damage[3] = 75
set extra_damage[4] = 100
endfunction
// END OF SETTINGS
private function Conditions takes nothing returns boolean
return GetUnitAbilityLevel(GetAttacker(), spell_id ) >= 1
endfunction
private function Actions takes nothing returns nothing
local unit u = GetAttacker()
local unit t = GetTriggerUnit()
local unit dummy
local integer lvl = GetUnitAbilityLevel(u , spell_id)
local real dmg = extra_damage[lvl]
local real angle = GetUnitFacing(t) + 180
local player owner = GetOwningPlayer(u)
local location l = GetUnitLoc(u)
local location l2
local integer ch = GetRandomInt(1 , 100)
local texttag text
local real pos = 60.
local effect eff
if t == u then
set u = null
set t = null
set dummy = null
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
return
else
// We call the chance function
call Settings()
if chance[lvl] >= ch then
set eff = AddSpecialEffectTarget(special_effect , u , attachment_point)
call SetUnitVertexColor(u, red_c , green_c, blue_c, alpha_c)
set dummy = CreateUnitAtLoc(owner, dummy_id , l , angle)
set l2 = GetUnitLoc(dummy)
call PauseUnit(dummy, true)
call SetUnitVertexColor(dummy , red , green, blue, alpha)
call SetUnitAnimation(dummy , animation)
if enable_texttag == true then
set text = CreateTextTagLocBJ( R2S(dmg)+"!" , l2, pos, 12, tag_red, tag_green, tag_blue, 0 )
call SetTextTagVelocityBJ( text, 60.00, 90 )
call SetTextTagPermanent( text, false )
call SetTextTagLifespan( text, 1)
call SetTextTagFadepoint( text, 0.1)
endif
call TriggerSleepAction(anim_delay)
call UnitDamageTarget(u, t, dmg, attack, ranged, atk_type , dmg_type , wep_type)
call RemoveUnit(dummy)
call DestroyEffect(eff)
call SetUnitVertexColor(u, 255 , 255, 255, 255)
endif
set u = null
set t = null
set dummy = null
call RemoveLocation(l)
call RemoveLocation(l2)
set l = null
set l2 = null
endif
endfunction
//===========================================================================
private function InitTrig_Illusion_Slash takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
endfunction
endscope
Last edited: