• 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] life of triggering unit problem

Status
Not open for further replies.
life of triggering unit problem ( solved ) thanks everyone

well im having a problem w life of triggering unit ok the even is when player enters region it fires in my old map it works fine but ive done a ton of updates and upgrades since then and then i noticed it stopped working for some reason can anyone help me solve this plz here r the triggers i took a pick since i dont know how to add them in here lol
 

Attachments

  • life of triggering unit.PNG
    life of triggering unit.PNG
    61 KB · Views: 115
Last edited:
dont post an image,use [trigger][/trigger] code instead and put the trigger text in between those.
You can copy the trigger by right clicking the trigger icon on the top right of your trigger and press copy as text.

Ok about the trigger.Do you have any unit indexer?because you are using custom value of entering unit w/c is for indexing.

Because you are using same value of custom value,i really wont work.

Also,change the entering unit to triggering unit.

Custom value is for the handle id of the unit not for such,because of what you did,only one unit will receive a very unique id.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yes, I can see a lot of flaws. That's to be expected, pretty much everyone makes the same mistakes you're making right now when they're just getting started.
I'm going to start out some things that have to be changed.

Array Sizes:
In the variable editor, you have the option to increase the array size. This doesn't actually increase anything: the array size always goes from 0 to 8191 (that's 8192 values).
What it actually does, is initialize those variables. Now you've got some variables where you set the array size to 50 or higher, that means that all those variables will be initialized while loading.
This increases loading time (and saving time as well I believe?).

Short story: array size must be kept at 1, except for dialog and timer-variables.

Leaks
You may or may not have heard from them, but leaks are everywhere in your map.
Leaks are basically bits of data that Warcraft uses, but never removes.
Say you use the location "Center of map". Warcraft will remember that location, but never use it again. If you then use "Center of map" again (the second time), it will store it again (so now it has stored the same location twice, for no real reason).
If too much data gets stored, Warcraft will get some trouble and will slow down.
I don't know how old/young you are, but in the past many maps became unplayable after 30 minutes, mostly TD's (those have a lot of locations and groups).

It will take a while to explain leaks, but you absolutely must be able to clean them before you can get to the bigger work. It's also a good idea to clean a leak the moment you see one, not afterward. Even when I'm creating a map that will only live for 10 minutes (never saved), I will clean those leaks.
Leaks tutorial.


Loops/Arrays:
You obviously know what arrays are and how they work, but you're not always using them the way you should.
You mostly use them as a way to store more things, while they're the key component of turning a lot of triggers into a single trigger.

The entire category "Unit Triggers" can be compressed to 2 triggers (3 or 4 is also fine, don't be too stressed by maximum efficiency at the moment).
As you may have noticed, you're actually repeating the exact same code 60-ish times while slightly modifying a few values.
Think about this: what if you use an array variable, say "waveType" to store the unit-type of the current level in? Like, waveType[5] would be "Runner 05".
And players have numbers (Red is Player 1, Blue is Player 2), so you can use those numbers to identify them.
waveType[ level[Player number] ] could hold the unit-type of the level "Player" is currently in.


Now that that's done, let's review some other things:

The checkers-thing really doesn't look good, I'm sorry.
I highly recommend you remove the entire category and re-do everything.
Checker boards have 2 dimensions (1 to 8 and A to H), you can create your own 2-dimensional arrays with a few tricks.
Variable[ (8 * row) + column ]​
That's a fake 2-dimensional array that can be used for a checkerboard (could be read as Variable[row][column]).
So instead of storing information for each piece, you store information for each square.
An example:
"checkerUnit[ (8 * 3) + 4 ] = queen" / "checkerPlayer[ (8 * 3) + 4] = 1"
Would mean that at D3, there's a queen belonging to Red.
You also have to work with substrings (like when a player says "-move D4 C8", you register that string and divide it into "-move "; "D"; "4"; "C" and "8".
You then transform "D" into 4 and you can use the 2D-array to see which unit is in square (4, 4).


Oh, and for your question: you mean that the DPS shown is incorrect, or what exactly?

(Also, I love Power Towers TD - I've re-made that power-drain system some years back).
 
on the old map the dps system i made works but for some reason in the latest version it doesnt i didnt change anything w it thts wat i need help w and wat exactly were my leaks ? i thought i took care of most of them

and yea i made the checkers right off the bat it works good looks horrible tho but now ik a lot more and i might redo in the future i also am going to go back and redo most of the stuff tht i made earlier to make it better just couldnt figure out y my dps checker stopped working on my new map if u could help me w tht tht would be great
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
I wouldn't recommend WEU, I used it in the past and has some awful options that kinda broke my map.
JNGP is the standard right now, it combines the good features of other projects, though it doesn't really add much for the average GUI-user.

List of Leaks
CategoryTriggerLeak type
InitializationShow Regions RedLocation (center of rect)
InitializationShow Regions BlueLocation (center of rect)
Unit AbilitiesSell TowersSpecial Effect (do not place a wait between creating/destroying something)
Unit AbilitiesUnstick UnitLocation
And I'm out of time, didn't check beyond that. There might be more leaks in the categories after that.
So you're right: it's fairly okay, but you have to be more careful with those massive arrays for no real reason.
Also, remove all "Do Nothing"s and never use them again (you don't need an action to do nothing).

That's all for now, good luck.
 
thx lol i noticed about the do nothing later when i was mkaing stuff i forgot to put them in and everything worked so i was thinking tht do nothing command is a huge waste lol and i only placed a wait between the creating and destroying special effects for sell towers because when i didnt have one the special effect wouldnt work how should i fix tht ? and wow i thought i went over everything after i found out about leaks not sure how i missed those other things lol thx a lot tho greatly appreciated lol

Edit: oooo now i remember the unstick unit was just to see if it would work i didnt even make one for the other player in my map lol i musta been drunk tht night haha and since uve seen my spawn triggers do u recommend using if/then/elses ? or hashtables ?
 
Last edited:
Level 28
Joined
Jan 26, 2007
Messages
4,789
It is indeed a huge waste :).
Yeah, the problem with the wait is this: what if you want to sell 10 buildings at the same time (in your map that seems pretty common). Now the trigger will fire 10 times, but there is only 1 "last created special effect": the 10th one. So that's 9 special effect that never get removed.
You can solve this with some trick I'm going to teach you right now. I call it the local variable trick.

Local variable trick:
Basically, local variables are variables that have a unique value for every instance of the trigger.
If you run the same trigger 10 times and you use a local variable in it, the local variable can be different each time (it won't get overwritten).
The problem? You can't use locals with pure GUI. But you can trick the editor into doing so by using a bit of JASS.

To start, just create a new special effect-variable in the variable editor (I'll call it "tempSfx").
Once that is done, use this line at the top of your trigger:
  • Custom script: local effect udg_tempSfx
It has to be at the top, otherwise the trigger will break.
Now you can set that variable to what you want and it cannot get overwritten by other instances of the trigger :) (locals have a higher priority than globals, that's why).
There's one more catch: because it cannot get overwritten, Warcraft keeps remembering it (that's what a leak is). So you need to null the value at the end by adding this line:
  • Custom script: set udg_tempSfx = null
  • Example
    • Events
      • Time - Every 0.20 seconds of game time
    • Conditions
    • Actions
      • Custom script: local effect udg_tempSfx
      • Set tempLoc = (Random point in Region 000 <gen>)
      • Special Effect - Create a special effect at tempLoc using Abilities\Spells\Other\Transmute\GoldBottleMissile.mdl
      • Set tempSfx = (Last created special effect)
      • Custom script: call RemoveLocation( udg_tempLoc )
      • Wait 2.00 seconds
      • Special Effect - Destroy tempSfx
      • Custom script: set udg_tempSfx = null
For the unit-spawn, I recommend neither ITE's (too much code), nor hashtables (too powerful for what you want :p).
I would advise using variables with an array. Here is how a setup could look like:
  • Setting up Creeps
    • Events
    • Conditions
    • Actions
      • -------- CreepType[X] = Creep type of each level --------
      • -------- GoldLevel[X] = Gold gained after defeating a level --------
      • -------- SpecialWave[X] = The type of the wave (air/normal/immune/...) --------
      • -------- CreepSpawns[X] = The amount of units that spawn per level --------
      • -------- Level 1 --------
      • Set tempInt = (tempInt + 1)
      • Set CreepType[tempInt] = Level 1
      • Set GoldLevel[tempInt] = 1
      • Set SpecialWave[tempInt] = Dummy
      • Set CreepSpawns[tempInt] = 20
      • -------- Level 2 --------
      • Set tempInt = (tempInt + 1)
      • Set CreepType[tempInt] = Level 2
      • Set GoldLevel[tempInt] = 3
      • Set SpecialWave[tempInt] = Normal
      • Set CreepSpawns[tempInt] = 15
      • -------- [...] --------
      • -------- Copy/paste "Wave 1" and set the variables to whatever you like --------
(Taken from "Sample TD", a map I made some time ago, and edited for simplicity).
The idea behind it is really simple: every wave has its own array-value. If you want to spawn the next wave, simply do this:
  • Unit - Create CreepSpawns[Level] CreepType[Level] for Player 12 (Brown) at tempLoc1 facing Default building facing degrees
For level 1, this will create 20 "Level 1" ( = unit) at the desired location.

Also, notice that the trigger doesn't have an event.
It's called from the trigger "Init". You can have multiple system-setups in your map without event and call them one after the other in your main init-trigger.

The map "Sample TD" is actually a unit-per-unit spawn (not a mass-unit spawn), so showing the actual spawn-trigger won't be very helpful.
 
Status
Not open for further replies.
Top