• 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.

Changing Owner, Life Twice

Status
Not open for further replies.

B30

B30

Level 1
Joined
Mar 1, 2012
Messages
3
Hi, I'm new here. Sorry if I'm sounding a bit rude, but I've got a few problems with my new map.

My new map is like a sort of command/conquer type of map, where there are creeps going around taking over 'bases', which will in turn spawn creeps to help give advantage and beat the opposing team.

The problem is with the triggers. Whenever the 'base' changes owner once, like for example the enemy takes down one of my 'base', then I will have to try to take it back if not I will lose the game (objective of my game).

However, when I try to take down the 'base', the 'base' remains my opponent's and it does not change back to mine. This is a big problem because this is what I'm trying to get out of my map.

I really hope all guys from HiveWorkshop can help me out because I've searched the internet and there seems no problem to solving it. Sorry if this was abrupt, rude and others because I've been facing this problem for a week.

Thank you very much for your kind attention,
- B30
 

B30

B30

Level 1
Joined
Mar 1, 2012
Messages
3
The triggers are as follows:

Events -
- Unit (Base 1) <gen>'s life becomes Less than or equal to 100.0
Conditions -
- (Owner of Base 1 <gen>) Equal to Player 1 (Red)
Actions -
- Unit - Change of ownership of Base 1 <gen> to Player 7 (Green) and Change color
- Unit - Set life of Base 1 <gen> to 100.00%

Player 1 is the computer for the first team, Player 7 is for the second team. For the change of the bases, I just changed the players. [Player 1 to 7, vice-versa]

Still, whenever the bases are down, they remain green/red forever and won't change. I tried putting Action: Trigger - Run [This Trigger] (Checking Conditions)
 
Level 12
Joined
Dec 20, 2011
Messages
885
The triggers are as follows:

Events -
- Unit (Base 1) <gen>'s life becomes Less than or equal to 100.0
Conditions -
- (Owner of Base 1 <gen>) Equal to Player 1 (Red)
Actions -
- Unit - Change of ownership of Base 1 <gen> to Player 7 (Green) and Change color
- Unit - Set life of Base 1 <gen> to 100.00%

Player 1 is the computer for the first team, Player 7 is for the second team. For the change of the bases, I just changed the players. [Player 1 to 7, vice-versa]

Still, whenever the bases are down, they remain green/red forever and won't change. I tried putting Action: Trigger - Run [This Trigger] (Checking Conditions)

Hmm. Why are you using "Player 7 (Green)" as a trigger? You should use variables for those, like "OwningPlayer", "BaseCaptured", "PlayerCapturesBase", and the like. If you still can't figure it out, attach your map here, unprotected, so that either I or someone could help you.
 
Level 13
Joined
Jun 22, 2004
Messages
783
The choosing for player slots is up to the creator, it doesn't relate to the problem.

I can't really detect something you did wrong, however I can't see what your other (expecting you have one) trigger.

Here's a small example of how it can be done,perhaps it is of help.

  • chance base
  • Events
  • Unit - "your unit" <gen>'s life becomes Less than 100.00
  • Conditions
  • Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • (Owner of ("your unit" <gen>'s)) Equal to Player 1 (Red)
  • Then - Actions
  • Unit - Change ownership of ("your unit" <gen>'s) to Player 2 (Blue) and Change color
  • Else - Actions
  • Unit - Change ownership of ("your unit" <gen>'s to Player 1 (Red) and Change color
  • Unit - Set life of (Triggering unit) to 100.00%
As suggested it is a wise idea to use variables for things like unit and player reference.
 

B30

B30

Level 1
Joined
Mar 1, 2012
Messages
3
The second one works perfectly! Thank you!

I couldn't get round the variables, they all seem very complicated to me.
 
Level 13
Joined
Jun 22, 2004
Messages
783
Good to hear your problem is fixed, good luck with the rest of your map!

As for Variables.
Well in essence, it's a piece of data that you can create in your memory and store a piece of information inside it. You can then later reference to the variable again to ask what was inside.

Think about something like this.
You want to keep track of how many people have died in the game. So every time a unit dies you have to influence a number and tell it to increase it's number by one. Well you would need a piece of space to save the number right? so you can tell it increase itself. This is where a variable comes in handy. you'd get something like this in triggers.

  • First you open up the trigger editor (Ctrl+F4)
  • Open up the variable window (Ctrl+B)
  • You create a new variable (Ctrl+N or click the green icon)
  • You type in a name, say: numberOfDeaths (this is the variable it's name or identifier(how it can be unidentified))
  • In The World Editor, we need to tell variable what kind of variable they are (The Type), in this case we want a number which is called a "Integer" in the world editor
  • Press OK and close the variable window.

now you have created your first variable, now we want to store something in it, so we create a new trigger and tell that trigger that when the map loads we fill that variable "numberOfDeaths" cause at the start of the games there are no deaths. that would look like this.


  • Start of the map
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set numberOfDeaths = 0
so we created a variable and now we put something inside it.

Additionally we want to add a trigger that will increase this number whenever a unit dies, that would look like this.

  • unit dies
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set numberOfDeaths = (numberOfDeaths + 1)
In the above trigger you can see that we tell numberOfDeaths to be numberOfDeaths but + 1 (so to increase itself by 1 first and then to save itself again), so we basically "update" the variable with new information.

Now that we got that running, we can ask somewhere in the game how many deaths we have had. for example if the user types "Deaths" in the game as a chat message.


  • how many deaths do we have
    • Events
      • Player - "Your player" types a chat message containing Deaths as An exact match
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (We have had + ((String(numberOfDeaths)) + deaths in the game))
You see that we reference to that "variable" (that holds my information) to tell us how many deaths we have had.
 
Status
Not open for further replies.
Top