• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] Entering/Leaving a region message

Status
Not open for further replies.
Level 4
Joined
May 17, 2011
Messages
106
Hello!

This is my first time posting in this forum and actually it's also my first big map project (I only worked on a few little self-made maps.. doing some easy triggers and mapping.. nothing huge.. never posted one) and I'm stuck on a relatively easy trigger but since I'm a bit new to it I can't find how to make it work.

I want a message saying something like ( Entering ***** place and Leaving ***** place ) whenever I'm getting in and out of a region.

Here's what I got.

  • AstriaIN
    • Events
      • Unit - A unit enters Astria <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Quest - Display to (All players matching (((Entering unit) is A Hero) Equal to True)) the Hint message: Entering Astria...
  • AstriaOUT
    • Events
      • Unit - A unit leaves Astria <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Quest - Display to (All players matching (((Leaving unit) is A Hero) Equal to True)) the Hint message: Leaving Astria...
This trigger work but the problem is it spam the entering/leaving message to everyone in the game.

Can anyone help me?

Thanks!

SckZ
 
Level 4
Joined
May 17, 2011
Messages
106
Create the text message only for the player who enters or leaves the region. Or add a cooldown so such messages can not display more than every 8 seconds (aka turn trigger off, wait and then back on).

I've searched for that... I couldn't find anything about only the player who enters the region. Maybe I just missed something, I'll take another look at it.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Firstly the player who enters the region is the owner of the entering unit (hint hint).
Secondly, use the game display message rather than the quest notification.

Be aware that forces leak (called player groups in GUI) so you may wish to use the native call instead which takes a player instead of a force.
 
Level 4
Joined
May 17, 2011
Messages
106
Firstly the player who enters the region is the owner of the entering unit (hint hint).
Secondly, use the game display message rather than the quest notification.

Be aware that forces leak (called player groups in GUI) so you may wish to use the native call instead which takes a player instead of a force.

Alright thank you, I'll try that :)

Edit: I feel a bit lost in there... I tried a few things that didn't work really well... sorry to bother you again but could you explain me exactly how to do it? :p
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
The GUI solution...
Under game there is a send message action which allows you to send a game message to specific players from a force. Make a force consisting of the owner of the entering unit and display the entering message to that force. Remember to remove the force once you are done as they will leak otherwise. In GUI a force is called a Player Group.

JASS....
Here is a basic template.
call DisplayTextToPlayer(GetOwningPlayer(GetEnteringUnit()),0,0,"Replace message here with whatever you want")
You can change the text shown to anything you want as long as you leave the "" quotation marks as they are a syntactical part of the JASS language for declaring a string constant. You can paste it into a GUI custom script action.

It will not stop the spammage of messages to a single player though if he decides to patrol around a border. To do that you will need some other system which uses a timer to restrict the rate the messages are able to be created but for the most part it should be nowhere near as bad as spamming to everyone like you have now.
 
Level 4
Joined
May 17, 2011
Messages
106
The GUI solution...
Under game there is a send message action which allows you to send a game message to specific players from a force. Make a force consisting of the owner of the entering unit and display the entering message to that force. Remember to remove the force once you are done as they will leak otherwise. In GUI a force is called a Player Group.

JASS....
Here is a basic template.
call DisplayTextToPlayer(GetOwningPlayer(GetEnteringUnit()),0,0,"Replace message here with whatever you want")
You can change the text shown to anything you want as long as you leave the "" quotation marks as they are a syntactical part of the JASS language for declaring a string constant. You can paste it into a GUI custom script action.

It will not stop the spammage of messages to a single player though if he decides to patrol around a border. To do that you will need some other system which uses a timer to restrict the rate the messages are able to be created but for the most part it should be nowhere near as bad as spamming to everyone like you have now.

Ah, thank you for answering me again... and sorry if I'm being annoying but I was a bit confused. I never used any custom script and I don't really know how they work but I guess I'll find something about it on this forum.

Thanks for your patience and your help. I'll try that. Hopefully I won't have to ask for your help once again about this trigger ;)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
The trigger system in WC3 is made of a language called "JASS". When you make GUI triggers it autogenerates a JASS script with the functionality.

The problem though is GUI in WC3 was poorly designed. Thus the result is restricted, inefficient code when using it. You can however write an insert for the trigger script in JASS where you have full control over the code.

It is advisible to use JNGP editor (JASSNewGenPack is an enhancement to the WE improving JASS support) if you plan to use JASS seriously.

Be aware that JASS is noticably slower than languages like JAVA and especially C. This is largly due to the high level nature of the language and the fact the trigger script compiles at map load. Due to load time withstraints and the poor compiler design, nearly no optimizations are carried out and so the results are unefficient machine code. It also has tons of compiler bugs (such as not decrimenting the garabge collector counter when a local handle reaches the end of function).
 
Level 2
Joined
Jun 15, 2010
Messages
6
  • Events
    • Unit - A unit enters No region
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • Game - Display to (All players matching ((No region contains (Triggering unit)) Equal to True)) for 5.00 seconds the text: Your text here
I'm not sure on this one, but you can try it.
Of course, your region goes to No region
 
Level 7
Joined
Dec 24, 2009
Messages
257
  • Events
    • A unit enters <region>
  • Conditions
    • ((Triggering unit) is A Hero) Equal to True
  • Actions
    • Set Temp_Player = (Owner of (Triggering unit))
    • Game - Display to (Player group (Temp_Player)) for 5.00 seconds the text: < >
Try it out (Temp_Player is a player-typed variable)
 
Level 4
Joined
May 17, 2011
Messages
106
Thanks for answering guys but I got my trigger up and running since a few days, thanks to Dr super good for helping me do that ;)

This thread can be closed :)
 
Status
Not open for further replies.
Top