//Spell Name: Accelerate
//Created by: Mckill2009
//===HOW TO USE:
//- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
//- The trigger name MUST be >>> Accelerate (see the name below)
//- Copy ALL that is written here and overwrite the existing texts in the custom text
//- Copy the Dummy/custom abilities/buffs etc... to your object editor
//- Make sure you inputed the correct RAW CODES of the base spell/buffs/dummy etc...
//- If your raw code is different, you MUST CHANGE IT...
//- You can view the raw codes by pressing CTRL+D in the object editor
//- Examples of raw codes are 'A000', 'h000' etc...
//===REQUIRED VARIABLES:
//- HASH = Hashtable
//==========CONFIGURABLES==========
constant function ACC_SPELLID takes nothing returns integer
return 'A002' //raw code
endfunction
constant function ACC_SPEED takes nothing returns real
return 2.
endfunction
//==========END OF CONFIGURABLES==========
function ACC_LOOP takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer tID = GetHandleId(t)
local unit u = LoadUnitHandle(udg_HASH, tID, 1)
local real speed = LoadReal(udg_HASH, tID, 2)
local real duration = LoadReal(udg_HASH, tID, 3)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real facing = GetUnitFacing(u)
if duration > 0 then
call SaveReal(udg_HASH, tID, 3, duration-0.03)
call SetUnitX(u, x+speed*Cos(facing))
call SetUnitY(u, y+speed*Sin(facing))
else
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_HASH, tID)
endif
set u = null
set t = null
endfunction
function ACC_CAST takes nothing returns boolean
local timer t
local unit u
local integer tID
local integer level
if GetSpellAbilityId()==ACC_SPELLID() then
set t = CreateTimer()
set tID = GetHandleId(t)
set u = GetTriggerUnit()
set level = GetUnitAbilityLevel(u, ACC_SPELLID())
call SaveUnitHandle(udg_HASH, tID, 1, u)
call SaveReal(udg_HASH, tID, 2, ACC_SPEED())
call SaveReal(udg_HASH, tID, 3, 10.) //duration
call TimerStart(t, 0.03, true, function ACC_LOOP)
endif
set u = null
set t = null
return false
endfunction
function InitTrig_Accelerate takes nothing returns nothing
local trigger t = CreateTrigger()
set udg_HASH = InitHashtable()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(t, Condition(function ACC_CAST))
set t = null
endfunction
I made something like this before, wait let me find it...
EDIT:
JASS://Spell Name: Accelerate //Created by: Mckill2009 //===HOW TO USE: //- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT //- The trigger name MUST be >>> Accelerate (see the name below) //- Copy ALL that is written here and overwrite the existing texts in the custom text //- Copy the Dummy/custom abilities/buffs etc... to your object editor //- Make sure you inputed the correct RAW CODES of the base spell/buffs/dummy etc... //- If your raw code is different, you MUST CHANGE IT... //- You can view the raw codes by pressing CTRL+D in the object editor //- Examples of raw codes are 'A000', 'h000' etc... //===REQUIRED VARIABLES: //- HASH = Hashtable //==========CONFIGURABLES========== constant function ACC_SPELLID takes nothing returns integer return 'A002' //raw code endfunction constant function ACC_SPEED takes nothing returns real return 2. endfunction function ACC_RANGE takes integer i returns real return 200 + i * 300. endfunction //==========END OF CONFIGURABLES========== function ACC_LOOP takes nothing returns nothing local timer t = GetExpiredTimer() local integer tID = GetHandleId(t) local unit u = LoadUnitHandle(udg_HASH, tID, 1) local real x = LoadReal(udg_HASH, tID, 2) local real y = LoadReal(udg_HASH, tID, 3) local real mindist = LoadReal(udg_HASH, tID, 4) local real maxdist = LoadReal(udg_HASH, tID, 5) local real facing = GetUnitFacing(u) if maxdist > mindist then call SaveReal(udg_HASH, tID, 4, mindist+ACC_SPEED()) call SetUnitX(u, x+mindist*Cos(facing)) call SetUnitY(u, y+mindist*Sin(facing)) else call PauseTimer(t) call DestroyTimer(t) call FlushChildHashtable(udg_HASH, tID) endif set u = null set t = null endfunction function ACC_CAST takes nothing returns boolean local timer t local unit u local integer tID local integer level if GetSpellAbilityId()==ACC_SPELLID() then set t = CreateTimer() set tID = GetHandleId(t) set u = GetTriggerUnit() set level = GetUnitAbilityLevel(u, ACC_SPELLID()) call SaveUnitHandle(udg_HASH, tID, 1, u) call SaveReal(udg_HASH, tID, 2, GetUnitX(u)) call SaveReal(udg_HASH, tID, 3, GetUnitY(u)) call SaveReal(udg_HASH, tID, 4, 0) //mindist call SaveReal(udg_HASH, tID, 5, ACC_RANGE(level)) //maxdist call TimerStart(t, 0.03, true, function ACC_LOOP) endif set u = null set t = null return false endfunction function InitTrig_Accelerate takes nothing returns nothing local trigger t = CreateTrigger() set udg_HASH = InitHashtable() call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT) call TriggerAddCondition(t, Condition(function ACC_CAST)) set t = null endfunction
NOTE: This has not yet been and I am modifying this that when you press 'stop' it will stop, meanwhile this code has a max range...
//Spell Name: Accelerate
//Created by: Mckill2009
//===CONTROLLER:
//- Mouse only, no arrow keys
//- Cast the spell and this will accelerate your movement fast depending on the level of your hero
//- Press stop to "stop"
//===HOW TO USE:
//- Make a new trigger and convert to custom text via EDIT >>> CONVERT CUSTOM TEXT
//- Copy ALL that is written here and overwrite the existing texts in the custom text
//- Copy the Dummy/custom abilities/buffs etc... to your object editor
//- Make sure you inputed the correct RAW CODES of the base spell/buffs/dummy etc...
//- If your raw code is different, you MUST CHANGE IT...
//- You can view the raw codes by pressing CTRL+D in the object editor
//- Examples of raw codes are 'A000', 'h000' etc...
//- The spell should be "NO TARGET" spell...
//===REQUIREMENT:
//- Jass New Gen Pack (JNGP) by Vexorian
scope Acc
globals
private constant integer SPELLID = 'A000' //Hero spell raw code
private constant hashtable HASH = InitHashtable()
private constant real SPEED = 0.03125
private unit hero
endglobals
//==========CONFIGURABLES==========
private constant function MAXSPEED takes integer i returns real
return 5 + i * 5.
endfunction
//==========END OF CONFIGURABLES==========
private module ACL
private static method onInit takes nothing returns nothing
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t1, EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerRegisterAnyUnitEventBJ(t2, EVENT_PLAYER_UNIT_ISSUED_ORDER)
call TriggerAddCondition(t1, Condition(function thistype.onCast))
call TriggerAddCondition(t2, Condition(function thistype.onClear))
set t1 = null
set t1 = null
endmethod
endmodule
private struct ACEL
unit caster
real speed
static method onAccelerate takes nothing returns nothing
local timer t = GetExpiredTimer()
local thistype this = LoadInteger(HASH, GetHandleId(t), 1)
local integer check = LoadInteger(HASH, GetHandleId(.caster), 1)
local real facing = GetUnitFacing(.caster) * bj_DEGTORAD
local real x = GetUnitX(.caster)
local real y = GetUnitY(.caster)
if check==0 and GetWidgetLife(.caster) > 0.405 then
call SetUnitX(.caster, x+.speed*Cos(facing))
call SetUnitY(.caster, y+.speed*Sin(facing))
else
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(HASH, GetHandleId(.caster))
call FlushChildHashtable(HASH, GetHandleId(t))
endif
set t = null
endmethod
static method onDo takes unit u returns thistype
local thistype this = thistype.allocate()
local timer t = CreateTimer()
local integer level = GetUnitAbilityLevel(u, SPELLID)
set .caster = u
set .speed = MAXSPEED(level)
call SaveInteger(HASH, GetHandleId(.caster), 1, 0)
call SaveInteger(HASH, GetHandleId(t), 1, this)
call TimerStart(t, SPEED, true, function thistype.onAccelerate)
return this
endmethod
static method onCast takes nothing returns boolean
if GetSpellAbilityId()==SPELLID and not HaveSavedInteger(HASH, GetHandleId(GetTriggerUnit()), 1) then
set hero = GetTriggerUnit()
call FlushChildHashtable(HASH, GetHandleId(hero))
call thistype.onDo(hero)
call ResetToGameCameraForPlayer(GetTriggerPlayer(), 0.01)
call SetCameraTargetControllerNoZForPlayer(GetTriggerPlayer(), hero, 0, 0, true)
endif
return false
endmethod
static method onClear takes nothing returns boolean
if GetIssuedOrderId()==OrderId("stop") then
call SaveInteger(HASH, GetHandleId(GetTriggerUnit()), 1, 1)
call ResetToGameCameraForPlayer(GetTriggerPlayer(), 0.01)
endif
return false
endmethod
implement ACL
endstruct
endscope