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

[General] Simple Levelup code

Status
Not open for further replies.
Level 5
Joined
Apr 1, 2010
Messages
107
Honestly, I don't know why this can't be simple, but Blizzard's triggering system has again proved to me that advanced functions can be very easy but the simplest of commands make me scratch my head in frustration.

This is all I want:

  • Events
  • Player - Player 1 (Red) types a chat message containing -level as An exact match
  • Actions
  • Hero - Set (My hero here, if you would) Hero-level to ((Hero-level of (My hero again)) + 1), Show level-up graphics.
I've tried setting all kinds of variables. None of them work. It is a newly created unit, so I cannot select an existing one on the map. I've tried using Last Created Unit, as well as trying to use a variable to set my hero variable to last created unit, but neither of those work (mainly due to the fact my map has constant unit spawns, and it will always override last created unit.)

What can I do to achieve this very simple trigger? Why is it so hard?
 
Level 5
Joined
Apr 1, 2010
Messages
107
There are four triggers.

  • Events
  • Unit - A unit enters Kael Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 BloodMage for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Illidan Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 DemonHunter for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Paladin Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 Paladin for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Blademaster Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 Blademaster for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Trigger - Turn off (This trigger)
BloodMage, DemonHunter, Paladin, and Blademaster are all Unit-Type variables consisting of the default melee heroes they are named after.

I also have these four triggers replicated for an AI player, as I'm working on a project that makes a human-like opponent in an 1v1 AoS map. So, I'll also need a variable like this for the AI player as to define functions with the specific hero.
 
Level 5
Joined
Apr 1, 2010
Messages
107
Yes, there is only one player, and one AI player. Each of these players will only have one hero at any given time, except the first ten seconds of the game, where neither will have a hero (they are choosing one).
 
Level 11
Joined
Mar 31, 2009
Messages
732
  • Events
  • Unit - A unit enters Kael Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 BloodMage for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Set variable[1] = Last Created Unit
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Illidan Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 DemonHunter for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Set variable[1] = Last Created Unit
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Paladin Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 Paladin for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Set variable[1] = Last Created Unit
  • Trigger - Turn off (This trigger)

  • Events
  • Unit - A unit enters Blademaster Hero <gen>
  • Conditions
  • Player - (Owner of (Triggering Unit)) equal to Player 1 (Red)
  • Actions
  • Unit - Remove (Triggering Unit) from the game
  • Unit - Create 1 Blademaster for Player 1 (Red) at (Center of Player 1 Respawn <gen>) facing blah blah
  • Set variable[1] = Last Created Unit
  • Trigger - Turn off (This trigger)
  • Events
  • Player - Player 1 (Red) types a chat message containing -level as An exact match
  • Actions
  • Hero - Set (variable[1]) Hero-level to ((Hero-level of (variable[1])) + 1), Show level-up graphics.

The index of the array variable should be the ID of the player in GUI format (1-based). If you duplicate these triggers for other players, make the index [2] or [3] depending on their player slot number.
The variable should be declared a unit array.
 
Level 5
Joined
Apr 1, 2010
Messages
107
The index of the array variable should be the ID of the player in GUI format (1-based). If you duplicate these triggers for other players, make the index [2] or [3] depending on their player slot number.
The variable should be declared an integer array.

I'm trying to replicate your variable function in the editor, but I'm not being given the option to set an integer as last created unit. What type of variable do I need to make to go along with this?
 
Level 5
Joined
Apr 1, 2010
Messages
107
Success. You sir, are a savior. This topic is solved, and rep will be given as due.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
It should be Player number of (Triggering player) inside the array.

If you make it 1 for Player 1, 2 for Player 2, that's a pre-set value, it should be a total variable.

  • Melee Initialization
    • Events
      • Player - Player 1 (Red) types a chat message containing -level as An exact match
    • Conditions
    • Actions
      • Hero - Set Hero[(Player number of (Triggering player))] Hero-level to ((Hero level of Hero[(Player number of (Triggering player))]) + 1), Show level-up graphics
Hero is Unit variable with array.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Events can be like this in a single trigger, more like a Condition of OR

  • Events
    • Player - Player 1 (Red) types a chat message containing -level as An exact match
    • Player - Player 2 (Blue) types a chat message containing -level as An exact match
    • Player - Player 3 (Teal) types a chat message containing -level as An exact match
    • Player - Player 4 (Purple) types a chat message containing -level as An exact match
Instead you create 12 separate triggers, better you create a single trigger and use that array function, am I right ?

He said himself, there is an AI including in that game
AI also occupies slots, therefore it will be on slot Player 2 and so on

It is not wrong to do the method you just mentioned but it is less efficient, that's all
 
Level 11
Joined
Mar 31, 2009
Messages
732
They CAN be, yes. WERE they? Perhaps he wants different actions for each player? Until he makes that decision, my code example works just fine.

The code has already been given. The original poster has already said I have answered him. Nobody asked you to come and change my sample. Perhaps the original poster already figured this out?
 
Level 11
Joined
Mar 31, 2009
Messages
732
Very. Very mad. There is no need to butt in to a thread after its been answered just to say "WELL LOL MAYBE IT SHOULD BE DONE THIS WAY???? THIS WORKS TOO LOLOL NOW GIVE ME ++ ELECTRONIC PEEN VALUE TOO!!!!!!!!!!!!!!!!!!!!!!!!".
 
Last edited:
Very. Very mad. There is no need to butt in to a thread after its been answered just to say "WELL LOL MAYBE IT SHOULD BE DONE THIS WAY???? THIS WORKS TOO LOLOL NOW GIVE ME ++ ELECTRONIC PENIS VALUE TOO!!!!!!!!!!!!!!!!!!!!!!!!".
Take care, bad words won't be tolerated.

Also can you explain, why is bad to correct bad code or silly mistakes.
There are many ways to handle this problem.

For example you can use temp unit group and level up 100 heroes at same time.

Also that hero pick system is really bad.
It leaks, trigger don't need to be disabled (even if need then it should be disabled before other trigger actions).
And there is no need for array unit it you have 1 player.
2 many triggers, it even can't be called system.
 
Level 5
Joined
Apr 1, 2010
Messages
107
I cannot use a tavern system because the only players are a human Player 1 and an AI Player 2, excluding neutral hostile and neutral passive. Last time I checked, there was no way to order the AI to buy a hero from a tavern, or to buy items from a shop. I'm no JASSer, so this is all coming from GUI. Also, the hero pick system consists of at least 12 triggers, so I'm afraid it has to stick that way in order for everything to work.

Unless someone can enlighten me and make my current system much simpler, I thank all of you for the help and suggestions, but it is done the way it is done for reasons.
 
Status
Not open for further replies.
Top