- Joined
- Sep 16, 2008
- Messages
- 47
Hi i tried to create my first Jass Spell.
Here is code:
When i cast this spell just nothing happens
Here is code:
JASS:
function Trig_Jump_Conditions takes nothing returns boolean
return(GetSpellAbilityId() == 'A007')
endfunction
function Jump takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local real Speed = LoadReal(udg_Jump_Table, id, 0)
local real Distance = LoadReal(udg_Jump_Table, id, 1)
local real MaxHeight = LoadReal(udg_Jump_Table, id, 2)
local real CurrentDistance = LoadReal(udg_Jump_Table, id, 3)
local real Real = LoadReal(udg_Jump_Table, id, 4)
local real X = LoadReal(udg_Jump_Table, id, 5)
local real Y = LoadReal(udg_Jump_Table, id, 6)
local real X2 = LoadReal(udg_Jump_Table, id, 7)
local real Y2 = LoadReal(udg_Jump_Table, id, 8)
local unit Caster = LoadUnitHandle(udg_Jump_Table, id, 9)
local string a="This is a message"
call DisplayTextToForce( GetPlayersAll(), a )
set Real = ( 4 * MaxHeight / Distance) * ( Distance - CurrentDistance) * ( CurrentDistance / Distance )
set X = GetLocationX(GetUnitLoc(Caster))
set Y = GetLocationY(GetUnitLoc(Caster))
set X2 = X + Speed
set Y2 = Y + Speed
call DisplayTextToForce( GetPlayersAll(), a )
call SetUnitPosition(Caster, X2, Y2)
call SetUnitFlyHeight(Caster, Real, 0)
if ( CurrentDistance == Distance ) then
call UnitRemoveAbility(Caster, 'Arav')
call FlushChildHashtableBJ( GetHandleIdBJ(t), udg_Jump_Table )
call DestroyTimer(t)
return
endif
call SaveRealBJ(CurrentDistance + Speed, 3, GetHandleIdBJ(t), udg_Jump_Table)
set t = null
set Caster = null
endfunction
function Trig_Jump_Actions takes nothing returns nothing
local unit Caster = GetTriggerUnit()
local location CasterLoc = GetUnitLoc(Caster)
local location TargetLoc = GetSpellTargetLoc()
local real Hyp
local real SINE
local real COSINE
local real Distance
local real CurrentDistance
local real Height
local real HYPSpeed
local real Speed
local real Angle
local real Real
local real X
local real Y
local real X2
local real Y2
local timer t = CreateTimer()
local real update = 0.03
local real MaxHeight = 500.00
local integer id = GetHandleId(t)
set CurrentDistance = 0.00
set Distance = DistanceBetweenPoints(CasterLoc, TargetLoc)
set Angle = AngleBetweenPoints(CasterLoc, TargetLoc)
set Height = 0
set Hyp = SquareRoot(( ( Distance * Distance ) + ( Height * Height ) ))
set SINE = (Distance / Hyp)
set COSINE = (Height / Hyp)
set HYPSpeed = Hyp * 0.03
set Speed = (HYPSpeed * SINE)
call UnitAddAbility(Caster, 'Arav')
call SaveReal(udg_Jump_Table, id, 0, Speed)
call SaveReal(udg_Jump_Table, id, 1, Distance)
call SaveReal(udg_Jump_Table, id, 2, MaxHeight)
call SaveReal(udg_Jump_Table, id, 3, CurrentDistance)
call SaveReal(udg_Jump_Table, id, 4, Real)
call SaveReal(udg_Jump_Table, id, 5, X)
call SaveReal(udg_Jump_Table, id, 6, Y)
call SaveReal(udg_Jump_Table, id, 7, X2)
call SaveReal(udg_Jump_Table, id, 8, Y2)
call SaveUnitHandle(udg_Jump_Table, id, 9, Caster)
call RemoveLocation(CasterLoc)
call RemoveLocation(TargetLoc)
call TimerStart(t, update, true, function Jump)
set Caster = null
set t = null
endfunction
//===========================================================================
function InitTrig_Jump takes nothing returns nothing
set gg_trg_Jump = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Jump, Condition( function Trig_Jump_Conditions ) )
call TriggerAddAction( gg_trg_Jump, function Trig_Jump_Actions )
endfunction
Last edited: