NeuroToxin
New Member
- Reaction score
- 46
Okay, so in my ability, Execute, heres what i have before I describe any further.
Learn Execution - [E] [Level %d].
When the warrior is attacked, and the attack brings him below 10% health, he will jump behind the target and perform an execution, dealing a percent of the targets max hp in damage, if the target has less health than him, he will kill it.
Level 1 - Deals 5% max hp
Level 2 - Deals 7% max hp
Level 3 - Deals 9% max hp
Level 4 - Deals 11% max hp
The problems are as follows.
1. I want the unit to go behind the unit (Sort of) which would mean using the angle from the caster to the unit, and if you'll look at ax2 and ay2, I tried doing that, however, it just messes up in that.
2. Also, I used a parabola in one of my other spells, and for some reason, it works sometimes, but not all the time.
3. I really want to use this spell, but I need ideas as to what I can do so that its not overpowered.
Learn Execution - [E] [Level %d].
When the warrior is attacked, and the attack brings him below 10% health, he will jump behind the target and perform an execution, dealing a percent of the targets max hp in damage, if the target has less health than him, he will kill it.
Level 1 - Deals 5% max hp
Level 2 - Deals 7% max hp
Level 3 - Deals 9% max hp
Level 4 - Deals 11% max hp
The problems are as follows.
1. I want the unit to go behind the unit (Sort of) which would mean using the angle from the caster to the unit, and if you'll look at ax2 and ay2, I tried doing that, however, it just messes up in that.
2. Also, I used a parabola in one of my other spells, and for some reason, it works sometimes, but not all the time.
3. I really want to use this spell, but I need ideas as to what I can do so that its not overpowered.
JASS:
scope Execute initializer Init
globals
//The spell ID of the passive ability Execution, press Control + D to get it.
private constant integer SPELLID = 039;A005039;
//The ability ID for Crow Form, should not need changing.
private constant integer CROW_FORM = 039;Arav039;
//The effect played when a unit is executed rather than percent of hp
private constant string EXECUTE_EFFECT = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl"
//The effect played when a target is taken a percent of his hp, rather than executed
private constant string HIT_EFFECT = "Abilities\\Spells\\Orc\\FeralSpirit\\feralspirittarget.mdl"
//The effect attached to the caster
private constant string CASTER_ATTACHMENT = "Abilities\\Weapons\\PhoenixMissile\\Phoenix_Missile_mini.mdl"
//The offset per TINTERVAL.
private constant real OFFSET = 20
//The timer interval for the moving
private constant real TINTERVAL = 0.03125
//The attachment point for everything
private constant string ATTACH_POINT = "origin"
endglobals
//THIS DAMAGE IS A PERCENT OF THEIR MAX LIFE!
private function DAMAGE takes integer lvl returns real
return .03 + (lvl * .02)
endfunction
//Credits to AceHart for the Parabola function.
private function GetParabolaZ takes real x, real dist, real height returns real
return 4.*height*x*(dist-x)/(dist*dist)
endfunction
globals
private hashtable h = InitHashtable()
endglobals
private function MoveDamage takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer hand = GetHandleId(t)
local unit attacked = LoadUnitHandle( h, hand, 0)
local unit attacker = LoadUnitHandle( h, hand, 1)
local real ax = GetUnitX(attacked)
local real ay = GetUnitY(attacked)
local real ax1 = GetUnitX(attacker)
local real ay1 = GetUnitY(attacker)
local real angle = Atan2(ay1 - ay, ax1 - ax)
local real ax2 = ax1 + 50 * Cos(angle)
local real ay2 = ay1 + 50 * Sin(angle)
local real dx = ax1 - ax
local real dy = ay1 - ay
local real dist = SquareRoot(dx * dx + dy * dy)
local real offsetx
local real offsety
local real dam
local real a = LoadReal( h, hand, 3)
if dist >= 50 then
set offsetx = ax + OFFSET * Cos(angle)
set offsety = ay + OFFSET * Sin(angle)
call SetUnitX( attacked, offsetx)
call SetUnitY( attacked, offsety)
call SetUnitFacing( attacked, angle * bj_RADTODEG)
call SetUnitFlyHeight( attacked, GetParabolaZ(a, dist, 400), 0)
call SaveReal( h, hand, 3, a - OFFSET)
else
set dam = DAMAGE(GetUnitAbilityLevel(attacked, SPELLID))
call DestroyEffect(LoadEffectHandle(h, hand, 2))
call UnitRemoveAbility( attacked, CROW_FORM)
call SetUnitFacing( attacked, angle + 180)
call SetWidgetLife( attacked, GetWidgetLife(attacked) * .5)
if GetWidgetLife(attacker) < GetWidgetLife(attacked) then
call KillUnit( attacker)
call DestroyEffect(AddSpecialEffectTarget( EXECUTE_EFFECT, attacker, ATTACH_POINT))
else
call SetWidgetLife( attacker, GetWidgetLife(attacker) - (GetUnitState(attacker, UNIT_STATE_MAX_LIFE) * dam))
call DestroyEffect(AddSpecialEffectTarget( HIT_EFFECT, attacker, ATTACH_POINT))
endif
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable( h, hand)
endif
endfunction
private function OnAttack takes nothing returns boolean
local unit attacker
local unit attacked
local real percenthp
local timer t
local effect e
local integer hand
local boolean bool1 = (GetUnitAbilityLevel(GetTriggerUnit(), SPELLID) > 0)
local real dx
local real dy
local real a
if bool1 then
set attacker = GetAttacker()
set attacked = GetTriggerUnit()
set percenthp = (GetUnitState( attacked, UNIT_STATE_MAX_LIFE) * .1)
if percenthp > GetWidgetLife(attacked) then
set t = CreateTimer()
set hand = GetHandleId(t)
set dx = GetUnitX(attacker) - GetUnitX(attacked)
set dy = GetUnitY(attacker) - GetUnitY(attacked)
set a = SquareRoot(dx * dx + dy * dy)
call SaveReal( h, hand, 3, a)
call SaveUnitHandle( h, hand, 0, attacked)
call SaveUnitHandle( h, hand, 1, attacker)
set e = AddSpecialEffectTarget( CASTER_ATTACHMENT, attacked, ATTACH_POINT)
call SaveEffectHandle( h, hand, 2, e)
call UnitAddAbility( attacked, CROW_FORM)
call TimerStart( t, TINTERVAL, true, function MoveDamage)
endif
endif
return true
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_ATTACKED)
call TriggerAddCondition( t, Condition(function OnAttack) )
endfunction
endscope