• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Trigger Problems!

Status
Not open for further replies.
Level 2
Joined
Jun 18, 2012
Messages
24
So I asked for help in the forums awhile ago and I thought I had fixed it, but it seems that it doesn't work anyways...

Imma post a printscreen becouse im lazy to type it all down, and to make sure it gets all right.
FdJfdD2.jpg

The problem here is that now 1 Elf spawns for everyone, including TempPlayer(wich is the badguy) and for those who are not playing, so lets say me and 3 others are playing the map, my friend X gets chosen as the badguy, and it still spawns 11 Elfs, inc for X.

Now for my second Problem, I have an income house wich triggers looks like this
  • Events
    • Unit - A unit begins construction
  • Conditions
    • (Unit-type of (triggering unit)) Equal to Castle
  • Actions
    • Trigger - Turn on Income <gen>
Income Trigger:
  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
  • Actions
    • For each (integer I) from 1 to 11, do (actions)
      • Loop - Actions
        • Set income[I] = (1x1)
        • Player - Add income[I] to (Player[I]) Current gold
It works fine, BUT it gives all the players the money, even the enemy. I have changed Player to (Triggering player) I can't test the map right now since i need some testers tho.
 
http://www.hiveworkshop.com/forums/miscellaneous-tutorials-456/how-easily-post-triggers-163285/

In your first trigger you may add conitions, if player is even in game and if it is not the enemy.

I dont understand your first comparrison "Player equals to tmpPlayer"

Also you have momory leaks, please read this: http://www.hiveworkshop.com/forums/triggers-scripts-269/things-leak-35124/
_________________________

To your second problem, this line:
  • Set Income[PlayerNumberOfTriggeringPlayer] =
move it in the trigger where you construct the castle (also change it from "start constructing" to "finished construction")

Also it's useless to set income = 1x1 , you might want something like:
  • Set Income[PlayerNumberOfTriggeringPlayer] = Income[PlayerNumberOfTriggeringPlayer] + 1
(it's just an arithmetic function)

Edit:

There is no need to turn on/off the income trigger.
 
Level 2
Joined
Jun 18, 2012
Messages
24
I know its useless to have 1x1, but it makes it easier in the following triggers.

My Triggers now looks like this
  • Events
    • Unit - A unit Finishes construction
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Castle
  • Actions
    • Set income[(Player number of (Triggering player))] = (1 x 1)
    • Player - Add income[I] to (Triggering player) Current gold
if I change (Triggering player) to (Player) it crashes the game
The above trigger does not work, how do I have multiple Events? since i already have the event finishes const. but since you told me to put in the set income trigger in the same one I also need the periodic event.
 
Level 2
Joined
Jun 18, 2012
Messages
24
Alrite, triggers now looks like this
  • Events
    • Unit - A unit Finishes construction
  • Conditions
    • (Unit-type of (Triggering unit)) Equal to Castle
  • Actions
    • Set income[(Player number of (Triggering player))] = (1 x 1)
And the income trigger wich is now always on(Initially on)
  • Events
    • Time - Every 1.00 seconds of game time
  • Conditions
  • Actions
    • For each (Integer I) from 1 to 11, do (Actions)
      • Loop - Actions
        • Player - Add income[I] to (Player(I)) Current gold
I think it works fine, it gives me money etc. Tho i don't know if its fixed, like i said i don't have the possibilities to test the map atm.

Now for the first problem with Elf spawn. I'm totally lost, ive read all in things in Things That Leak. But no idea how that should help me for the spawning. I do have a trigger similar to the one in Things that leak, Player Groups, but I have tempPlayerGroup.
 
Level 25
Joined
May 11, 2007
Messages
4,650

Err, shouldn't it be:

If Player is NOT tempPlayer:
set temppoint1 = random position in =select region=;
Create 1 elf for player at temppoint1;
custom script remove temppoint1;

Right now in the trigger you check if Player (which is a variable?) is tempPlayer, which will be true for every loop lap, thus creating units for all of them.

If you want to not have afk players, just add in:
If Player is NOT tempPlayer and boolean(Status of Player equal to Playing):

Or have a playergroup for all your players in one team and just do:
Playergroup - Pick every player in HolyAllianceTeamSuperL337Fighters and do:
set temppoint1 = random position in =select region=;
unit - create 1 unit for picked player at temppoint1;
custom script remove temppoint1;
 
Level 2
Joined
Jun 18, 2012
Messages
24
temppoint1 what kind of variable is that?
Also why not just create unit at random point in "spawn" region instead of that temppoint1?

And still no idea how to fix my leaks.
 
Level 25
Joined
May 11, 2007
Messages
4,650
Temppoint is a point variable.
When you create a unit at a random point in a region, Warcraft 3 will save that point for all the time that warcraft 3 is running, thus everytime you create a unit, more points will be saved, which will take up more memory, which will in the end slow the players computers and they be more likley to disconnect.

  • Set loc = Somewhere
  • Unit - Create 1 unit at loc
  • Custom script: call RemoveLocation(udg_loc)
 
Level 2
Joined
Jun 18, 2012
Messages
24
Temppoint is a point variable.
When you create a unit at a random point in a region, Warcraft 3 will save that point for all the time that warcraft 3 is running, thus everytime you create a unit, more points will be saved, which will take up more memory, which will in the end slow the players computers and they be more likley to disconnect.

  • Set loc = Somewhere
  • Unit - Create 1 unit at loc
  • Custom script: call RemoveLocation(udg_loc)

Alrite, so now it looks like this
  • Events
    • Time - Elapsed game time is 5.00 seconds
  • Conditions
  • Actions
    • Player Group - Pick every player in (All enemies of tempPlayer) and do (Actions)
      • Loop - Actions
        • Set temppoint1 = (Random point in troll spawn <gen>)
        • Unit - Create 1 Elf for (Picked player) at temppoint1 facing Default building facing degrees
        • Custom script: call RemoveLocation(udg_temppoint1)
It spawns 1 elf for Player 2(computer) when i test it in WE. But i guess thats a good sign
EDIT: It does not spawn one for me, but thats good because i get choosed as the "badguy"
 
Level 2
Joined
Jun 18, 2012
Messages
24
You leak a player group. Better you read link from above about memory leaks again.^^

It's no good habit to use a temp player variable like this. You should immediatly do actions if you set a temp variable instead of running this trigger without setting it right in there.

Ok I've read Things That Leak, should i just make a new trigger containing'
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Some Spell
  • Actions
    • Set PlayerGroup = (All enemies of Player 1 (Red))
    • Player Group - Pick every player in PlayerGroup and do (Do nothing)
    • Custom script: call DestroyForce(udg_PlayerGroup)
But i obviously need to change the Event and Ability being cast if I'm right
plus shall i change All enemies of player 1 Red to tempPlayer, since tempPlayer is the "badguy"
 
Level 2
Joined
Jun 18, 2012
Messages
24
Yes.
Also, if you're gonna have a player being the badguy, why not just have a variable for the badguy instead of a variable called tempPlayer?

Good question!
I followed a guide or if it was a thread in here cant remember. So i basically copied whatever they did.

But now im havin a hard time tryin to fix the player group, what shall the event and condition be? :vw_wtf:

Sorry, I know that you should not try to make a map wich is harder than you can handle. But I want to learn, and how im i suppose to learn things if i just keep doin stuff that I already know.
 
Level 10
Joined
Apr 18, 2009
Messages
601
If I understand you correctly, this is what you're after:

  • Elf Spawn
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((Matching player) is an enemy of tempPlayer) Equal to True) and ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Elf for (Picked player) at (Random point in troll spawn <gen>) facing Default building facing degrees
The first line (Player Group - Pick every player...) creates an empty Player Group. Then it checks every player one at a time and adds the checked player to the Player Group if the checked player matches all of the following conditions:
• The checked player must be an enemy of tempPlayer.
• The checked player must be a "user" or "human" player (in contrast to a "computer" or "AI" player).
• The checked player must be playing right now (hasn't left the game).

So the code makes these checks for every possible player and adds every player that matches all of the conditions to a Player Group. Very well.

The "Unit - Create..." line is within a loop. This means that this line will run separately for every player in the Player Group. An example: if there are 4 users plus the tempPlayer bad guy playing your map, then an Elf unit will be created for each one of these 4 players. The "create unit" line will be running 4 times. In every run, "(Picked player)" will be one of these 4 players from our Player Group.

Then, the Player Group is not destroyed. We leave it to rot and decay in memory for the rest of the game. This is what all the fuzz is about; why you are being asked to read up on memory leaks etc. However, this memory management stuff is of trivial meaning to you right now. I suggest that you do not bother with memory leaks at this stage. What you should probably be focusing on is to understand more basic code logic and simply to get your code to work. That will actually help you to practically improve in a way that's useful to you right now.

Anyway, I've uploaded an example map as well if you want to take a closer look at the trigger.
 

Attachments

  • Example Trigger.w3x
    12.5 KB · Views: 39
Level 2
Joined
Jun 18, 2012
Messages
24
If I understand you correctly, this is what you're after:

  • Elf Spawn
    • Events
      • Time - Elapsed game time is 5.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players matching ((((Matching player) is an enemy of tempPlayer) Equal to True) and ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))) and do (Actions)
        • Loop - Actions
          • Unit - Create 1 Elf for (Picked player) at (Random point in troll spawn <gen>) facing Default building facing degrees
The first line (Player Group - Pick every player...) creates an empty Player Group. Then it checks every player one at a time and adds the checked player to the Player Group if the checked player matches all of the following conditions:
• The checked player must be an enemy of tempPlayer.
• The checked player must be a "user" or "human" player (in contrast to a "computer" or "AI" player).
• The checked player must be playing right now (hasn't left the game).

So the code makes these checks for every possible player and adds every player that matches all of the conditions to a Player Group. Very well.

The "Unit - Create..." line is within a loop. This means that this line will run separately for every player in the Player Group. An example: if there are 4 users plus the tempPlayer bad guy playing your map, then an Elf unit will be created for each one of these 4 players. The "create unit" line will be running 4 times. In every run, "(Picked player)" will be one of these 4 players from our Player Group.

Then, the Player Group is not destroyed. We leave it to rot and decay in memory for the rest of the game. This is what all the fuzz is about; why you are being asked to read up on memory leaks etc. However, this memory management stuff is of trivial meaning to you right now. I suggest that you do not bother with memory leaks at this stage. What you should probably be focusing on is to understand more basic code logic and simply to get your code to work. That will actually help you to practically improve in a way that's useful to you right now.

Anyway, I've uploaded an example map as well if you want to take a closer look at the trigger.

Thanks! I do not have time to test it out now, but im pretty sure it works!
And yeah, i will leave memory leaks for now, tho i want to learn it, but as you mentioned i should concentrate on to practice common code logic etc.
 
Status
Not open for further replies.
Top