Bribe
vJass errors are legion
- Reaction score
- 67
I meant at what float-value
Would it be .03, 0.01, 0.00125 or what?
Would it be .03, 0.01, 0.00125 or what?
Jesus4Lyf said:This is, at the time of release, the most efficient timer system in existance.
//////////
// TAZO //
////////////////////////////////////////////////////////////////////////////
// KT2 implementation for higher periods (low frequency).
globals
private constant integer TAZO_DATAMEM=8190 // Added for KT2 hook. Don't change.
endglobals
globals
private conditionfunc TAZO_LoadDataCond
private conditionfunc TAZO_RemoveInstanceCond
private timer array TAZO_TrigTimer
private integer array TAZO_Data
private boolexpr array TAZO_Boolexpr
private trigger array TAZO_AvailableTrig
private integer TAZO_Max=0
private integer TAZO_ConstructNext=0
private trigger array TAZO_ConstructTrig
private integer array TAZO_ConstructCount
endglobals
globals//locals
private integer TAZO_ConKey
endglobals
private function TAZO_Constructer takes nothing returns boolean
set TAZO_ConKey=GetData()
call TriggerExecute(TAZO_ConstructTrig[TAZO_ConKey])
set TAZO_ConstructCount[TAZO_ConKey]=TAZO_ConstructCount[TAZO_ConKey]-1
if TAZO_ConstructCount[TAZO_ConKey]==0 then
set TAZO_Max=TAZO_Max+1
set TAZO_AvailableTrig[TAZO_Max]=TAZO_ConstructTrig[TAZO_ConKey]
set TAZO_TrigTimer[TAZO_ConKey]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AvailableTrig[TAZO_Max],TAZO_TrigTimer[TAZO_ConKey])
return true
endif
return false
endfunction
globals//locals
private trigger TAZO_DeadTrig
private integer TAZO_DeadCount
endglobals
private function TAZO_Recycle takes nothing returns boolean
set TAZO_DeadTrig=GetTriggeringTrigger()
set TAZO_DeadCount=GetTriggerExecCount(TAZO_DeadTrig)
call TriggerClearConditions(TAZO_DeadTrig)
call DestroyBoolExpr(TAZO_Boolexpr[TAZO_DeadCount])
call PauseTimer(TAZO_TrigTimer[TAZO_DeadCount])
set TAZO_Max=TAZO_Max+1
set TAZO_AvailableTrig[TAZO_Max]=TAZO_DeadTrig
return false
endfunction
private function TAZO_LoadData takes nothing returns boolean
// KT2 Data Hook
set t_mem=TAZO_DATAMEM
set Data[TAZO_DATAMEM]=TAZO_Data[GetTriggerExecCount(GetTriggeringTrigger())]
// End KT2 Data Hook
return false
endfunction
private function InitTrigExecCount takes trigger t, integer d returns nothing
if d>128 then
call InitTrigExecCount.execute(t,d-128)
set d=128
endif
loop
exitwhen d==0
set d=d-1
call TriggerExecute(t)
endloop
endfunction
globals//locals
private integer TAZO_AddKey
private trigger TAZO_AddTrigger
endglobals
public function TAZOadd takes code func, integer data, real period returns nothing
if TAZO_Max==0 then
// Failsafe.
set TAZO_ConstructNext=TAZO_ConstructNext+1
set TAZO_AddTrigger=CreateTrigger()
set TAZO_AddKey=TAZO_ConstructNext
call InitTrigExecCount.execute(TAZO_AddTrigger,TAZO_AddKey)
set TAZO_TrigTimer[TAZO_AddKey]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AddTrigger,TAZO_TrigTimer[TAZO_AddKey])
else
set TAZO_AddTrigger=TAZO_AvailableTrig[TAZO_Max]
set TAZO_AddKey=GetTriggerExecCount(TAZO_AddTrigger)
set TAZO_Max=TAZO_Max-1
endif
set TAZO_Data[TAZO_AddKey]=data
set TAZO_Boolexpr[TAZO_AddKey]=And(Condition(func),TAZO_RemoveInstanceCond)
call TriggerAddCondition(TAZO_AddTrigger,TAZO_LoadDataCond)
call TriggerAddCondition(TAZO_AddTrigger,TAZO_Boolexpr[TAZO_AddKey])
call TimerStart(TAZO_TrigTimer[TAZO_AddKey],period,true,null)
if TAZO_Max<10 then
set TAZO_ConstructNext=TAZO_ConstructNext+1
set TAZO_ConstructTrig[TAZO_ConstructNext]=CreateTrigger()
set TAZO_ConstructCount[TAZO_ConstructNext]=TAZO_ConstructNext
call KTadd(function TAZO_Constructer,TAZO_ConstructNext,TAZO_CONSTRUCT_PERIOD)
endif
endfunction
private function TAZOinit takes nothing returns nothing
set TAZO_LoadDataCond=Condition(function TAZO_LoadData)
set TAZO_RemoveInstanceCond=Condition(function TAZO_Recycle)
// Allow for GetData
set Next[TAZO_DATAMEM]=TAZO_DATAMEM
set Prev[TAZO_DATAMEM]=TAZO_DATAMEM
// End allow for GetData
loop
exitwhen TAZO_Max==TAZO_PRECACHE
set TAZO_ConstructNext=TAZO_ConstructNext+1 // The index.
set TAZO_Max=TAZO_Max+1 // Will be the same in the initialiser as ConstructNext.
set TAZO_AvailableTrig[TAZO_Max]=CreateTrigger()
call InitTrigExecCount.execute(TAZO_AvailableTrig[TAZO_Max],TAZO_ConstructNext)
set TAZO_TrigTimer[TAZO_ConstructNext]=CreateTimer()
call TriggerRegisterTimerExpireEvent(TAZO_AvailableTrig[TAZO_Max],TAZO_TrigTimer[TAZO_ConstructNext])
endloop
endfunction
See, structs allow you to make your own types, like integers and units and locations. I mean, what is a location but two reals? Then, you have methods.
[/JASS]
I'm not sure if this is right, but I believe you can use the AIDS Struct for that. AIDS is Jesus4Lyf's powerful and pretty amazing indexer that provides a textmacro (he says he'll make it a module, but he hasn't yet) that allows you to give units additional stats, sort of, like more attributes for units. It's all abstract, but it's pretty cool.
// Note: Comment serves no purpose.
private struct Creep extends array // You always extend array.
//! runtextmacro AIDS()
private method AIDS_onDestroy takes nothing returns nothing
call TriggerSleepAction(3.00)
call ReviveUnit(this.unit) // Pretend it exists.
endfunction
private static method AIDS_filter takes unit u returns boolean
if GetUnitTypeId(u)==039;hfoo039; then
return true
endif
return false
endmethod
endstruct
// Note: Comment serves no purpose.
library Placeholder uses AIDS
private struct Data extends array //All AIDS structs extend array.
boolean holy // A regular struct member.
trigger t
private static method AIDS_filter takes unit u returns boolean
/* This method lets you decide who you want to index in this
struct. If the function returns true, unit u will be indexed
into the struct. */
return true
endmethod
private method AIDS_onCreate takes nothing returns nothing
//All things in here will be done when a unit is created in the map
//and the filter returns true. Refer to the unit as this.unit.
set this.holy=true // Give the boolean a default value of true.
set t=CreateTrigger()
//Pretend right here we register a function to run when a unit
//is killed, with the callback method being onKill.
endmethod
method onKill takes nothing returns nothing
if GetKillingUnit()==this.unit then // If this is the indexed unit,
set this.holy=false//They killed the unit, they aren't holy anymore.
endif
endmethod
endstruct
endlibrary
No, the onKill method isn't a part of AIDS, I made that myself. Remember, read the comment, I 'pretended' to register that in the AIDS_onCreate method.Okay, this added a little more understanding. How do I access information from OUTSIDE the structure (aka, the functions and triggers?) So, my unit dies, does AIDS run the structure for that unit's onKill method? Or do I have to initiate something to make it register that event for that unit. I think I see how I have to register the trigger to activate on death, right? So I just register the event with this.unit onCreate and tell it to run the onKill method when the trigger executes, is that right? Then as long as everything is run inside of the AIDS structure, I don't need any external functions to make anything work? Is that a good summary?
All your programming should be done inside the struct. I can't really help since you're not being specific.So then I have every function that modifies a unit's structure INSIDE the structure as a method, then it will work fine? Sounds a lot simpler than what I've been doing. Unfortunately, I have some triggers that modify TWO unit's stats at the same time. How would I make that work?
You would have to store all of that in the struct though, anything you want to save, but I think you can do something like this.Okay, last thing I think I need to learn how to do with this system before I am sold on it. I have a unit that changes classes, and when he goes from one class to the next, certain qualities transfer, certain qualities stay in memory and decay over time (but can be transfered to the structure of the new unit), so what if I have AIDS with my system? If I have my hero change classes (create a new unit) then how would I easily transfer over his information? It looks like if I could just get the index value he represents, then change the unit that corresponds to his index, that everything would transfer fine.
set this.unit=CreateUnit(...)