• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

TD - Earn wood/gold bounty in a specific area (mini-game)

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2020
Messages
86
Hi,

I have modified my map so that lumber = souls. In order to earn souls (actually lumber), any player in the specific area has to kill "hunters" (random creep spawns from levels 1-3, owned by player 10).

Here are the conditions I want to use:

- A player's hero (spawned from altar nearby) has to be in a specific area to earn souls (4 player map). If your hero is not in the region, you do not earn the shared souls.
- It does not matter who kills a unit, it is shared to anyone in the specific region.
- Soul bounty must be a random number from 8-12 and the floating text should match the corresponding number.

Area:
tTmxDLi.jpg


Current Trigger:
pPrrcWp.png


Thanks!
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
  • Triggering unit and dying unit are always the same for this event. In general you should usually use Triggering Unit any time you can instead of the more specific responses.
  • What is the trigger = dying condition intended to do? It does nothing currently.
  • Should the bounty for all players be the same? Currently it adds a different random number to all players lumber.
  • Do nothing is pointless and should never be used.
  • Put a region around that corner area and check that the unit died in that region.
  • Put all the human players into a player group variable at map init and then use “pick every player in...”
  • Remove the if block.
  • Events
    • Unit - A unit dies
  • Conditions
    • (Owner of (Triggering Unit)) equal to Player 10 (Light Blue)
    • ((Triggering Unit) is in Souls Region <gen>) equal to True
  • Actions
    • Set Souls = (Random number between 8 and 12)
    • // do floating text stuff here here
    • Player Group - Pick every player in HUMAN_PLAYERS and do (Actions)
      • Loop - Actions
        • Player - Add Souls to (Picked Player) current lumber
 
Level 5
Joined
Jan 23, 2020
Messages
86
Thanks Pyro! I've applied your points to most of my map already. I have a lot to learn!

I was able to follow your instructions until the "player group" variable at the end. I cannot seem to add more than one player to the player group.

Current trigger:

TtR4nZt.png


Player group variable not allowing me to add more than one player:

fXRPUo1.png
 
Level 9
Joined
Jul 30, 2018
Messages
445
The trigger above should work just fine. If you want a specific group for only humans players, like Pyrogasm suggested above, you have to make another trigger. It can be in your Map Initialization trigger or some other that is ran at the start of the map. There you pick (All Players) and add (Picked Player) to your HumanPlayers group if the player is a user and is currently playing.
 
Level 5
Joined
Jan 23, 2020
Messages
86
I've used "all players", it works perfectly. BUT now all the players are getting souls, regardless of if their hero is in the region or not.

What I want is: ONLY the heroes IN the region <hunter spawn> get shared souls. If your hero is not in the region, no souls for you.
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
How To Post Your Trigger

The way you're checking if the unit is in the region leaks a unit group. You should use the boolean check "Unit - Unit in region"You should have some sort of unit array where you store each player's hero. So like PlayerHero[3] is the hero of player 3. Then check like this:
  • Conditions
    • (Hunter spawn 2 <gen> contains (Triggering Unit)) equal to True
  • Player Group - Pick every player in (All Players) and do (Actions)
    • Loop - Actions
      • If (All conditions are true) then do (Then actions) else do (Else actions)
        • If - Conditions
          • (Hunter spawn 2 <gen> contains PlayerHero[(Player number of (Picked Player))]) equal to True
        • Then - Actions
          • Player - Add Souls to (Picked player) current lumber
        • Else - Actions
 
Level 5
Joined
Jan 23, 2020
Messages
86
I've tried to understand and apply what you've said regarding "unit arrays" but I don't think my expertise is quite there... I tried this tutorial: Array Tutorial but couldn't wrap my head around how to apply it to this scenario.

Heres whats I've come up with so far:

  • Hunter Bounty
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Player 10 (Light Blue)
      • (Hunter spawn 2 <gen> contains (Triggering unit)) Equal to True
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Hunter spawn 2 <gen> contains UnitArray[(Player number of (Picked player))]) Equal to True
            • Then - Actions
              • Set souls = (Random integer number between 8 and 14)
              • Floating Text - Create floating text that reads ((String((Random integer number between 8 and 14))) + |cff8080ff Souls|r) above (Dying unit) with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
              • Player - Add souls to (Picked player) Current lumber
            • Else - Actions

and the "UnitArray":

RjSnrMW.png


pfSBaAb.png
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
What you’ve done is correct, you just need to set the values of the array with a trigger. If players pick a hero then the appropriate time would be right as they pick. If the heroes are static then you could do it on map init or as soon as they’re created. This would be the most general solution:

  • Custom script: set bj_wantDestroyGroup = true
  • Unit Group - Pick every unit in (Units in (Playable map area) marching (((Matching Unit) is a hero) equal to true)) and do (Actions)
    • Loop - Actions
      • Set UnitArray[(Player number of (Owner of (Picked Unit)))] = (Picked Unit)
The way you are doing the floating text is a little wrong though. When you do it inside the player group loop it will do the actions for each player. This means it will create 24 different floating texts, all on top of each other. Each player will also get a different value of souls added to their lumber. I would move the setting of the souls variable and all of the floating text out of the loop. If you DO want each player to receive different amounts you’ll have to locally set the text of the floating text to be different for each player.
 
Status
Not open for further replies.
Top