HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Any Unit, WTF???

12-08-2006, 03:47 AM#1
Hydrolisk
In the GUI trigger editor of the normal WC3 editor, I think to myself, "Boy, it would be great to make an aura that's has a percent chance every second to hurt undead units..." And so, I make my "dummy" spell and I go in the trigger editor. I make a "If real = to blah blah or less then, do this blah blah" trigger. So far so good. I finish my events. Now, to do the event and conditions, I think to myself. As I look for an "Any unit" condition, I think back to StarCraft's trigger editor. Why? 'Cause I can't find "Any unit" as a condition!!! RAWR! WTH! And so now, I come to WC3C to find an answer: is there anyway at all to have a sort of "Any unit" condition as in, "Any unit has specific buff: Aura of Holy Fury."

Is there anyway to achieve this? And I mean, ANY way. Different editors, or what? Triggers? JASS? HELP!!! IT'S RUINING ALL MY COOL SPELLS!
12-08-2006, 04:05 AM#2
Av3n
... Learn JASS.

-Av3n
12-08-2006, 04:12 AM#3
PipeDream
You could make your own 'any unit condition', but it would be worthless for this application, as it is simpler and far more efficient to iterate over the units with the buff and damage them appropriately. The simplest way is probably 'get all units with filter buff' followed by 'for all units in group, ...'
12-08-2006, 05:53 AM#4
Pyrogasm
How about this trigger:
Trigger:
Collapse Events
Every 1.00 seconds of game-time (or whatever you want it to be)
Conditions
Collapse Actions
Collapse Unit group - Pick every unit in (Units in Playable Map Area) matching ((Matching Unit) Has buff (Your Buff) equal to True) and do (Actions)
Collapse Loop - Actions
Set Damage_Chance = Random number between 1 and 100
If (All Conditions are True) then do Actions, Else do Actions
Collapse If - Conditions
Damage_Chance is less than or equal to 55 (or whatever your percentage is) Then do actions, else do actions
Collapse Then - Actions
Unit - Set life of (Picked Unit) to ((Life of (Picked Unit) - 10.00)) (Or whatever the damage should be)
Collapse Else - Actions
Do Nothing

For future reference, you can trick WE into turning unit-specific actions into generic unit actions with these simple triggers:
Trigger:
Collapse Start of Map Add
Collapse Events
Map Initilization
Conditions
Collapse Actions
Unit Group - Pick every unit in (Units in Playable Map Area) and do (Trigger - Add to Your Trigger That Requires Unit Specific Actions <gen> the action (Unit - (Picked Unit) takes Damage (Or whatever your action is)))
Collapse Unit Enter Map Add
Collapse Events
Unit - A unit enters (Playable Map Area)
Collapse Conditions
Unit Type of (Triggering Unit) not equal to Dummy (If you have dummy units)
Collapse Actions
Trigger - Add to Your Trigger That Requires Unit Specific Actions <gen> the action (Unit - Picked Unit) takes damage (Or whatever that action is)
Collapse Your Trigger That Requires Unit Specific Actions
Collapse Events
Make sure this has no events
Collapse Conditions
If you have any conditions, put them in
Collapse Actions
Put your actions here for whatever should happen when your unit-specific thing happens.

This is demonstrated in Freakazoid's Floating Text damage with GUI system, which can be found here.
12-08-2006, 11:49 AM#5
ArchWorm
Pyrogasm, that's a heavy work for Warcraft. I mean it will be a bit leaky.
12-08-2006, 07:19 PM#6
Pyrogasm
You're saying the trigger I posted for him to try is leaky, or the trigger for turning unit-specific commands into any unit commands leaks?

I may not have copied it over correctly, but the only thing that leaks on Freakazoid's Floating Text using GUI map is that when the units are added to the trigger it allocates some memory for that.
Quote:
Originally Posted by Pipedream
Each time you add an event a little memory is allocated for that. That memory is only returned to general use when the trigger is destroyed. The trigger is not informed when a unit dies, that it might let the memory go, nor are we given the tools to manually fix it.

So, what's wrong with it then if you don't use it for maybe 1 or 2 spells in a map?
12-08-2006, 07:32 PM#7
Fireeye
it's leaky because you don't store the unit-group into a var an destroy the group afterwards and it's a periodic event.
Group Leak + Periodic = Enormous Lagg after some time depending on the intervall.
Best way to solve this, learn JASS.
12-08-2006, 08:53 PM#8
TaintedReality
Not sure why everyone is telling you to learn JASS, this is an incredibly simple task. Of course you'll want to clean up leaks, which JASS might be better for, but it can easily be done in GUI. Just use something similar to what Pyrogasm posted, using this action:

Trigger:
Unit group - Pick every unit in (Units in Playable Map Area) matching ((Matching Unit) Has buff (Your Buff) equal to True) and do (Actions)
12-09-2006, 06:02 AM#9
Pyrogasm
The "Pick all units in playable map area" action leaks? Well I'll be darned. I knew that unit groups leaked, but not that the one regarding the whole map did. Sorry for the misinformation

So would using this trigger clear all leaks?
Trigger:
Collapse Events
Every 1.00 seconds of game-time (or whatever you want it to be)
Conditions
Collapse Actions
Set Damage_Group = ((Units in Playable Map Area) matching ((Matching Unit) has buff (Your Buff) equal to True)
Collapse Unit group - Pick every unit in (Damage Group) and do (Actions)
Collapse Loop - Actions
Set Damage_Chance = Random number between 1 and 100
If (All Conditions are True) then do Actions, Else do Actions
Collapse If - Conditions
Damage_Chance is less than or equal to 55 (or whatever your percentage is) Then do actions, else do actions
Collapse Then - Actions
Unit - Set life of (Picked Unit) to ((Life of (Picked Unit) - 10.00)) (Or whatever the damage should be)
Collapse Else - Actions
Do Nothing
Custom Script - call DestroyGroup( udg_Damage_Group )
12-09-2006, 05:14 PM#10
The_AwaKening
Yes, that would cleanup the leak.
12-09-2006, 07:31 PM#11
BlinkBoy
That's the annoying way, make it better like this:

Trigger:
Collapse Events
Every 1.00 seconds of game-time (or whatever you want it to be)
Conditions
Collapse Actions
Custom Script - set bj_wantDestroyGroup = true
Collapse Unit group - Pick every unit in ((Units in Playable Map Area) matching ((Matching Unit) has buff (Your Buff) equal to True) and do (Actions)
Collapse Loop - Actions
Set Damage_Chance = Random number between 1 and 100
If (All Conditions are True) then do Actions, Else do Actions
Collapse If - Conditions
Damage_Chance is less than or equal to 55 (or whatever your percentage is) Then do actions, else do actions
Collapse Then - Actions
Unit - Set life of (Picked Unit) to ((Life of (Picked Unit) - 10.00)) (Or whatever the damage should be)
Else - Actions

the reason is because the function ForGroupBJ got a flag variable [bj_wantDestroyGroup] to edentify when you want the own function to destroy the group, that way you can save the job of declaring a global variable.

Collapse JASS:
function ForGroupBJ takes group whichGroup,code callback returns nothing
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false
    call ForGroup(whichGroup, callback)
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction
12-09-2006, 08:27 PM#12
Pyrogasm
Hmmm. I really don't understand anything but the most elementary JASS (the first half of Vex's tutorial is all I've read), but I think I understand what you're saying. If I had multiple groups, would I need only that one line, or would I have to CnP it before every Unit group function?
12-09-2006, 10:45 PM#13
Anitarf
You would have to copy it before every Pick-every-unit-and-do-actions action, since the ForGroupBJ function sets the boolean back to false when it runs.