HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Oh no mye trigger wont work!

04-09-2004, 03:06 PM#1
macho271
Hello, I have a few questions..

The first one:
I want a trigger like this: when a unit (say pesant) enters regions, the player of owning unit will earn 10 gold per 5 seconds. When the same unit leave region stop earning money..

I did it this way:
Quote:

- Trigger 1 -*Event*
Unit - A unit enters region 1
Unit - A unit enters region 2
Unit - A unit enters region 3
Unit - A unit enters region 4

*conditions*
(unit type of (triggering unit)) equal to pesant

*actions*
Wait 5 seconds
trigger - Turn on trigger 2
trigger - run trigger 2

- Trigger 2 -
*events*

*conditions*
(unit type of (triggering unit)) equal to pesant

*actions*
Player - add 10 to (owner of triggering unit current gold
wait 5 seconds
Trigger - run trigger 3

- Trigger 3 -

*events*

*conditions*
(unit type of (triggering unit)) equal to pesant

*actions*
Player - add 10 to (owner of triggering unit current gold
wait 5 seconds
Trigger - run trigger 2

- Trigger 4 -
*events*
A unit leaves region 1
A unit leaves region 2
A unit leaves region 3
A unit leaves region 4

*condition*
(unit type of (triggering unit)) equal to pesant

*events*
trigger - turn off trigger 2

The problem is that when the unit leaves the region the player still earns money...




Question 2
How can I get a Custom made Loading screen, I tried to follow a tutorial but it did not work.. Can somebody tell me how?
04-09-2004, 03:55 PM#2
The Gearhead
It looks like you've got an infinite loop between trigger 2 and 3. Try using a countdown timer or game timer at a repetative cycle such as every half second.

Try creating a variable which is defined in Trigger 1, and used by Trigger 2 to define gold usage. Or ... wait a sec.

E
Unit enters region 1-4

C
Unit of type is equal to peasant

Run Trigger 2


A
wait .5 seconds
If/Then/Else
If Rect - Is Unit in Region //For this I'd use Triggering Region and Triggering Unit. This is WEUnlimited only!

Else Give gold to owner of triggering unit
Run trigger (this trigger)


Obviously I'm not the best programmer, and I'm a novice at this. But I think that will work. It should give a gold amount every .5 seconds for the unit contained.


It might not work, I'll reexamine this later if the solution isnt found.
04-09-2004, 04:25 PM#3
Savage1
Hi
I think this might work

Trigger1
Events:
Unit enters region X

Condition:
Entering unit equal to peasant

Action:
Turn on trigger2
Turn on trigger3
( if you wish to make various regions, then make a trigger for each one. If you wish that only a peasant per player activates then you must also put "Turn off this trigger".)


Trigger2
Event:
Every 10 seconds of game time

Conditions:

Actions:
Add 10 gold to owner of peasant

Trigger3
Events:
Unit leaves region X

Condition:
Leaving unit equals to peasant

Action:
Turn off trigger2
Turno on trigger1
Turn off this trigger

Hope this has helped you in your quest to make the warcraft universe a better place
04-09-2004, 06:22 PM#4
The Gearhead
Player 1 Gold Event

Event: Periodic Event ~ Every .25 Seconds of Game Time

Conditions
+ And
~ + Or
~ ~ - Boolean Comparison: Unit is in Rect [1] // could be region for normal WE
~ ~ - Boolean Comparison: Unit is in Rect [2]
~ ~ - repeat for regions
~ - Unit Owned By Player 1
~ - Unit-Type of (triggering unit) is equal to Peasant

Actions:
- Give player 1 10 gold


Repeat this trigger for each player. Adjust the trigger time as necessary. Try not to go below .10 as there will be multiple triggers executing simultaneously. One way to make this smoother is to make this on Map Initialization

Events
- Map Initialization

Actions
- Run trigger (Player 1 Gold Peasant Thingy)
- Wait .01 seconds
- Run trigger (Player 2 Gold Peasant Thingy)

This will desync the triggers by a miniscule, but calculable amount, so there is no chance of an old crappy computer hanging.


Edit, ignore this for now I am working out something. (Triggering unit) would obviously not work as there is no unit event.


I'd make an enable/disable trigger with the trigger above... and switch Player 1 with triggering player.
04-09-2004, 06:30 PM#5
CrazyAznDanger
Wrong forum... A moderator should move this thread to the trigger haven.
04-09-2004, 06:51 PM#6
The Gearhead
For multiple units and/or players... this is what I'd do if I were to fully hash this out...

Create 1 variable, with an array size equal to the number of players that can execute the trigger. For this example the variable will be labeled InsanelyLongVariableThatsEasyToSpot ok. And the gold variable will be InsanelyEasyToTellGoldInteger

Trigger 1 (Enter Trigger)
Event:
~ Unit Enters Region
~ Unit Enters Region
(Repeat as neccessary)

Condition:
~ Unit-type of (triggering unit) is equal to Peasant

Action:
+ For (Integer A) 1 through 12 //Set this
~ + Loop
~ ~ ~ + If/Then/Else (Multiple)
~ ~ ~ ~ + If
~ ~ ~ ~ ~ - (Triggering Unit) is owned by (Player Index (Integer A))
~ ~ ~ ~ + Then
~ ~ ~ ~ ~ - Set InsanelyLongVariableThatsEasyToSpot[Integer A] to (InsanelyLongVariableThatsEasyToSpot[IntegerA] + 1)
~ ~ ~ ~ + Else
~ ~ ~ ~ ~ - Do Nothing (I don't think this is required, however)

Trigger 2 (Leave Trigger)
Event:
~ Unit Leaves Region
~ Unit Leaves Region
(Repeat as neccessary)

Condition:
~ Unit-type of (triggering unit) is equal to Peasant

Action:
+ For (Integer A) 1 through 12 //Set this
~ + Loop
~ ~ ~ + If/Then/Else (Multiple)
~ ~ ~ ~ + If
~ ~ ~ ~ ~ - (Triggering Unit) is owned by (Player Index (Integer A))
~ ~ ~ ~ + Then
~ ~ ~ ~ ~ - Set InsanelyLongVariableThatsEasyToSpot[Integer A] to (InsanelyLongVariableThatsEasyToSpot[IntegerA] - 1) //When copying the trigger, be sure to change the + to a -... I boldened it but it may not be visible.
~ ~ ~ ~ + Else
~ ~ ~ ~ ~ - Do Nothing (I don't think this is required, however)

Trigger 3 (Hands Out Gold)
Events:
~ Periodic Event: Every .25 Seconds of Game Time

Actions:
+ For [Integer A] 1 through 12 //Change this as needed
~ + Loop
~ ~ - Add (InsanelyLongVariableThatsEasyToSpot[Integer A] x InsanelyEasyToTellGoldInteger) to PlayerIndex(IntegerA) Current gold

So, if you have 2 peasants, double the gold fun. Etc.
04-09-2004, 09:07 PM#7
macho271
Thanks for fast answering! :)

But back to question 2! :)

I havent tried your replies yet, but im going to later..! :D
04-09-2004, 10:03 PM#8
The Gearhead
I suggest getting World Editor Unleashed 2, and then using the WEU Enhancer to put in a loading screen.

BE WARNED... it will drastically increase the filesize of your map!
04-10-2004, 12:03 AM#9
macho271
Damn, really cant get it to work..
Tried some of the suggestion (not the one with all the arrays, variables +, to hard)..

The thing is that I cant turn my trigger off.. Say I have the trigger i started with.. Cant turn it off.. Because its running??


And one more thing.. The (TIME -PERIODIC EVENT) Event doesent work at all.. tried to turn it on by a trigger, but no..

I also tried to just have it on, and not to be turn on by a trigger, but it does'nt work at all..

event:
Time - Every 5 seconds of game time

action:
Player - add 10 to player 1 Current gold
04-10-2004, 01:15 AM#10
The Gearhead
I'm telling you, the trigger I gave you will work, and there is no turning on or turning off required. All three triggers simply run simultaneously and automatically add gold to players, add gold to be given periodically, or subtract gold to be given periodically.

If you are new to Arrays and Variables, now is always a good time to get acquainted with the most powerful tools available in the world editor. I'd have to say local variables are mighty good, but I'm pretty sure WEUnleashed allows some minor local variables through the GUI.
04-10-2004, 01:19 AM#11
Aznwhore
i dun think he understands the trigger ur using...
the triggers i've seen him posting are the basic of wc triggering
04-10-2004, 07:15 AM#12
The Gearhead
Okay, here's some basics that might help you. (as in him, not the poster right above me)

Variables are set using Ctrl-B (at least, thats the shortcut I use).

Then, when a variable is defined, it can be redefined as often as you want.

In Warcraft, a Variable Array lets you create something like this:
VariableName[0] =
VariableName[1] =
ad infinitum (up to the size of the array).

Well, when you use a variable that has an array, you can make it even more flexible through "For" Loops.

"+ For [Integer A] 1 through 12 //Change this as needed
~ + Loop
~ ~ - Add (InsanelyLongVariableThatsEasyToSpot[Integer A] x InsanelyEasyToTellGoldInteger) to PlayerIndex(IntegerA) Current gold"

In that "For" loop, I use 2 variables and the Integer A "local" variable which ceases upon the ending of the trigger. (Am I right on this, pro coders?)

So, the For Loop specifies that the actions in the "Loop" part are run for each Integer A which is, in this case, 1 through 12.

In this case, I use "Player Index(Integer A)" because it allows me to apply a setting to each player, 1 through 12, with only one trigger. Pretty useful, huh?


Let's go through each trigger.

Trigger 1 (Enter Trigger)
Events are obvious (unit enters region)

Condition:
~ Unit-type of (triggering unit) is equal to Peasant

Pretty obvious...


Action:
+ For (Integer A) 1 through 12 //Set this
~ + Loop

Okay, see, I entered a Loop. Which means that the actions in the loop are 'run' for each integer I have set. In this situation, it is 1 through 12.

~ ~ ~ + If/Then/Else (Multiple)
~ ~ ~ ~ + If
~ ~ ~ ~ ~ - (Triggering Unit) is owned by (Player Index (Integer A))

In the IF part of this if/then/else, I am determining whether or not the unit is owned by a certain player. By doing this, I am absolutely certain that the "Then" will only change the unit properties that I want. This way, if a unit for player 2 enters the region, it will do things relating to player 2, and not player 1.

~ ~ ~ ~ + Then
~ ~ ~ ~ ~ - Set InsanelyLongVariableThatsEasyToSpot[Integer A] to (InsanelyLongVariableThatsEasyToSpot[IntegerA] + 1)

The "InsanelyLongVariablEThatsEasyToSpot[IntegerA]" is an Array, which possesses a row size of 12. (We wont get into n-1 formatting)

So, what this does is... if a Peasant owned by Player 1 enters one of the "Event" regions, then:
InsanelyLongVariableThatsEasyToSpot[1] is increased by 1. So, if it was 0. It is now 1. If it was 2, it is now 3.

~ ~ ~ ~ + Else
~ ~ ~ ~ ~ - Do Nothing (I don't think this is required, however)
This makes it ignore incorrect Player/Unit combinations (Unit owned by player 2, and Integer A is 1 at that specific moment)



Trigger 2 works the same way, but instead of going from 0 to 1, it decreases the value of the variable. So if it was 1, it becomes 0.



Final trigger:
Trigger 3 (Hands Out Gold)
Events:
~ Periodic Event: Every .25 Seconds of Game Time

<This keeps it consistent>

Actions:
+ For [Integer A] 1 through 12 //Change this as needed
~ + Loop
~ ~ - Add (InsanelyLongVariableThatsEasyToSpot[Integer A] x InsanelyEasyToTellGoldInteger) to PlayerIndex(IntegerA) Current gold

Okay, let me stretch this out so it doesnt look like gibberish. I will shorten "InsanelyLongVariableThatsEasyToSpot" to "Spot" and "InsanelyEasyToTellGoldInteger" to "GoldInt"

Add (Spot[Integer A] x GoldInt) to PlayerIndex(IntegerA) Current gold

You remember from the "For Loop" that it does it for integer A 1 through 12

So, it first does:

Add (Spot[1] x GoldInt) to PlayerIndex(1) Current gold

So, lets say Player 1 has 2 peasants in one of our regions from the triggers above.

This means he will get Spot[1] = 2. And lets say its 20 gold per second, per peasant in those regions. Then we set GoldInt to "5" in the Variables section. That's because 20 times .25 (the repeating-ness) is 5.

So, Spot[1] = 2, and GoldInt = 5.

Add (2 x 5) to PlayerIndex(1) Current Gold

Or
Add 10 to Player 1's Current gold


If there were 3 units, it would add 15.

Change the periodic time to mesh with the gold per second. So if you wanted 10 gold per second, per unit. Set gold int to 5, and set the "Periodic" time to half a second. 5 x 2 = 10.
04-10-2004, 12:48 PM#13
macho271
Hehe, Im noob at Variables and that stuff, never used it. I got it working, sat down to think, and, suddenly I tried to make different trigger for each player (hard work) but i finally got i working! ;)
So, now I think I have to learn arrays and vaiables..! But can somebody tell me why I should use it?
Never undertood it..!

And one more thing, say I have 20 regions over the map that the peasent can earn money in, is there a way to group those regions together? Do I have to use variables then?

Are there any good tutorials here on variables for noobs? :>
04-10-2004, 03:07 PM#14
The Gearhead
If you have UMSWorld Editor or WEUnleashed, you can make a trigger that groups all those "rectangles" into a region. Then you can use that single region for each trigger.