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

[Trigger] Warning events? Not enough mana/build more farms, etc.

Status
Not open for further replies.
I am creating a Naga sound set and I need to know - How to detect when a player attempts to do something but does not have the resources?

For example, a player clicks to build a farm but has not enough lumber. I removed the standard sounds like this:

  • Old sounds Off
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Race of (Triggering unit)) Equal to Demon
    • Actions
      • Unit - Turn alarm generation for (Triggering unit) Off
And, I have some of my new alarms being generated like this:

  • Unit Under Attack
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Race of (Attacked unit)) Equal to Demon
    • Actions
      • Set SoundPlayer = (Owner of (Triggering unit))
      • Set Sound = NagaUnitAttack1 <gen>
      • Custom script: if GetLocalPlayer() == udg_SoundPlayer then
      • Sound - Play Sound
      • Custom script: endif
      • Trigger - Turn off (This trigger)
      • Wait 10.00 seconds
      • Trigger - Turn on (This trigger)
But, things like "not enough mana" I can't find and event to go with them. Please point me to a list or system, or spell them out if you can.
Currently I am lacking the following:

  • Not enough Mana
  • Not enough Lumber
  • Can't build there
  • Not enough Gold
  • Not enough Food
  • Gold Mine is running Low*(I can probably figure out a work around for these)
  • Gold Mine has Collapsed (but if someone knows the actual event, great!)

Help is greatly appreciated and will be +rep'd!

 
Level 30
Joined
Feb 18, 2014
Messages
3,623
I believe you can find them in the World Editor [On the top] where you can find a huge list a database of warcraft 3 were you can change everything you like for your map (including the sound] like ex : can't build there... just check out the configuration of your map [Not in triggers section]

I really want to explain you more cuz I understand what do you mean, but my WC3 is in frensh... so sorry

Edit : try the seek on the window, I suppose! Or somewhere there!
 
Il est ok , merci pour tenter.

Do you mean the game interface?

I know where they are in the interface. There is a custom script file, like war3miscSkin.txt. Where you can change them, but that would change them for all players of one race. I am making a map with 10 races. The player will choose with a dialog in the beginning. Then I want to alarm sounds for that player to be the Naga set of sounds.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
iirc, there are a total of 5 races but the last one was never implemented.
However, it can still be used for some neat race-dependent stuff.

In any case, what you want to achieve is not really possible according to standard WC3 rules. You would have to make the restrictions like "Not enough mana", "Build more farms", "Not enough space to build", etc yourself.
This is not really hard to do but you will have to get rid of the standard restrictions so you can actually catch the event of when a player tries to do anything in the first place.

In essence, it is not worth the efford and you should try to make your races inherit from the standard races so that the messages will still fit with the themes.
(You can replace the sound files though which is some relief.)
 
iirc, there are a total of 5 races but the last one was never implemented.
However, it can still be used for some neat race-dependent stuff.

In any case, what you want to achieve is not really possible according to standard WC3 rules. You would have to make the restrictions like "Not enough mana", "Build more farms", "Not enough space to build", etc yourself.
This is not really hard to do but you will have to get rid of the standard restrictions so you can actually catch the event of when a player tries to do anything in the first place.

In essence, it is not worth the efford and you should try to make your races inherit from the standard races so that the messages will still fit with the themes.
(You can replace the sound files though which is some relief.)

Well, that could work, but there has to be an easier way. For example, using a script to set Demon race sounds? Or changing the race via vJass or something?

Wait wait??? What is this? And why only in 1 player games?
  • Detect Player's Attempts at casting or building?
    • Events
      • Game - The 'Hero Abilities' button is clicked
      • Game - The 'Build Structure' button is clicked
Is there a way to know when the button was pressed that won't desync? or whatever?
 
Level 30
Joined
Feb 18, 2014
Messages
3,623
Il est ok , merci pour tenter.

Do you mean the game interface?

I know where they are in the interface. There is a custom script file, like war3miscSkin.txt. Where you can change them, but that would change them for all players of one race. I am making a map with 10 races. The player will choose with a dialog in the beginning. Then I want to alarm sounds for that player to be the Naga set of sounds.

Exactly the game interface!

But since you want to make a 10 player map with different races! Well just change the basic race (e.x : you want to play with human? Just change those sounds on the interface! And that will not interupt other races!

Well, that's all I can do for you!
 
But since you want to make a 10 player map with different races! Well just change the basic race (e.x : you want to play with human? Just change those sounds on the interface! And that will not interupt other races!

Actually, it will be a 2 (maybe 4) player map, where the players can choose from 10 races. I don't know if that makes it easier, but the sounds I have so far are good, so I really want to finish this the way I started. I have, hero dies, ally hero dies, town attacked, ally town attacked, unit attacked, ally unit attacked, upgrade complete, building complete, research complete... so if I could just get these last few, then it would be really cool.
 
The gold mine stuff is easy, but those others prevent things from happening which means there are no events.
You would have to remove the restriction and make it yourself... or just use the standard errormessage.

How would you do the gold mine then? That gets me closer, and I haven't figured it out yet.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Well, you could maybe catch the collapsed event with "A unit dies", but mainly you could do it with this:
  • Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer TempInteger[0]) from 1 to GoldMinesAmount, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • GoldMineIsLow[TempInteger[0]] Equal to False
                  • (Resource quantity contained in GoldMines[TempInteger[0]]) Less than or equal to GOLD_MINE_LOW_THRESHOLD
            • Then - Actions
              • Set GoldMineIsLow[TempInteger[0]] = True
              • Game - Display to (All players) the text: Gold mine is almost...
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Resource quantity contained in GoldMines[TempInteger[0]]) Equal to 0
            • Then - Actions
              • Game - Display to (All players) the text: Gold mine is empty.
              • -------- remove goldmine --------
              • Set GoldMines[TempInteger[0]] = GoldMines[GoldMinesAmount]
              • Set GoldMineIsLow[TempInteger[0]] = GoldMineIsLow[GoldMinesAmount]
              • Set GoldMinesAmount = (GoldMinesAmount - 1)
              • Set TempInteger[0] = (TempInteger[0] - 1)
            • Else - Actions
What this does is it checks every 0.5 seconds if any of the listed gold mines is below the threshold but has not been below it yet and will give the first message.
And when a gold mine is empty, it will display the second message and will be removed from the list.

With this trigger you can easily add gold mines to the list:
  • Add Goldmine
    • Events
    • Conditions
    • Actions
      • Set GoldMinesAmount = (GoldMinesAmount + 1)
      • Set GoldMines[GoldMinesAmount] = TempUnit[0]
And this trigger is what I used to test it:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set GOLD_MINE_LOW_THRESHOLD = 5000
      • -------- - --------
      • -------- - --------
      • -------- - --------
      • Set TempUnit[0] = Gold Mine 0024 <gen>
      • Trigger - Run Add Goldmine <gen> (ignoring conditions)
      • Set TempUnit[0] = Gold Mine 0021 <gen>
      • Trigger - Run Add Goldmine <gen> (ignoring conditions)
      • Set TempUnit[0] = Gold Mine 0022 <gen>
      • Trigger - Run Add Goldmine <gen> (ignoring conditions)
      • Set TempUnit[0] = Gold Mine 0023 <gen>
      • Trigger - Run Add Goldmine <gen> (ignoring conditions)
You could loop trough all units owned by neutral passive and check their unit type and add them so it will work generic.

One thing that this does not have included is a check who the owner was of the gold mine.
For example, you dont get the collapsed messages from gold mines that other people use.
You can check for the nearest unit and use his owner.
 
One thing that this does not have included is a check who the owner was of the gold mine.
For example, you dont get the collapsed messages from gold mines that other people use.
You can check for the nearest unit and use his owner.

Well, that is the trick right there. I know how to check for gold periodically, and I suppose, the closest player would work, but it would be better to have the real owner of the mine.

  • Goldmine is Running Low
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Set Real_Mine = 2000.00
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units of type Gold Mine) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Resource quantity contained in (Picked unit)) Equal to 3000
            • Then - Actions
              • Set tempp1 = (Position of (Picked unit))
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 2000.00 of tempp1) and do (Actions)
                • Loop - Actions
                  • Set tempp2 = (Position of (Picked unit))
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Distance between tempp1 and tempp2) Less than Real_Mine
                    • Then - Actions
                      • Set Real_Mine = (Distance between tempp1 and tempp2)
                      • Set NearestUnit = (Picked unit)
                    • Else - Actions
                  • Custom script: call RemoveLocation(udg_tempp2)
              • Custom script: call RemoveLocation(udg_tempp1)
            • Else - 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
              • (Race of (Picked player)) Equal to Demon
              • (Owner of NearestUnit) Equal to (Picked player)
            • Then - Actions
              • Set SoundPlayer = (Picked player)
              • Set Sound = NagaGoldMineLow1 <gen>
              • Custom script: if GetLocalPlayer() == udg_SoundPlayer then
              • Sound - Play Sound
              • Custom script: endif
            • Else - Actions
But still, does anyone know about those events (Game - The 'Hero Abilities' button is clicked) I posted above?
 
Last edited:
Level 24
Joined
Aug 1, 2013
Messages
4,658
They do actually work.
When you click any of those buttons an event is fired.
However, a trigger is the only thing that can actually use events.
And a trigger has to run on all clients.

You cannot have the event for other clients as you shouldnt even be caring about them.
But neither can you have a local trigger.

So in fact, it is the fault of Blizzard that there is no local version of a trigger or make triggers themselves local.
 
They do actually work.
When you click any of those buttons an event is fired.
However, a trigger is the only thing that can actually use events.
And a trigger has to run on all clients.

You cannot have the event for other clients as you shouldnt even be caring about them.
But neither can you have a local trigger.

So in fact, it is the fault of Blizzard that there is no local version of a trigger or make triggers themselves local.

But I can have triggers run locally ... in fact I do it here ... see:
  • Custom script: if GetLocalPlayer() == udg_SoundPlayer then
  • Sound - Play Sound
  • Custom script: endif
So I could do ....

Everytime a build/ability order button is clicked, if (can't build there) then (play local sound) ...right?
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
No, you CANT run triggers locally.

What you do is run a part of your script locally which is a big ass difference from what triggers actually do.

You can create a trigger locally (which crashes the game immediately because you create something locally) or you can create it for all players but only add the events locally... which crashes the game when that trigger runs.

When I click on the button to build, the trigger runs on my client, but not on yours so we fall out of sync (why? dunno, blizzard made it this way).
So then we disconnect from the host and so it doesnt work locally.

So after all, Every time a build/ability order button is clicked, you disconnect from the host.

OT
There was this spacebar hit event script which also didnt work in multiplayer... until you removed the run trigger part of it and added the actions directly to the script.
But noone thinks about those things these days.
 
No, you CANT run triggers locally.

What you do is run a part of your script locally which is a big ass difference from what triggers actually do.

You can create a trigger locally (which crashes the game immediately because you create something locally) or you can create it for all players but only add the events locally... which crashes the game when that trigger runs.

When I click on the button to build, the trigger runs on my client, but not on yours so we fall out of sync (why? dunno, blizzard made it this way).
So then we disconnect from the host and so it doesnt work locally.

So after all, Every time a build/ability order button is clicked, you disconnect from the host.

OT
There was this spacebar hit event script which also didnt work in multiplayer... until you removed the run trigger part of it and added the actions directly to the script.
But noone thinks about those things these days.

Ok, so yes the trigger "runs" for everyone but it doesn't do any actions except for local players. I still believe there is a way to do this (without recoding the restrictions) and someone here knows how. I wonder if there is a script that controls game interface and has sounds for the demon race. What script has the normal race alarm sounds?
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
The scripts are in the game.dll.
Try editting it and you will get a hacked WC3 which only you can use because we wont have the editted version.

And yes, for a trigger to work, you run it for everyone and place the actions inside local player checks... however, there is no way that your trigger will run when I press the build button.
It is one of the flaws that WC3 has which is just something that Blizzard didn't think of.

Warcraft III is not able to do everything and I have a shitload of examples what it can and what it can't.
So wether you still believe there is a way to do it or not is irrelevant.
You can believe it but this is not an anime so you won't change the actual situation.

There isn't really a script that controls the game interface of the demon race.
However, I recall a function that changes the race of a player to another race.
And a quick check in Common.j gave me this:
constant race RACE_DEMON = ConvertRace(5)
Which basically means that it is accessable. However, if that change race function doesn't exist, then it won't work.

(There also seems to be an "OTHER" race and race #6 is missing so there may essentially be 7 races instead of 5:
constant race RACE_OTHER = ConvertRace(7))
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
-_-
You cant import such things... or at least, you can but it won't affect anything at all... or crash the game.

Game.dll is loaded when you start WC3 and won't be re-loaded after that.
So you would have to have a separate WC3 for your map specific.
Next to that, you won't be able to edit game.dll at all.

Common.j is already inside WC3. It holds all native declaration and default global variables.

The alarm responses are somewhere in game.dll, but you should just accept that WC3 is not an IDE, WC3 is not able to give you what you want.
WC3 has many problems with things that we want but can't achieve in it using the standard stuff.

To make what you want, you will have to do mana cost, build cost, collision detection, etc ALL yourself so you remove the normal restrictions and create your own.
Ofcourse this comes with many nice features but I doubt that WC3 is able to handle a bonus collision detection from JASS.

After all, just use the normal stuff for the remaining error messages.
 
Please don't be offended if I want a second opinion. I understand the limitation, but often if someone thinks creatively, there is a viable work-around. You even suggested one (labor intensive though it may be). So we know it is possible, the question pending is ... whether there is a way to do it that requires less work than removing restrictions and triggering them manually?
 
Status
Not open for further replies.
Top