- Joined
- Mar 10, 2009
- Messages
- 5,014
I have this code and it works just fine...
But I have some few questions...
1. is there any way to shorten the "If randomizer blahhh and blahhh and blahhh..."
2. Can I use "filterfunc >>> Filter>>>Condition" for this? coz I've tried and I got an error...pls show me how to do it correctly...
3. I did this before and its not functioning well, why?...
But I have some few questions...
JASS:
function Doppel takes nothing returns nothing
local unit Attacked = GetTriggerUnit()
local unit Attacker = GetAttacker()
local unit Doppelganger
local integer randomizer = GetRandomInt(1,100)
local integer abilityID = 'AHab' // <<< Can be customized
local integer abilitylevel = GetUnitAbilityLevel(Attacked, abilityID)
local integer castok = 5 * abilitylevel
local string SFX = "Abilities\\Spells\\Demon\\DarkPortal\\DarkPortalTarget.mdl"
if randomizer <= castok and GetUnitAbilityLevel(Attacked, abilityID) >= 0 and IsUnitEnemy(Attacker, GetOwningPlayer(Attacked)) and IsUnitType(Attacked, UNIT_TYPE_HERO) then
call DisplayTextToPlayer(Player(0), 0, 0, I2S(castok))
set Doppelganger = CreateUnit(GetOwningPlayer(Attacked), GetUnitTypeId(Attacker), GetUnitX(Attacker), GetUnitY(Attacker), 0)
call DestroyEffect(AddSpecialEffect(SFX, GetUnitX(Doppelganger), GetUnitY(Doppelganger)))
call UnitApplyTimedLife(Doppelganger, 'BTLF', 15.0)
endif
set Attacked = null
set Attacker = null
set Doppelganger = null
endfunction
//==== Init Trigger Doppelganger ====
function InitTrig_Doppelganger takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ (t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddAction (t, function Doppel)
set t = null
endfunction
2. Can I use "filterfunc >>> Filter>>>Condition" for this? coz I've tried and I got an error...pls show me how to do it correctly...
3. I did this before and its not functioning well, why?...
JASS:
if randomizer <= castok and abilitylevel >= 0 .........