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

Variables don't show

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
I've made a big load of region variables for my map, added a region to each variable in Melee Initialization, but when I make a trigger, the variable doesn't appear in the list of regions when I want to select a region for a 'Unit enters region' Event.
The same counts for units when I want to make a 'Unit comes within range of unit' Event. This is when a unit comes within range of a watchtower (the watchtower has a unit variable that is also set in the Melee Initialization trigger).
However, a unit group does work in the watchtower trigger. Also this variable is set in the Melee Initialization trigger.

I've attached the map, so if anybody can figure out what's wrong with this, please tell me so I can fix it.
 
Last edited by a moderator:
Level 11
Joined
Oct 20, 2007
Messages
342
the problem is the Unit Group "Blue villager"....
You din't set any variable into it and i juz a empty unit group.
  • Spotted by Watchtower 14
    • Events
      • Unit - A unit comes within 1000.00 of Watchtower 0380 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is in BlueVillager) Equal to True
        • Then - Actions
          • Unit - Change ownership of (Triggering unit) to Player 2 (Blue) and Change color
          • Unit - Order (Triggering unit) to train/upgrade to a Peasant
          • Unit - Change color of (Triggering unit) to Blue
        • Else - Actions
Look at ur condition, (Triggering unit) is in BlueVillager) Equal to True
that saying if triggering unit is in the unit group named "BlueVillager" only do the action (i think u know this)
but you "BlueVillager" is no one, so the trigger won't do the "action"

You must set something like:
  • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
    • Loop - Actions
      • Unit Group - Add (Picked unit) to BlueVillager
Or what unit u want to put into the group....

Or u tell me what u want to do, i can help u.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
It's because you can't use variables in trigger Events, they're always attached to a specific unit, not some unit in variable.
If you want the trigger to react on custom units, you will have to use a bit of JASS
JASS:
call TriggerRegisterUnitInRangeSimple( gg_trg_TRIGGERNAME, 256, UNIT )
If you want the trigger to react on different towers during the game, you will have to register trigger for every tower. You can do it like this (using global Watchtower, which contains unit, you want to register)
  • Register Watchtower
  • Actions
    • Custom script: call TriggerRegisterUnitInRangeSimple( gg_trg_TRIGGERNAME, 1000, udg_Watchtower )
Edit: I just downloaded the map and I just can't believe it.... Why do you use "watchtower1" to "watchtower18" instead of an array.
Nevermind, you don't have to create 200 exact same triggers, you can make one, which detects entering to all regions, then in the trigger find out which region it was
  • Crosspoint
    • Events
      • Unit - a unit enters region Crosspoint 1
      • Unit - a unit enters region Crosspoint 2
      • Unit - and so on....
    • Actions
      • For (Integer A) from 1 to 175(or how may crosspoint there are)
        • If ( Crosspoint[ IntegerA() ] contains Entering unit
          • Set index = IntegerA
      • ------- Rest of the trigger ------
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Thanks both for your time and effort.

jareph: I know about unit groups and stuff, and it's true that the group BlueVillager is still empty. I still need to make a trigger that adds units to that group, so thats all covered :smile:

MORT: Thanks for the JASS line, but what exactly does it do? I see the range and unit, but does it give some kind of JASS variable that's available for Events, or will it be the event itself or something? And since it's an Action, I assume it should be made in the Melee Initialization. Also, wouldn't maps all leak if they don't use that JASS line, or doesn't the leak-able info in Events cause leaks?
I indeed should have used arrays for the regions and watchtowers, but since they're all individual variables, does it make a difference? And finally: The last trigger you posted isn't really for this map. Not your fault, because I've only made 1 base trigger and copied them for the others, but those other crosspoints have different regions and chances, so I can't make those in 1 trigger. However what you showed in the Actions is very different from what I got. I've never worked with those Integer A/B/other Actions before, so maybe you can tell me what's different between those and Integer Variables or link me a page that explains it.

I know it's a big load of questions, but you would ofcourse also help me a big load with it :wink:
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
The Jass function (TriggerRegisterUnitInRangeSimple() ) adds another event the Trigger reacts on, but you can call this function half throughout the game. Also it allows you to let the trigger react on units/regions stored in variables. ( If you use "Edit - Convert to custom text", you can see this jass line in your watchtower trigger)

The trigger I posted uses "For A" loop to go through the whole array of Crosspoints and finds the one the unit was entering to. (The "For each Integer A" action makes the included actions run more times, each time with increased (Integer A). So the trigger above runs the IF..THEN..ELSE action 175 times, while the Integer A increases from 1 to 175. And since the Integer A is used as array index, it tests all of the array fields (assuming the array contains 175 regions) ). Then it saves it's index. So you have several more arrays, which contain this crosspoint's parameters ( chances, targets of move) under the same index:
  • Array Init
    • Actions
      • Set Crosspoint[1] = <reg> crosspoint 001
      • Set CrosspointWay1Chance[1] = 30
      • Set CrosspointWay1Region[1] = <reg> crosspoint 003
      • Set CrosspointWay2Chance[1] = 20
      • Set CrosspointWay2Region[1] = <reg> crosspoint 002
      • Set Crosspoint[2] = <reg> crosspoint 002
      • Set CrosspointWay1Chance[2] = 25
      • Set CrosspointWay1Region[2] = <reg> crosspoint 004
      • Set CrosspointWay2Chance[2] = 35
      • Set CrosspointWay2Region[2] = <reg> crosspoint 006
And then make one general trigger for all crosspoints, which uses the arrays with the crosspoint's index instead of preset regions/units.
  • Watchtower
    • Actions
      • "For Loop" as posted before, setting Index variable
      • ----- your original trigger -----
      • If (RandomNumber Less than CrosspointWay1Chance[Index])
        • Unit - order unit to move to CrosspointWay1Region[Index]
      • If (RandomNumber Less than CrosspointWay2Chance[Index])
        • Unit - order unit to move to CrosspointWay2Region[Index]
I hope it helps.
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
To prevent leaks, you enter a JASS-line that destroys the Variable, so it'll won't stay stuck in the game and suck your RAM until your computer can't take it anymore and crashes Warcraft III. ARRRRRH! (Because of the talk like a pirate day :xxd:)
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
You only need to destroy Locations and Groups, I don't see the problem here. You can't destroy the regions or units, because you need them on the game ( the Destroy() functions doesn't just clear the variable, they also remove the object from game, which you don't need(or want) for your towers and crosspoint)
 
Level 18
Joined
Aug 23, 2008
Messages
2,319
Ok. (I'm not the anti-leak king, so I believe you on destroying it completely)
But I've downloaded the Leak Check in the Tools section, which is made to check everything that causes leaks. This includes (I believe) everything where you can make a variable of and destroy with that JASS line. Meaning that these parts also cause leaks that should be prevented. So if you can't enter a variable in an Event, does that mean that they also don't cause leaks?

More ARRRH!
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
This includes (I believe) everything where you can make a variable of and destroy with that JASS line.
More ARRRH!

No, it doesn't. It includes only things you can't acces another way than a variable. Once you set that variable to another value, the previous group/unit/region/point/whatever becomes unaccesible for the program, therefore consuming memory until the end of game. But things like units, regions and items (maybe other stuff) have an actual representation in the game, and will automatically be deleted from memory when destroyed (in-game, not with JASS). So, basicaly, only abstract thing leak (point, unit group, player group).

After all, you need to worry about leaks only if you use a single variable repeatedly for different things. I remember before I first learned about leaks couple years ago, I had map which created about 100 leaking points per second, and still was playable for the first ten minutes :grin:
 
Status
Not open for further replies.
Top