shiFt
Member
- Reaction score
- 8
Iv got the basic framework for the struct developed from a previous post, now im trying to make the casting unit slide/dash/move like a missle to the target point of the spell, damaging units on the way and making a dummy cast a dummy spell on them.
The problems are:
I dont know how to move the unit, in the facing angle
The unit currently doesnt move // fixed this now I cant stop him
Setting the duration of the time taken for the caster to get to the point as d.dur
And finally stopping the unit when it reaches the target point of the spell
Have never done this in JASS before, have made GUI spells like this but this is just new to me.
so far:
The problems are:
I dont know how to move the unit, in the facing angle
The unit currently doesnt move // fixed this now I cant stop him
Setting the duration of the time taken for the caster to get to the point as d.dur
And finally stopping the unit when it reaches the target point of the spell
Have never done this in JASS before, have made GUI spells like this but this is just new to me.
so far:
JASS:
scope MOVE initializer Init
globals
private constant integer SPELL_ID = 039;A045039;
private constant integer DUMMY = 039;h01J039;
private constant integer DUMMY_SPELL = 039;A02T039;
private hashtable ht = InitHashtable()
endglobals
private struct Data
unit cs
real x
real y
real x2
real y2
player p
real dur
integer ticks
integer timeScaleTicks
timer t
group g
real dmg
real a
real dist
real x1
real y1
endstruct
globals
private unit U
private unit DUM
private Data D
private real X
private real Y
private integer array TimerData
private conditionfunc cf
private group gg = CreateGroup()
endglobals
private function Conditions takes nothing returns boolean
return GetSpellAbilityId() == SPELL_ID
endfunction
private function Effect2 takes nothing returns boolean
set U = GetFilterUnit()
if GetWidgetLife(U) > .405 and IsUnitEnemy(U,D.p) and not IsUnitInGroup(U,D.g) and IsUnitType(U,UNIT_TYPE_STRUCTURE) == false then
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Undead\\DevourMagic\\DevourMagicBirthMissile.mdl", U, "chest"))
call DestroyEffect(AddSpecialEffectTarget("Abilities\\Spells\\Human\\Feedback\\SpellBreakerAttack.mdl", U, "chest"))
call UnitDamageTargetEx(D.cs,U, D.dmg, false, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
set DUM = CreateUnit(D.p, DUMMY, GetWidgetX(U), GetWidgetY(U) ,0.00)
call UnitAddAbility(DUM, DUMMY_SPELL)
call UnitApplyTimedLife( DUM, 039;BTLF039;, 1)
call SetUnitAbilityLevel(DUM, DUMMY_SPELL,GetUnitAbilityLevel(D.cs, SPELL_ID))
call IssueTargetOrder( DUM, "entanglingroots" ,U )
call GroupAddUnit(D.g,U)
endif
return false
endfunction
private function Effects takes nothing returns nothing
local Data d = LoadInteger(ht,GetHandleId(GetExpiredTimer()),0)
if d.ticks > 0 then
set d.ticks = d.ticks - 1
if d.timeScaleTicks > 0 then
set d.timeScaleTicks = d.timeScaleTicks - 1
else
set d.timeScaleTicks = 10000
endif
set D = d
set d.x = GetUnitX(d.cs)
set d.y = GetUnitY(d.cs)
call SetUnitPosition(d.cs, d.x+ 10, d.y + 10)
call GroupEnumUnitsInRange(gg,d.x,d.y,175.,cf)
set d.dist = SquareRoot(d.x1 * d.x1 + d.y1 * d.y1)
if d.dist < 50 then
call PauseTimer(d.t)
call GroupClear(d.g)
call d.destroy()
endif
return
endif
call PauseTimer(d.t)
call GroupClear(d.g)
call d.destroy()
endfunction
private function Actions takes nothing returns nothing
local Data d = Data.create()
set d.cs = GetTriggerUnit()
set d.x2 = GetUnitX(d.cs)
set d.y2 = GetUnitY(d.cs)
set d.x1 = GetSpellTargetX() - d.x2
set d.y1 = GetSpellTargetY() - d.y2
set d.p = GetOwningPlayer(d.cs)
set d.dist = SquareRoot(d.x1 * d.x1 + d.y1 * d.y1)
set d.dur = d.dist/ 10
set d.ticks = R2I(d.dur / .04)
set d.timeScaleTicks = R2I(1. / .04)
set d.dmg = 60 + ( 10* GetUnitAbilityLevel(d.cs,SPELL_ID))
set d.a = AngleBetweenCoords( d.x, d.y, GetSpellTargetX(), GetSpellTargetY())
if d.t == null then
set d.t = CreateTimer()
call SaveInteger(ht,GetHandleId(d.t),0,d)
endif
if d.g == null then
set d.g = CreateGroup()
endif
call TimerStart(d.t,.04,true,function Effects)
endfunction
//---------------------------------------------------------------------------------------------------------
private function Init takes nothing returns nothing
local trigger t = CreateTrigger( )
local integer i = 0
loop
exitwhen i > 11
call TriggerRegisterPlayerUnitEvent(t, Player(i), EVENT_PLAYER_UNIT_SPELL_EFFECT, null)
set i = i + 1
endloop
call TriggerAddCondition( t, Condition( function Conditions ) )
call TriggerAddAction( t, function Actions )
set cf = Condition(function Effect2)
set t = null
endfunction
endscope