GetTriggerUnit-
DogEntrepreneur
- Reaction score
- 129
Yes, If I want it to be Mui, yes.
Why do you still have
Jass:
= CreateTimer()?
----------
Why is the group still in the struct?
----------
"thunderbolt" still isn't configurable.
private constant string MODEL1 = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" //Model periodic.
private constant string MODEL2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Model at cast and at the end.
private constant string ORDER = "thunderbolt" //The stun order cast
scope PowerRage initializer Init uses CSData
StartTimer
//* set t=NewTimer() : Get a timer (alternative to CreateTimer)
I guess you can;
I just never have.
With TimerUtils you create the timer using the line stated above.
scope PowerRage initializer Init
globals
private constant integer SPELL_ID = 039;A000039; //Id of the spell.
private constant integer DUMMY_ID = 039;h000039; //Id of the dummy.
private constant integer DUMMY_ABILITY_ID = 039;A001039; //Id of the dummy's spell.
private constant integer FLY_ID = 039;Arav039; //What allows the caster to fly.
private constant string MODEL1 = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" //Model periodic.
private constant string MODEL2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Model at cast and at the end.
private constant string ORDER = "thunderbolt" //The stun order cast
private constant real DAMAGE_MULTIPLIER = 75.00 //This amount will be multiplied by the level of the spell.
private constant real OFFSET = 20.00 //The speed of the caster.
private constant real DTS = 25.00 //Distance to stop.
private constant real HEIGHT_MODIFIER = 12.00 //The height multiplier, every time caster move, he's gain the real as height.
private constant attacktype AT = ATTACK_TYPE_NORMAL //Attack type.
private constant damagetype DT = DAMAGE_TYPE_NORMAL //Damage type.
endglobals
//=================================================================================\\
//===============DO NOT TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU DO!==============\\
//=================================================================================\\
globals
private player array P
private integer Index
private unit Dummy
private group Group = CreateGroup()
endglobals
private struct data
integer level
integer change
integer execs
timer t = CreateTimer()
unit caster
real cx
real cy
real lx
real ly
real offset
real angle
real damage
real height
player owner
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function GCond takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), P[Index])
endfunction
private function Callback takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
local real x
local real y
local real dx
local real dy
local unit u
set d.offset = d.offset + OFFSET
set x = d.cx + d.offset * Cos(d.angle * bj_DEGTORAD)
set y = d.cy + d.offset * Sin(d.angle * bj_DEGTORAD)
call SetUnitX(d.caster, x)
call SetUnitY(d.caster, y)
call DestroyEffect(AddSpecialEffect(MODEL1, x, y))
set dx = d.lx - x
set dy = d.ly - y
set d.execs = d.execs + 1
if d.execs < d.change then
set d.height = d.height + HEIGHT_MODIFIER
call SetUnitFlyHeight(d.caster, d.height, 0.00)
elseif d.execs > d.change then
set d.height = d.height - HEIGHT_MODIFIER
call SetUnitFlyHeight(d.caster, d.height, 0.00)
endif
if SquareRoot(dx * dx + dy * dy) <= DTS then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call GroupEnumUnitsInRange(Group, d.lx, d.ly, 200.00, Condition(function GCond))
call DestroyEffect(AddSpecialEffect(MODEL2, d.lx, d.ly))
loop
set u = FirstOfGroup(Group)
exitwhen u == null
set Dummy = CreateUnit(d.owner, DUMMY_ID, d.lx, d.ly, 0.00)
call UnitAddAbility(Dummy, DUMMY_ABILITY_ID)
call SetUnitAbilityLevel(Dummy, DUMMY_ABILITY_ID, d.level)
call GroupRemoveUnit(Group, u)
call IssueTargetOrder(Dummy, ORDER, u)
call UnitApplyTimedLife(Dummy, 039;BTLF039;, 1.00)
call UnitDamageTarget(Dummy, u, d.damage, true, false, AT, DT, WEAPON_TYPE_WHOKNOWS)
endloop
endif
endfunction
private function Main takes nothing returns nothing
local data d = data.create()
local integer i = GetTriggerExecCount(GetTriggeringTrigger())
local location l = GetSpellTargetLoc()
local real range
local real dx
local real dy
set d.caster = GetTriggerUnit()
set Index = i
set P[Index] = GetOwningPlayer(d.caster)
set d.level = GetUnitAbilityLevel(d.caster, SPELL_ID)
set d.cx = GetUnitX(d.caster)
set d.cy = GetUnitY(d.caster)
set d.lx = GetLocationX(l)
set d.ly = GetLocationY(l)
set dx = d.lx - d.cx
set dy = d.ly - d.cy
set range = SquareRoot(dx * dx + dy * dy)
set d.change = R2I(range / OFFSET) / 2
set d.execs = 0
set d.angle = bj_RADTODEG * Atan2( d.ly - d.cy, d.lx - d.cx)
set d.offset = 0.00
set d.damage = DAMAGE_MULTIPLIER * I2R(GetUnitAbilityLevel(d.caster, SPELL_ID))
set d.owner = GetOwningPlayer(d.caster)
call DestroyEffect(AddSpecialEffect(MODEL2, d.cx, d.cy))
call UnitAddAbility(d.caster, FLY_ID)
call UnitRemoveAbility(d.caster, FLY_ID)
call TimerStart( d.t, 0.02, true, function Callback)
call SetTimerData( d.t, d)
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function Cond))
call TriggerAddAction(t,function Main)
endfunction
endscope
What is the error?
scope PowerRage initializer Init
globals
private constant integer SPELL_ID = 039;A000039; //Id of the spell.
private constant integer DUMMY_ID = 039;h000039; //Id of the dummy.
private constant integer DUMMY_ABILITY_ID = 039;A001039; //Id of the dummy's spell.
private constant integer FLY_ID = 039;Arav039; //What allows the caster to fly.
private constant string MODEL1 = "Abilities\\Spells\\Human\\FlakCannons\\FlakTarget.mdl" //Model periodic.
private constant string MODEL2 = "Abilities\\Spells\\Orc\\WarStomp\\WarStompCaster.mdl" //Model at cast and at the end.
private constant string ORDER = "thunderbolt" //The stun order cast
private constant real DAMAGE_MULTIPLIER = 75.00 //This amount will be multiplied by the level of the spell.
private constant real OFFSET = 20.00 //The speed of the caster.
private constant real DTS = 25.00 //Distance to stop.
private constant real HEIGHT_MODIFIER = 12.00 //The height multiplier, every time caster move, he's gain the real as height.
private constant attacktype AT = ATTACK_TYPE_NORMAL //Attack type.
private constant damagetype DT = DAMAGE_TYPE_NORMAL //Damage type.
endglobals
//=================================================================================\\
//===============DO NOT TOUCH BELOW HERE UNLESS YOU KNOW WHAT YOU DO!==============\\
//=================================================================================\\
globals
private player array P
private integer Index
private unit Dummy
private group Group = CreateGroup()
endglobals
private struct data
integer level
integer change
integer execs
timer t = NewTimer()
unit caster
real cx
real cy
real lx
real ly
real offset
real angle
real damage
real height
player owner
endstruct
private function Cond takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function GCond takes nothing returns boolean
return IsUnitEnemy(GetFilterUnit(), P[Index])
endfunction
private function Callback takes nothing returns nothing
local data d = GetTimerData(GetExpiredTimer())
local real x
local real y
local real dx
local real dy
local unit u
set d.offset = d.offset + OFFSET
set x = d.cx + d.offset * Cos(d.angle * bj_DEGTORAD)
set y = d.cy + d.offset * Sin(d.angle * bj_DEGTORAD)
call SetUnitX(d.caster, x)
call SetUnitY(d.caster, y)
call DestroyEffect(AddSpecialEffect(MODEL1, x, y))
set dx = d.lx - x
set dy = d.ly - y
set d.execs = d.execs + 1
if d.execs < d.change then
set d.height = d.height + HEIGHT_MODIFIER
call SetUnitFlyHeight(d.caster, d.height, 0.00)
elseif d.execs > d.change then
set d.height = d.height - HEIGHT_MODIFIER
call SetUnitFlyHeight(d.caster, d.height, 0.00)
endif
if SquareRoot(dx * dx + dy * dy) <= DTS then
call PauseTimer(GetExpiredTimer())
call DestroyTimer(GetExpiredTimer())
call GroupEnumUnitsInRange(Group, d.lx, d.ly, 200.00, Condition(function GCond))
call DestroyEffect(AddSpecialEffect(MODEL2, d.lx, d.ly))
loop
set u = FirstOfGroup(Group)
exitwhen u == null
set Dummy = CreateUnit(d.owner, DUMMY_ID, d.lx, d.ly, 0.00)
call UnitAddAbility(Dummy, DUMMY_ABILITY_ID)
call SetUnitAbilityLevel(Dummy, DUMMY_ABILITY_ID, d.level)
call GroupRemoveUnit(Group, u)
call IssueTargetOrder(Dummy, ORDER, u)
call UnitApplyTimedLife(Dummy, 039;BTLF039;, 1.00)
call UnitDamageTarget(Dummy, u, d.damage, true, false, AT, DT, WEAPON_TYPE_WHOKNOWS)
endloop
endif
endfunction
private function Main takes nothing returns nothing
local data d = data.create()
local integer i = GetTriggerExecCount(GetTriggeringTrigger())
local location l = GetSpellTargetLoc()
local real range
local real dx
local real dy
set d.caster = GetTriggerUnit()
set Index = i
set P[Index] = GetOwningPlayer(d.caster)
set d.level = GetUnitAbilityLevel(d.caster, SPELL_ID)
set d.cx = GetUnitX(d.caster)
set d.cy = GetUnitY(d.caster)
set d.lx = GetLocationX(l)
set d.ly = GetLocationY(l)
set dx = d.lx - d.cx
set dy = d.ly - d.cy
set range = SquareRoot(dx * dx + dy * dy)
set d.change = R2I(range / OFFSET) / 2
set d.execs = 0
set d.angle = bj_RADTODEG * Atan2( d.ly - d.cy, d.lx - d.cx)
set d.offset = 0.00
set d.damage = DAMAGE_MULTIPLIER * I2R(GetUnitAbilityLevel(d.caster, SPELL_ID))
set d.owner = GetOwningPlayer(d.caster)
call DestroyEffect(AddSpecialEffect(MODEL2, d.cx, d.cy))
call UnitAddAbility(d.caster, FLY_ID)
call UnitRemoveAbility(d.caster, FLY_ID)
call TimerStart( d.t, 0.02, true, function Callback)
call SetTimerData( d.t, d)
call RemoveLocation(l)
set l = null
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t,Condition(function Cond))
call TriggerAddAction(t,function Main)
endfunction
endscope