Technomancer
New Member
- Reaction score
- 14
Hey, the code so far is ugly, but this is for a new timer system that I'm working on.
First syntax error:
Second syntax error:
The appropriate crap is commented out right now, however, for the first one, I'm stumped, for the second one, I'm stumped.
Import this and ABC into a map, uncomment, and try to compile to see what I mean.
JASS:
// These functions and structs are the core of the hit n' run library.
//
// DOCUMENTATION
// I'm generally bad at documentation so please, if you would like anything explained,
// please, PM me @Technomancer on <a href="http://www.thehelper.net" class="link link--internal">www.thehelper.net</a>, and I'll add it to the documentation
//
// ***************************************************************************************
// The general idea is to run your map according to a global timer, instead of creating
// and destroying any number of individual timers, because as a rule we try to cut down
// on trigger events and function calls during the execution of a map, and CreateTimer(),
// DestroyTimer(), and espeically TimerStart(...) and the associated triggers will lag your
// shit up, that's a gaurentee. Several maps already incorporate global event timers into
// themselves, this is just a premade package that will allow you to easily do so in your
// map.
//
// ***************************************************************************************
// This trigger set uses vJass. The only other effective system for doing this sort of
// would be to use gamecache based handle var systems, which in rare cases are buggy,
// but can also slow the game excessively.
//
// ***************************************************************************************
//
// This is how this pacakage will create new timer operated units:
// Step 1) Create a Unit
// Step 2) Create a timer structure (Techno_TimerUnitOnTimerHandle)
// Step 3) Assign a struct of type Techno_GunUnitAttach to the unit's custom value
// using ABC attachment system
// Step 4) Create a function with the following arguements:
// function NAME takes unit interface_unit returns nothing
// Step 5) Assign the unit and an associated function to the timer
// the timer can now automatically pick out the unit's necessary
// custom values from the attached
// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// EXAMPLE
// call YOUR_TIMER_STRUCT_NAME.Timer_Add_Unit( YOUR_UNIT_NAME, UNIT'S_FUNCTION_NAME )
// Obviously, replace the stuff in all caps with your names
// '''''''''''''''''''''''''''''''''''''''''''''''''''''''''
// Step 5) Activate the timer if necessary. The timer will automatically pass the unit
// to the required function.
// Step 7) Any additional data you wish to pass can be passed in the structure you
// assigned in the Unit's custom value. This allows total modularity, because
// any function that can access the unit can access all of the values that are
// involved in the function
//
//
// I would love some help textmacroing this up to be more modular, so that the unit
// can take differently named structs, and the function interface can take different
// arguements if the user so desires.
globals
constant integer MAX_UNITS = 64
endglobals
function interface INTERFACE takes unit interface_unit returns nothing
struct Techno_TimerUnitOnTimerHandle
private timer T_Timer = CreateTimer()
private unit array Unit_Array[MAX_UNITS]
private INTERFACE array Unit_Funcs_Array[MAX_UNITS]
private real cooldown = .01
private integer Num_Units = 0
method Timer_Add_Unit takes unit u, INTERFACE f returns nothing
if (this.Num_Units <= MAX_UNITS) then
set this.Unit_Array[this.Num_Units] = u
set this.Unit_Funcs_Array[this.Num_Units] = f
set this.Num_Units = this.Num_Units + 1
else
call BJDebugMsg("Unit Cap Reached on Timer")
endif
set u = null
endmethod
method Timer_Get_Last_Unit takes nothing returns unit
local unit u = this.Unit_Array[this.Num_Units]
return u
endmethod
method Timer_Remove_Last_Unit takes nothing returns nothing
set this.Unit_Array[this.Num_Units] = null
set this.Num_Units = this.Num_Units - 1
endmethod
// ***AWAITING IMPLEMENT***
method Timer_Remove_Unit_Enum takes integer unum returns nothing
//This one could use rescripting...
endmethod
//This function is the function on the timer trigger
method Timer_Action_Functions takes nothing returns nothing
local integer i = 0
local unit u
local Techno_GunUnitAttach gattach = Techno_GunUnitAttach.create()
local INTERFACE f
loop
exitwhen i > this.Num_Units
//Get Function Attached GunStruct
set u = this.Unit_Array<i>
set gattach = GetUnitUserData(u)
//***AWAITING IMPLEMENT***
//***CHECK COOLDOWN OF UNIT TRIGGER***
//Get associated function of gunstruct
set f = this.Unit_Funcs_Array<i>
call f.execute(u)
set i = i + 1
endloop
set u = null
endmethod
method Timer_SetCooldown takes real cd returns nothing
set this.cooldown = cd
endmethod
//***AWAITING IMPLEMENT***
//For some reason, the following line of code bugs.
method Timer_TimerStart takes nothing returns nothing
// call TimerStart(this.T_Timer, this.cooldown, true, this.Timer_Action_Functions)
endmethod
endstruct
struct Techno_GunUnitAttach
integer timercounter //counts timer iterations
integer projectile_unit
//targetting declares
integer targetting_function_type = 2
unit targ1_targettingunit
real targ2_fixedx
real targ2_fixedy
real targ3_angle
method SetProjectileType takes integer UnitType returns nothing
set this.projectile_unit = UnitType
endmethod
method GetProjectileType takes nothing returns integer
return this.projectile_unit
endmethod
method GetTimerCounter takes nothing returns integer
return this.timercounter
endmethod
method GetTargLocX takes nothing returns real
if (this.timercounter == 1) then
return GetUnitX(this.targ1_targettingunit)
elseif (this.timercounter == 2) then
return this.targ2_fixedx
endif
return 0.
endmethod
method GetTargLocY takes nothing returns real
if (this.timercounter == 1) then
return GetUnitY(this.targ1_targettingunit)
elseif (this.timercounter == 2) then
return this.targ2_fixedy
endif
return 0.
endmethod
method GetTargFixedAngle takes nothing returns real
return this.targ3_angle
endmethod
method CalcTargAngle_targ1 takes real sourceX, real sourceY returns real
return (bj_RADTODEG * Atan2( (GetUnitY(this.targ1_targettingunit) - sourceY ), (GetUnitX(this.targ1_targettingunit) - sourceX) ))
endmethod
method CalcTargAngle_targ2 takes real sourceX, real sourceY returns real
return (bj_RADTODEG * Atan2( (this.targ2_fixedy - sourceY ) , ( this.targ2_fixedx - sourceX ) ) )
endmethod
method GetTargUnit takes nothing returns unit
return this.targ1_targettingunit
endmethod
method GetTargFuncType takes nothing returns integer
return this.targetting_function_type
endmethod
// method SetProjectileTargType takes integer t returns null
// set this.targetting_function_type = t
// endmethod
method Init takes unit u, integer i returns nothing
set this.targetting_function_type = i
set this.timercounter = 0
set this.projectile_unit = 039;nfro039; //make sure to change this if your shit is coming out in frogs, dumbass.
set this.targ2_fixedx = 0.
set this.targ2_fixedy = 0.
set this.targ3_angle = 0.
endmethod
endstruct
library TechnoGunSystem uses ABC
function TGSLinearMove takes unit interface_unit returns nothing
//Move unit in a straight line according to distance every tick
endfunction
function TGSArcMoveByAngle takes unit interface_unit returns nothing
//Move unit and adjust move angle each time.
endfunction
function TGSArcMoveByDxDy takes unit interface_unit returns nothing
//Move unit in an arc pattern, and use distance modifiers instead of angle modifiers
endfunction
function TGSMathFuncMove takes unit interface_unit returns nothing
//Move unit following a mathematical function.
endfunction
function TGSLinearMove_AdjustWithMathFunc takes unit interface_unit returns nothing
//Moves unit following the path of a straight line, and adjusts the pathing of the unit using a mathematical function
endfunction
function TGSCollision_Detect takes unit interface_unit returns nothing
local trigger trig = GetTriggeringTrigger()
//Get applicable units
//Get EFFECTS functions
//Apply EFFECTS to target
//Clean Up Trigger
//Remove Triggering Unit from the Game
endfunction
endlibrary</i></i>
First syntax error:
JASS:
Second syntax error:
JASS:
// method SetProjectileTargType takes integer t returns null
// set this.targetting_function_type = t
// endmethod
The appropriate crap is commented out right now, however, for the first one, I'm stumped, for the second one, I'm stumped.
Import this and ABC into a map, uncomment, and try to compile to see what I mean.