Hey guys,
This is my new floating system.
Read everything over the system first.
Any questions, bugs, etc.. post here in the thread.
v1.01 configurable data section added
v1.02 TimerUtils instead of ABC
GL&HF Give Credits! Give Feedback if you want!
This is my new floating system.
Read everything over the system first.
Any questions, bugs, etc.. post here in the thread.
JASS:
//*******************************************************************************************
//
// FLOATING SYSTEM v1.02
//
//*******************************************************************************************
//
// by Razoron from hiveworkshop.com
//
// REQUIRES: Timer Utils, vJass
//
//Discription:
//This is a universal floating system to do jumps,...
//
//How to use:
//call Floating(unit WhichUnit, real Delay, boolean X(*), string ("up" or "down" or "middle"), real height, real strong)
//*If you want a normal jump with friction: true
//If you want a jump without friction: false
//
//up: the unit floats up
//down: the unit floats down
//middle: both
//
//If you use X=false, you can choose the height the unit should flow. Strong doesn't metter.
//If you use X=true, you can choose the force(strong). Height doesn't metter.
//WARNING: The unnecessary parameter should be replaced with a number you want.
// But don't leave it out!
//
//YOU NEED A DUMMIE SPELL:
//1.Create a new spell(metramorphose) with the ID 'FLYY'.
//2.Set the alternative figure to a gryphon rider.
//3.Set all values to 0.
//4.Done
//
//How to import:
//1.Copy this code in a new trigger.
//2.Create the dummie spell.
//3.Give Credits to Razoron!
//
//*******************************************************************************************
library Floatingg requires TimerUtils
globals
//
// CONFIGURABLE DATA
//
//TIMEOUT:
//The interval of the timer.
//
//ID:
//The ID of your dummie spell.
private constant real TIMEOUT=0.04
private constant integer ID='FLYY'
endglobals
private struct Floatinggg
unit fl
real delay
boolean b
integer steps
real height
integer mode
real rate
real strong
real bonus
real bonusw
timer t
real totalsteps
endstruct
private function GoFloating takes nothing returns nothing
local timer t=GetExpiredTimer()
local Floatinggg f=GetTimerData(t)
local real height=GetUnitFlyHeight(f.fl)
if f.mode==1 and f.b==true then
set f.bonus=f.bonus-f.bonusw
endif
if f.mode==3 and f.b==true then
set f.bonus=f.bonus+f.bonusw
endif
if f.mode==2 and f.b==true then
set f.bonus=f.bonus-f.bonusw
endif
set f.steps=f.steps-1
if f.steps<=0 and f.mode!=2 then
call f.destroy()
call ReleaseTimer(t)
elseif f.steps<=0 and f.mode==2 and f.b==false then
call f.destroy()
call ReleaseTimer(t)
endif
if f.steps<=0 and f.mode==2 and GetUnitFlyHeight(f.fl)<=10 and f.b==true then
call f.destroy()
call ReleaseTimer(t)
endif
if f.b==false then
call SetUnitFlyHeight(f.fl,height+f.rate,10000000)
else
call SetUnitFlyHeight(f.fl,height+f.bonus,10000000)
endif
if f.steps<=f.totalsteps/2 and f.mode==2 and f.b==false and f.rate>=0 then
set f.rate=-(f.rate)
endif
set t=null
endfunction
function Floating takes unit f, real delay, boolean b, string upordownormiddle, real height, real strong returns nothing
local Floatinggg flo=Floatinggg.create()
local timer t=CreateTimer()
local real b1=0
set flo.t=t
set flo.fl=f
set flo.delay=delay
set flo.b=b
set flo.height=height
set flo.steps=R2I(delay)/R2I((TIMEOUT*100))
set flo.strong=strong
if upordownormiddle=="up" and b==true then
set flo.bonus=strong
elseif upordownormiddle=="down" and b==true then
set flo.bonus=strong
elseif upordownormiddle=="middle" and b==true then
set flo.bonus=strong
endif
set flo.totalsteps=flo.steps
if upordownormiddle=="up" and b==true then
set flo.bonusw=flo.bonus/flo.delay
elseif upordownormiddle=="down" and b==true then
set flo.bonusw=-(flo.bonus/flo.delay)
set flo.bonus=0
elseif upordownormiddle=="middle" and b==true then
set flo.bonusw=2*(flo.bonus/flo.delay)
elseif b==false and upordownormiddle=="middle" then
set flo.rate=2*(height/delay)
elseif b==false and upordownormiddle=="up" then
set flo.rate=height/delay
elseif b==false and upordownormiddle=="down" then
set flo.rate=-(height/delay)
endif
call UnitAddAbility(flo.fl,ID)
call UnitRemoveAbility(flo.fl,ID)
if upordownormiddle=="up" then
set flo.mode=1
elseif upordownormiddle=="middle" then
set flo.mode=2
elseif upordownormiddle=="down" then
set flo.mode=3
endif
call SetTimerData(t,flo)
call TimerStart(t,0.01,true,function GoFloating)
set t=null
endfunction
endlibrary
v1.01 configurable data section added
v1.02 TimerUtils instead of ABC
GL&HF Give Credits! Give Feedback if you want!
Last edited: