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

[Trigger] Text Message

Status
Not open for further replies.
Level 10
Joined
Jun 20, 2017
Messages
327
What's wrong? That only shows the first message!
  • Notice 1
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
    • Actions
      • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Triggering unit)) Equal to (==) Town Hall (2)
        • Then - Actions
          • Game - Display to (All players) the text: (String_PlayerColors[(Player number of (Triggering player))] + has constructed the |cffffcc00Town Hall (2).|r)
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Do nothing
      • -------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of (Triggering unit)) Equal to (==) Town Hall (3)
          • Then - Actions
            • Game - Display to (All players) the text: (String_PlayerColors[(Player number of (Triggering player))] + has constructed the |cffffcc00Town Hall (3).|r)
            • Trigger - Turn off (This trigger)
          • Else - Actions
            • Do nothing
      • -------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// --------
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Unit-type of (Triggering unit)) Equal to (==) Town Hall (4)
          • Then - Actions
            • Game - Display to (All players) the text: (String_PlayerColors[(Player number of (Triggering player))] + has constructed the |cffffcc00Town Hall (4).|r)
            • Trigger - Turn off (This trigger)
          • Else - Actions
            • Do nothing
 
Shorter triggers you say? Try a hashtable.
  • Upgrade
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
      • (Load (Key (Name of (Triggering unit))) of (Player number of (Triggering player)) from UpgradeTable) Equal to False
    • Actions
      • Hashtable - Save True as (Key (Name of (Triggering unit))) of (Player number of (Triggering player)) in UpgradeTable
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( upgraded to + (Name of (Triggering unit))))
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
I think it can be done without hashtables, and a hashtable would just make that trigger shorter it would have a larger setup instead, the overall gain is probably very small.

Try

set upgraded = triggering unit
if ANY conditions are true
upgraded is equal to townhall (1)
upgraded is equal to townhall (2)
upgraded is equal to townhall (3)​
Then
Display message Name of triggering player + upgraded to + name of upgraded
Turning off the trigger does not seem needed to me here.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,182
No it does not. triggering player only works for player events.

I tried the following in a temp map:
  • Melee Initialization
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) the text: 1
      • Game - Display to (All players) the text: (Name of (Triggering player))
"1" gets written but not the second one.
 
Level 38
Joined
Feb 27, 2007
Messages
4,951
Yeah it works for playerunitevents. Honestly I didn't know you could use GetTriggerPlayer() in the playerunitevent responses. Logical but nothing actually suggests you can do that because, you know, no player actually causes the event to happen.
 
Unit events that are registered for a specic player can use TriggeringPlayer.

call TriggerRegisterPlayerUnitEvent(trigger, player, playerunitevent, null) -- is the used function.

For example, "A unit dies" does call the above function with EVENT_PLAYER_UNIT_DEATH for all players.

==

"A unit enters region" looks like (Chaosy, your example)
JASS:
function TriggerRegisterEnterRectSimple takes trigger trig, rect r returns event
    local region rectRegion = CreateRegion()
    call RegionAddRect(rectRegion, r)
    return TriggerRegisterEnterRegion(trig, rectRegion, null)
endfunction
^which does not register any player event. TriggeringPlayer can't be used here.
 
Status
Not open for further replies.
Top