Komaqtion
You can change this now in User CP.
- Reaction score
- 469
Hi again
Just a small script which will track the absolute movement-speed of units by using a single timer (Copied T32's module for this, so people can use different periods for T32 and this. Though if enough people think this is unecessary then I'll just use T32 instead ).
Ok, here's the small code
Might not be too useful, but can be extended quite a bit I'd believe
Just a small script which will track the absolute movement-speed of units by using a single timer (Copied T32's module for this, so people can use different periods for T32 and this. Though if enough people think this is unecessary then I'll just use T32 instead ).
Ok, here's the small code
JASS:
library UnitSpeedTracking requires AIDS
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
//*********************************************************************************************************//
//@@///////////////////////////////// *// UnitSpeedTracking \\* /////////////////////////////////////////@@//
//@@ @@//
//@@ Made by , Komaqtion @ TheHelper.net @@//
//@@ @@//
//@@ @@//
//@@ Purpose: @@//
//@@ @@//
//@@ # The purpose of this small snippet is to be able to get a unit's absolute @@//
//@@ speed, and accurately, too <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /> @@//
//@@ @@//
//@@ Usage: @@//
//@@ @@//
//@@ # Now, the functions provided by this small snippet is: @@//
//@@ @@//
//@@ -> function GetUnitSpeed takes unit speeder returns real <- @@//
//@@ @@//
//@@ - "unit speeder" -> This is the unit you wish to find out the speed of @@//
//@@ - "returns real" -> This function will return the current speed @@//
//@@ the unit is currently moving at, used as "range-per-second". @@//
//@@ @@//
//@@ @@//
//@@ Requirements: @@//
//@@ @@//
//@@ # This snippet's only requirement is vJASS compilement, which is @@//
//@@ easiest achieved by downloading JASS Newgen Pack, at @@//
//@@ <a href="http://www.thehelper.net/forums/showthread.php?t=73936" class="link link--internal">http://www.thehelper.net/forums/showthread.php?t=73936</a> @@//
//@@ You'll also have to update JASS Helper to the latest version... @@//
//@@ @@//
//@@ @@//
//@@ Credits: @@//
//@@ @@//
//@@ # - Jesus4Lyf, for his T32 module which I've copied for the @@//
//@@ timer-efficiency of using a single timer for it all ! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" /> @@//
//@@ @@//
//@@ # And credits, if you use this that is, is not needed to give me @@//
//@@ though it's always welcome <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite2" alt=";)" title="Wink ;)" loading="lazy" data-shortname=";)" /> @@//
//@@ @@//
//@@/////////////////////////////////////////////////////////////////////////////////////////////////////@@//
//*********************************************************************************************************//
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Small but important CONFIGURATION AREA !
globals
private constant real TRACK_PERIOD = 0.01 // This is the period of which the speed of each unit in-game is refreshed
endglobals
// END OF CONFIGURATION !!!! <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite7" alt=":p" title="Stick Out Tongue :p" loading="lazy" data-shortname=":p" />
private struct UnitSpeedData extends array
//! runtextmacro AIDS()
timer trackTimer
real unitX
real unitY
real currentSpeed
private thistype next
private thistype prev
static trigger trackingTrigger = CreateTrigger()
private method AIDS_onCreate takes nothing returns nothing
set unitX = GetUnitX( unit )
set unitY = GetUnitY( unit )
set currentSpeed = 0
set thistype(0).next.prev = this
set this.next = thistype(0).next
set thistype(0).next =this
set this.prev = thistype(0)
endmethod
private static method SpeedTracking takes nothing returns boolean
local real x
local real y
local real difx
local real dify
local real dist
local thistype this = thistype(0).next
loop
exitwhen this == 0
set x = GetUnitX( unit )
set y = GetUnitY( unit )
set difx = x - unitX
set dify = y - unitY
set dist = SquareRoot( difx * difx + dify * dify )
set currentSpeed = dist / TRACK_PERIOD
set unitX = x
set unitY = y
set this = next
endloop
return false
endmethod
private method AIDS_onDestroy takes nothing returns nothing
set this.prev.next = this.next
set this.next.prev = this.prev
endmethod
private static method EvaluateStack takes nothing returns nothing
call TriggerEvaluate( thistype.trackingTrigger )
endmethod
private static method AIDS_onInit takes nothing returns nothing
call TimerStart( CreateTimer(), TRACK_PERIOD, true, function thistype.EvaluateStack )
call TriggerAddCondition( thistype.trackingTrigger, Condition( function thistype.SpeedTracking ) )
endmethod
endstruct
function GetUnitSpeed takes unit speeder returns real
return UnitSpeedData( GetUnitId( speeder ) ).currentSpeed
endfunction
endlibrary
Might not be too useful, but can be extended quite a bit I'd believe