HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Making a t Controlling the map

06-26-2003, 11:57 AM#1
Vexorian
Introduction

Yesterday I found that my map had 10 different Triggers with the "time - periodic event" Event. That maked my map really laggy in some computers and I found that it was completely Unnecesary.

Now I will explain you how to do all the periodic actions you want to do with only ONE periodic event.

Improving your map
We will take this Example:

A hero Arena that requires:
a) A trigger That Checks if somebody quit each 5 seconds
b) A trigger that spawns Creeps each 30 seconds
c) Another trigger that spawns Creeps each 50 seconds
d) A trigger that orders The computers to do something each 10 seconds.
e) A trigger that Shows a Random Text message each 35 seconds
f) A trigger that creates an item for the losing team each 300 seconds.

Well with that options we have an only map with 6 Periodic Events Inside!

Now To improve the Map:

- Create a variable called "t" with an initial value of 0 (t is an integer)

- Create a trigger called timecontroll then
PHP Code:
EventsEach 5 seconds
Conditions
: (You may want some)
Actions:
set t 

Now we need to place there the triggers
-The first one has to be run each 5 seconds, then we add to the actions:

PHP Code:
Run Player Quits (Checking conditions

The second one requires to be run each 30 seconds, here is were we need the t variable If you take a look to the trigger above Each 5 seconds t is increased in one point so to now the real time you only have to do Time = t * 5 , But we don't really need that.

But if we want to make a trigger to Run each 30 seconds we can do this little trick:

(The next is an integer comparision)
PHP Code:
If ((t mod 6equal to 0then Run Spawn Creep (Checking conditions) Else Do nothing 

- Why a 6 ? will you ask, well just because 30 / 5 = 6
- What is this mod function ? would you ask
You can find it in Math - Modulo . This function does this:

======you don't need to understand this, and my English is not the best to explain this, so it may be better to skip it =======

When you divide 20 with 3 You get a result of 6 and a Residual of 2 - With The modulo you get the Residual

==============================================

The next trigger repeats each 50 seconds - And in fact it is the same Spawn creep trigger We will change the Last line

PHP Code:
If ((t mod 6equal to 0then Run Spawn Creep (Checking conditions) Else IF ((t mod 10equal to 0then Run Spawn Creep (checking Conditions) Else do nothing 

50 / 5 = 10

The Remaining triggers are:
d) A trigger that orders The computers to do something each 10 seconds. So 10/ 5 = 2
e) A trigger that Shows a Random Text message each 35 seconds
So 35 / 5 = 7
f) A trigger that creates an item for the losing team each 300
seconds.
So 300 / 5 = 60


PHP Code:
If ((t mod 2equal to 0then Run CompuOrder (Checking conditions) Else (do nothing)
If ((
t mod 7equal to 0then Run Message (Checking conditions) Else (do nothing)
If ((
t mod 60equal to 0then Run Help losing Team (Checking conditions) Else (do nothing

Now we remove the Periodic Events for the triggers.


Final notes
If you have triggers that require something like each 12 seconds and each 37 seconds - You can't use an each 5 seconds Event - You need to use each 1 Second, But remember that in the (t mod X) condition you have no longer to divide the time with 5 to get X

Something Like This

- Trigger A runs each 37 seconds
- Trigger B runs each 12 seconds

Then The time trigger should be like:
PHP Code:
EventsEach 1 second (s)
Conditions:
Actions
If ((
t mod 37equal to 0then Run Trigger A (checking conditions)
If ((
t mod 12equal to 0then Run Trigger B (checking conditions
06-26-2003, 06:27 PM#2
theJ89
But... can you explain why this is better besides organization?
06-27-2003, 11:36 AM#3
Vexorian
My map is now less laggy than before - And you can turn off the Trigger to Stop the Time when the game is paused.
06-29-2003, 01:49 AM#4
DemonicSoul
just a comment vexorian, your english is better than a lot of english speaking people... now thats pretty sad if you think your english is bad lol
06-29-2003, 09:30 AM#5
blubber
I think you found something that will greatly help mappers. :D Good work. :D