Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 JASS.com
"The Jass Vault" plus vJASS and Zinc
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Triggers & Scripting
WC3JASS.com
General Jass Discussion
[HELP] Improving Effect over time code
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation
-
Zinc documentation
-
WC3 Optimizer documentation
[HELP] Improving Effect over time code
General Jass Discussion
Started by
moyack
Views
7793
Replies
2
Users
2
2
1
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
[HELP] Improving Effect over time code
on:
January 18, 2012, 11:18:05 PM
Hi:
In my project PoC, I use a system that manages several effects over time with few timers, so all the hero abilities with
EoT
, were handled with few timers. When the map had few players (4 to be exact), it worked properly. But now that I'm testing passing the map code into larger maps, the code starts being slow and buggy.
My first approach was to implement a interface with some stub methods, but after reading
this tutorial
and
this other
, I've decided to start improving this procedure.
Code: jass
library
Indexor
struct
Indexer
extends
array
trigger
t
real
dt
method
AddCode
takes
code
c
returns
nothing
call
TriggerAddAction
(.t, c)
endmethod
static
method
create
takes
real
t
returns
thistype
local
thistype
D =
thistype
.
allocate
()
if
D.t ==
null
then
set
D.t =
CreateTrigger
()
endif
set
D.dt = t
call
TriggerRegisterTimerEvent
(D.t, D.dt,
true
)
return
D
endmethod
endstruct
function
AddPeriodicCheck
takes
Indexer I,
code
c
returns
nothing
call
I.AddCode(c)
endfunction
endlibrary
Is this code by itself slow?? Could you suggest a way to improve this?
WC3 Modding Information Center
Magtheridon96
Awesome Global Code Moderator
Recognized User
Posts:
84
WC3 Models: 0
WC3 Tutorials: 0
WC3 Tools: 0
WC3 Maps: 0
WC3 Skins: 0
WC3 Icons: 0
WC3 Spells: 0
Reputation:
516
vJass Incarnate
Re: [HELP] Improving Effect over time code
Reply #1 on:
January 23, 2012, 06:11:02 PM
Well, TriggerRegisterTimerEvent is a pretty slow native :p
It doesn't matter much though, I like how you can easily add code into it
Still, maybe looping through a boolexpr array would be better :/
Or maybe having a trigger only to store the boolexprs and codes and a timer for the looping would be awesome
And you can use TriggerAddCondition if you pass the code to function Filter(takes code)
Oh and when you make a struct extend an array, allocate and deallocate are gone
You should use your own allocation and deallocation procedures.
If you don't want a destroy method, just use a simple integer that you increase whenever allocating
Else a simple dynamic indexing snippet like the one from Nestharus' tutorial would suffice ^.^
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
Re: [HELP] Improving Effect over time code
Reply #2 on:
January 25, 2012, 09:13:47 PM
That's actually a pretty cool idea. Here's the new code:
Code: jass
globals
private
constant
key
A
endglobals
struct
Indexor2
extends
array
timer
t
trigger
tr
real
period
static
integer
count = 1
private
static
method
evaluate
takes
nothing
returns
nothing
call
TriggerEvaluate
(
thistype
(GetData(
GetExpiredTimer
(), A)).tr)
// this function is from one simplified table I have in my map
endmethod
method
AddCode
takes
code
c
returns
nothing
// this code should return a boolean to keep consistency
call
TriggerAddCondition
(.tr,
Condition
(c))
endmethod
static
method
create
takes
real
period
returns
thistype
local
thistype
this
=
thistype
(
thistype
.count)
set
thistype
.count =
thistype
.count + 1
set
this
.t =
CreateTimer
()
set
this
.tr =
CreateTrigger
()
set
this
.period = period
call
StoreData(
this
.t, A,
integer
(
this
))
// this function is from one simplified table I have in my map
call
TimerStart
(
this
.t, period,
true
,
function
thistype
.
evaluate
)
return
this
endmethod
endstruct
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Triggers & Scripting
WC3JASS.com
General Jass Discussion
[HELP] Improving Effect over time code
Suggested Topics
vJASS Syntax Highlighter for notepad++
Started by
moyack
Replies: 2
Views: 6131
WC3 Editing Tools
Jassdoc introduction
Started by
moyack
Replies: 3
Views: 4229
Jassdoc
The Jass NewGen Pack (JNGP) 2.0
Started by
moyack
Replies: 225
Views: 315334
WC3 Editing Tools
coding efficient vjass structs
Started by
nestharus
Replies: 0
Views: 2288
Jass Tutorials
wc3jass.... R.I.P??
Started by
moyack
Replies: 1
Views: 8085
Tavern
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?