Fulla
Evil Overlord
- Reaction score
- 31
The spell is meant to be a pretty straight forward projectile spell. It launches an arrow in an arc towards a destination & upon impact explodes dealing AoE damage.
Anitarf helped me alot with this script, but he had to go, so seeking further help. I'm currently having 2 major problems:
I'm also learning how to use scopes during this, so bare with me
thx for any help.
Anitarf helped me alot with this script, but he had to go, so seeking further help. I'm currently having 2 major problems:
- The Z for the projectile seems to not working at all, i.e. the projectile remains at ground height through out.
- The Speed seems to vary depending on which angle I cast at, i.e. sideways (roughly 0 or 180) it works fine, but other than that it gets completely screwed up
I'm also learning how to use scopes during this, so bare with me
JASS:
scope FlamingArrow
globals
flamingarrowdata array FlamingArrowArray
integer FlamingArrowTotal = 0
private constant integer ABILITY_RAWCODE = 039;A002039;
private constant real TIMER_INTERVAL = 0.03
private constant real MISSILE_SPEED = 900
private constant real MISSILE_GRAVITY = 300
private constant real MISSILE_MINDIST = 400
private constant real MISSILE_DAMAGE = 100
endglobals
struct flamingarrowdata
unit missile = null
effect sfx = null
integer level = 0
real sx = 0
real sy = 0
real sz = 0
real vx = 0
real vy = 0
real vz = 0
real time = 0
real duration = 0
endstruct
function Conditions takes nothing returns boolean
return GetSpellAbilityId() == ABILITY_RAWCODE
endfunction
function End takes unit u, integer level returns nothing
local real x = GetUnitX(u)
local real y = GetUnitY(u)
call DestroyEffect(AddSpecialEffect("Objects\\Spawnmodels\\Other\\NeutralBuildingExplosion\\NeutralBuildingExplosion.mdl", x, y))
endfunction
function Timer takes nothing returns nothing
local flamingarrowdata dat
local integer i = 0
local integer aoa = 0
local real z = 0
loop
exitwhen i >= FlamingArrowTotal
set dat = FlamingArrowArray<i>
set dat.time = dat.time + (TIMER_INTERVAL / dat.duration)
set z = GetZ(GetUnitX(dat.missile), GetUnitY(dat.missile))
call SetUnitX(dat.missile, dat.sx + dat.vx * dat.time)
call SetUnitY(dat.missile, dat.sy + dat.vy * dat.time)
call SetUnitFlyHeight(dat.missile, dat.sz + dat.vz * dat.time - MISSILE_GRAVITY * dat.time * dat .time / 2 - z, 0)
set aoa = R2I(Atan2BJ(dat.vz -MISSILE_GRAVITY * dat.time, SquareRoot(dat.vx * dat.vx + dat.vy * dat.vy))) + 90
call SetUnitAnimationByIndex(dat.missile, aoa)
//Missile has reached its destination
if dat.time >= dat.duration then
//Add an explosion
call End(dat.missile, dat.level)
//Destroy everything
call DestroyEffect(dat.sfx)
call KillUnit(dat.missile)
set FlamingArrowTotal = FlamingArrowTotal - 1
set FlamingArrowArray<i> = FlamingArrowArray[FlamingArrowTotal]
call dat.destroy()
set i = i - 1
endif
set i = i + 1
endloop
if FlamingArrowTotal==0 then
call ReleaseTimer(GetExpiredTimer())
endif
endfunction
function Actions takes nothing returns nothing
local flamingarrowdata dat = flamingarrowdata.create()
local unit u = GetTriggerUnit()
local location l = GetSpellTargetLoc()
local real dx = GetLocationX(l) - GetUnitX(u)
local real dy = GetLocationY(l) - GetUnitY(u)
local real dz = GetLocationZ(l) - (GetUnitZ(u) + 100)
local real dist = SquareRoot(dx * dx + dy + dy)
//Minimum distance
if dist < MISSILE_MINDIST then
set dx = dx * MISSILE_MINDIST / dist
set dy = dy * MISSILE_MINDIST / dist
set dist = MISSILE_MINDIST
endif
set dat.missile = CreateUnit(GetOwningPlayer(u), 039;hmil039;, GetUnitX(u), GetUnitY(u), Atan2BJ(dy, dx))
set dat.sfx = AddSpecialEffectTarget(GetAbilityEffectById(ABILITY_RAWCODE, EFFECT_TYPE_MISSILE, 1), dat.missile, "origin")
set dat.level = GetUnitAbilityLevel(u, ABILITY_RAWCODE)
set dat.duration = dist / MISSILE_SPEED
set dat.sx = GetUnitX(u)
set dat.sy = GetUnitY(u)
set dat.sz = GetUnitZ(u)
set dat.vx = dx / dat.duration
set dat.vy = dy / dat.duration
set dat.vz = dz / dat.duration + MISSILE_GRAVITY * dat.duration / 2
//The Missile is shot/launched from 100 above the caster
call SetUnitFlyHeight(dat.missile, 100, 0)
if FlamingArrowTotal == 0 then
call TimerStart(NewTimer(), TIMER_INTERVAL, true, function Timer)
endif
set FlamingArrowArray[FlamingArrowTotal] = dat
set FlamingArrowTotal = FlamingArrowTotal + 1
call RemoveLocation(l)
set u = null
endfunction
//===========================================================================
function InitTrig_Flaming_Arrow takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_CAST)
call TriggerAddCondition(t, Condition(function Conditions))
call TriggerAddAction(t, function Actions)
endfunction
endscope</i></i>
thx for any help.