• 🏆 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!

Could need help for a Trigger "Building limit"

Status
Not open for further replies.
Level 2
Joined
Dec 9, 2021
Messages
5
Hello,

I am working on a map but have some trouble with a trigger. In this Map you can build "wonders". Like in Civ Wars each Player can start construction the same wonder. But the player who finish the wonder first "gets it". All other Player shall lose the unfinished wonder (by explode) and getting the value back. And The possbility to build that wonder again shall be removed. Maybe someone could help me there please.

Example:

Player 1, 2 and 3 begins construction "Pyramid".
Player 2 finishs construction "Pyramid".
Player 1 not finished construction "Pyramid" Explode.
Player 1 Gets Value Points of Pyramid back.
Player 3 not finished construction "Pyramid" Explode.
Player 3 Gets Value Points of Pyramid back.
"Pyramid" cant be built again.

greetings
spacz
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,548
Hi, I believe this should work:

  • Build Wonder
    • Events
      • Unit - A unit Finishes construction
    • Conditions
      • (Unit-type of (Constructed structure)) Equal to Pyramid
    • Actions
      • -------- Cancel the construction of other Wonders: --------
      • Set VariableSet WonderGroup = (Units in (Playable map area))
      • Unit Group - Pick every unit in WonderGroup and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Picked unit)) Equal to Pyramid
              • (Picked unit) Not equal to (Constructed structure)
            • Then - Actions
              • -------- The Cancel order is hidden from us so we have to use this special Jass code to order the building to cancel: --------
              • Custom script: call IssueImmediateOrderById(GetEnumUnit(), 851976)
            • Else - Actions
      • Custom script: call DestroyGroup (udg_WonderGroup)
      • -------- --------
      • -------- Prevent players from building another one of these Wonders: --------
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Player - Limit training of Pyramid to 0 for (Picked player)

So this trigger tells the other Wonders to Cancel themselves and then prevents all players from building another Wonder. This should use Warcraft 3's refund system which I believe returns half of the resources. Did you want a full 100% refund? If so, it will be slightly different.

In that case I would Kill the (Picked units) instead of cancelling them and Add X gold/lumber to the Owner of the (Picked unit). Something like this:
  • Then - Actions
    • Player - Add 500 Gold to (Owner of (Picked unit))
    • Player - Add 250 Lumber to (Owner of (Picked unit))
    • Unit - Kill (Picked unit)

WonderGroup is a Unit Group variable. It's used to prevent Memory Leaks which can help with map performance.
 
Last edited:
Level 2
Joined
Dec 9, 2021
Messages
5
Nice dude! It works. Thank you very much!

For another wonders the hidden jass "Custom script: call IssueImmediateOrderById(GetEnumUnit(), 851976)" code is always usable?
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,548
Nice dude! It works. Thank you very much!

For another wonders the hidden jass "Custom script: call IssueImmediateOrderById(GetEnumUnit(), 851976)" code is always usable?
Yep, you can use that for anything as long as you reference the correct unit/order id. Simply copy and paste that trigger and replace all instances of Pyramid with your other Unit-type.

That Custom Script is the code form of the "Issue order with no target" action. All of the triggers that you make in the trigger editor are translated into code under the hood. So when you're making triggers you're technically coding! You'll probably see the word GUI thrown around, this refers to the trigger editor since it uses a Graphical User Interface instead of requiring that you write the code yourself.

So if you break down that custom script here's what everything means in GUI terms:
  • IssueImmediateOrderById() = Issue order with no target (an order that doesn't require a target, like Thunderclap, Avatar, etc)
  • GetEnumUnit() = (Picked unit)
  • 851976 = The Order Id of the Cancel ability
 
Status
Not open for further replies.
Top