Log in
Current Version: v0.0.01A
Alpha version
Changelogs to come
Latest topics
Version Progress
Changes for v0.02.0A||||||||||||||||||||[●] [general]
||||||||||||||||||||[●] [Heroes]
||||||||||||||||||||[●] [Items]
||||||||||||||||||||[●] [Bugs]
||||||||||||||||||||[●] [Total]
jass jump code
Page 1 of 1
jass jump code
so i need the ability to call a function when the jump itself is over... i just wouldnt know how to add it... im thinking do call ExecuteFunction("function name")... but that wont work if i dont want to call a function after the jump
- Code:
//||-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-||
//|| ||
//|| ~ J U M P L I B R A R Y ~ ||
//|| [v1.2b] ||
//|| ||
//||-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-||
//|| C H A N G E L O G ||
//||-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-||
//|| ||
//|| [v1.0a] ~First Version ||
//|| ||
//|| [v1.0b] ~Fixed a problem with memory leaks :/ ||
//|| ||
//|| [v1.1a] ~Code efficiency & safety updrade ||
//|| ||
//|| [v1.2a] ~More efficiency updrades ||
//|| ||
//|| [v1.2b] ~Made the Interval and the FPS2 constants ||
//|| ||
//||-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-||
library Jump initializer Init
globals
private constant integer FPS = 40
private constant integer FlyId = 'Amrf'
// ~ DO NOT TUCH! ~
private constant real Interval = (1.0/FPS)
private constant integer FPS2 = (FPS*FPS)
private real MaxX = 0
private real MaxY = 0
private real MinX = 0
private real MinY = 0
endglobals
private struct Data
unit Object
real Cos
real Sin
real X
real H
real Speed
real Dist = 0
real MaxDist
real Z
string Effect
string EffectAttach
effect Art
boolean AffectZ
boolean Paused
static real nX = 0
static real nY = 0
static real nH = 0
static location Loc = Location(0, 0)
static integer array Index
static integer Total = 0
static timer Timer = null
static method Loop takes nothing returns nothing
local Data dat
local integer i = 0
loop
exitwhen i >= Data.Total
set dat = Data.Index[i]
if dat.AffectZ then
set dat.Dist = dat.Dist + dat.Speed
set Data.nX = GetUnitX(dat.Object) + dat.Speed * dat.Cos
set Data.nY = GetUnitY(dat.Object) + dat.Speed * dat.Sin
call MoveLocation(Data.Loc, Data.nX, Data.nY)
set Data.nH = dat.X*(dat.MaxDist - dat.Dist)*(dat.Dist / dat.MaxDist) - GetLocationZ(Data.Loc) + dat.Z
if Data.nH > 0.0 and Data.nX < MaxX and Data.nY < MaxY and Data.nX > MinX and Data.nY > MinY and GetWidgetLife(dat.Object) > .405 then
call SetUnitX(dat.Object, dat.nX)
call SetUnitY(dat.Object, dat.nY)
call SetUnitFlyHeight(dat.Object, Data.nH, 0)
else
if dat.Effect != "" and dat.Effect != null then
if dat.EffectAttach != "" and dat.EffectAttach != null then
call DestroyEffect(AddSpecialEffectTarget(dat.Effect, dat.Object, dat.EffectAttach))
set dat.EffectAttach = null
else
call DestroyEffect(AddSpecialEffect(dat.Effect, GetUnitX(dat.Object), GetUnitY(dat.Object)))
endif
set dat.Effect = null
endif
if dat.Art != null then
call DestroyEffect(dat.Art)
set dat.Art = null
endif
if dat.Paused then
call PauseUnit(dat.Object, false)
endif
call SetUnitFlyHeight(dat.Object, dat.H, 0)
set dat.Object = null
call dat.destroy()
set Data.Total = Data.Total - 1
set Data.Index[i] = Data.Index[Data.Total]
set i = i - 1
endif
elseif dat.Dist < dat.MaxDist then
set dat.Dist = dat.Dist + dat.Speed
set Data.nX = GetUnitX(dat.Object) + dat.Speed * dat.Cos
set Data.nY = GetUnitY(dat.Object) + dat.Speed * dat.Sin
set Data.nH = dat.X*(dat.MaxDist - dat.Dist)*(dat.Dist / dat.MaxDist)
if Data.nX < MaxX and Data.nY < MaxY and Data.nX > MinX and Data.nY > MinY and GetWidgetLife(dat.Object) > .405 then
call SetUnitFlyHeight(dat.Object, Data.nH, 0)
call SetUnitX(dat.Object, dat.nX)
call SetUnitY(dat.Object, dat.nY)
else
set dat.Dist = dat.MaxDist
endif
else
if dat.Effect != "" and dat.Effect != null then
if dat.EffectAttach != "" and dat.EffectAttach != null then
call DestroyEffect(AddSpecialEffectTarget(dat.Effect, dat.Object, dat.EffectAttach))
set dat.EffectAttach = null
else
call DestroyEffect(AddSpecialEffect(dat.Effect, GetUnitX(dat.Object), GetUnitY(dat.Object)))
endif
set dat.Effect = null
endif
if dat.Art != null then
call DestroyEffect(dat.Art)
set dat.Art = null
endif
if dat.Paused then
call PauseUnit(dat.Object, false)
endif
call SetUnitFlyHeight(dat.Object, dat.H, 0)
set dat.Object = null
call dat.destroy()
set Data.Total = Data.Total - 1
set Data.Index[i] = Data.Index[Data.Total]
set i = i - 1
endif
set i = i + 1
endloop
if Data.Total == 0 then
call PauseTimer(Data.Timer)
endif
endmethod
static method Start takes unit Object, real Angle, real X, real Speed, real Dist, boolean Arced, boolean AffectZ, boolean Paused, string Effect, string EffectAttach, string Art, string ArtAttach returns nothing
local Data dat = Data.allocate()
call MoveLocation(Data.Loc, GetUnitX(Object), GetUnitY(Object))
set dat.Object = Object
set dat.H = GetUnitDefaultFlyHeight(Object)
set dat.Cos = Cos(Angle)
set dat.Sin = Sin(Angle)
set dat.Speed = Speed
set dat.Z = GetLocationZ(Data.Loc) + dat.H
set dat.AffectZ = AffectZ
set dat.Paused = Paused
if Arced then
set dat.X = 4 * X
else
set dat.X = 4 * X / Dist
endif
if dat.X < .001 then
set dat.X = .001
endif
if Dist < .001 then
set dat.MaxDist = .001
else
set dat.MaxDist = Dist
endif
if Paused then
call PauseUnit(Object, true)
endif
call UnitAddAbility(Object, FlyId)
call UnitRemoveAbility(Object, FlyId)
if Effect != "" and Effect != null then
if EffectAttach != "" and EffectAttach != null then
set dat.EffectAttach = EffectAttach
endif
set dat.Effect = Effect
endif
if Art != "" and Art != null and ArtAttach != "" and ArtAttach != null then
set dat.Art = AddSpecialEffectTarget(Art, Object, ArtAttach)
endif
if Data.Total == 0 then
call TimerStart(Data.Timer, Interval, true, function Data.Loop)
endif
set Data.Index[Data.Total] = dat
set Data.Total = Data.Total + 1
endmethod
endstruct
//==================================================================================
function Jump takes unit Object, real RadAngle, real X, integer Speed, real Dist, boolean Arced, boolean AffectZ, boolean Paused, string Effect, string EffectAttach, string Art, string ArtAttach returns nothing
call Data.Start(Object, RadAngle, X, Speed/FPS, Dist, Arced, AffectZ, Paused, Effect, EffectAttach, Art, ArtAttach)
endfunction
function JumpHeight takes unit Object, real RadAngle, real Height, integer Speed, real Dist, boolean Paused returns nothing
call Data.Start(Object, RadAngle, Height, Speed/FPS, Dist, false, false, Paused, "", "", "", "")
endfunction
function JumpHeightEx takes unit Object, real RadAngle, real Height, integer Speed, real Dist, boolean AffectZ, boolean Paused, string Effect, string EffectAttach, string Art, string ArtAttach returns nothing
call Data.Start(Object, RadAngle, Height, Speed/FPS, Dist, false, AffectZ, Paused, Effect, EffectAttach, Art, ArtAttach)
endfunction
function JumpArc takes unit Object, real RadAngle, real Arc, integer Speed, real Dist, boolean Paused returns nothing
call Data.Start(Object, RadAngle, Arc, Speed/FPS, Dist, true, false, Paused, "", "", "", "")
endfunction
function JumpArcEx takes unit Object, real RadAngle, real Arc, integer Speed, real Dist, boolean AffectZ, boolean Paused, string Effect, string EffectAttach, string Art, string ArtAttach returns nothing
call Data.Start(Object, RadAngle, Arc, Speed/FPS, Dist, true, AffectZ, Paused, Effect, EffectAttach, Art, ArtAttach)
endfunction
function JumpTimed takes unit Object, real RadAngle, real X, real Time, real Dist, boolean Arced, boolean Paused returns nothing
call Data.Start(Object, RadAngle, X, Dist/Time/Interval/FPS2, Dist, Arced, false, Paused, "", "", "", "")
endfunction
function JumpTimedEx takes unit Object, real RadAngle, real X, real Time, real Dist, boolean Arced, boolean Paused, string Effect, string EffectAttach, string Art, string ArtAttach returns nothing
call Data.Start(Object, RadAngle, X, Dist/Time/Interval/FPS2, Dist, Arced, false, Paused, Effect, EffectAttach, Art, ArtAttach)
endfunction
//==================================================================================
private function Init takes nothing returns nothing
set Data.Timer = CreateTimer()
set MaxX = GetRectMaxX(bj_mapInitialPlayableArea)
set MaxY = GetRectMaxY(bj_mapInitialPlayableArea)
set MinX = GetRectMinX(bj_mapInitialPlayableArea)
set MinY = GetRectMinY(bj_mapInitialPlayableArea)
endfunction
endlibrary
_________________
warning! very-stubborn, sarcastic, self-important, argumentative developer detected!
And unto the masses, He doth spoke:
"Behold The Stuff! It Is Good!"
And the Stuff was good.
Heroes:
Commander Farsight (colab - implemented) - Ku'gaath Plaguefather(incomplete) - Ilyana Arienal(incomplete) - Harlequin Shadowseer(incomplete) - Modular Tau Battlesuit(sandbox)

» Emoticon Code from Neopets!
» JOIN THE MOST BEASTLY DOJO WITH THE CODE: AFAEAHGE
» New Cheerleading Move Code
» Animal ID code not working?
» First Code from Ds game Welcome to Hugsville
» JOIN THE MOST BEASTLY DOJO WITH THE CODE: AFAEAHGE
» New Cheerleading Move Code
» Animal ID code not working?
» First Code from Ds game Welcome to Hugsville
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
» Faction creeps
» [SCII] [Inquisition] Hector Rex
» [necrons] Orikan, the Diviner
» Talent System
» Capture Points system
» [SCII] [Orks] Warboss(es)
» Game Guide
» [Inquisition] Mordrak
» [inquiition] Kaldor Draigo