• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

General Unit Acquires a Target

Status
Not open for further replies.
Level 7
Joined
Jun 16, 2008
Messages
253
Can this be done? Not a specific unit acquires a target, but an event that will respond to any unit that acquires a target, or notices a target in range?

What do you think? If I can find a way, it shouldn't simplify certain (very large) triggers enormously.

EDIT: Perhaps this should be moved to the Triggers and Scripts forum. My bad.
 
Level 11
Joined
Oct 20, 2007
Messages
342
ermm, i think u should use other way for that.
like:
  • Target
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to <your trigger> the event (Unit - (Triggering unit) Acquires a target)
 
Level 17
Joined
May 6, 2008
Messages
1,598
Grwararsldsald!

Trigger related questions go to TRIGGERS & SCRIPTS.

It's not so hard to check for yourself.

Make a trigger like this

  • Events
    • Unit - A unit acquires a target
  • Conditions
  • Actions
    • Game - Make a message with the text Testing.
This is just rough.
 
Level 7
Joined
Jun 16, 2008
Messages
253
Dudeness

Trigger related questions go to TRIGGERS & SCRIPTS.

You know I had noticed that... :gg:

But I had just posted another thread here and accidentally repeated myself. If I knew how to move it I would.

Um. Could you guys please lead me through it veeery slowly, I'm brand new on custom script scene, so won't grasp certain things you take for common knowledge.
The Event Unit - A unit acquires a target, is what I want to get.
However, the only place I see the function acquires a target is under specific unit, and not general, not even Player owned.
How do I get the general version?

If the answer is quite literally within your posted triggers, please write it out accurately for me so I can grasp what I dealing with. I know enough to figure out most custom script or JASS.

Btw, I have been cannibalising all sorts of related trigger functions to piece together a General Unit event. But basically it tells me I can't mix 'playerevent' and 'unitevent', and I'm having trouble figuring out where to go from there.
 
Level 17
Joined
May 6, 2008
Messages
1,598
Hm. I'm not 100% sure about what you want.

You want if a unit acquires a target, you want it to do an action.

This won't require any custom script.
 
Level 7
Joined
Jun 16, 2008
Messages
253
Do you guys have a function that is missing on New Gen?
I'll try to lay out what I have.

I can use GUI to go:

Event- Specific Unit acquires a Target
in the game it would look like
Event - Footman_0023 acquires a Target

I CANNOT use GUI to go
Event - Generic Unit acquires a Target
or even
Event - PlayerOwnedUnit acquires a Target.

I have the choice of using a specific unit or unit variable for my Event, but nothing that will chime when ANY unit, or any unit of type, or any unit matching condition, acquires a Target.

Therein is my dilemma. I want the Event to fire when ANY unit acquires another target, or notices a target in range type deal.
But unless New Gen is missing something vital, there is no pre-existing function to cover this. My only resort is to use a periodic event and write complicated triggers just to find the appropriate unit and take action.
 
Level 7
Joined
Jun 16, 2008
Messages
253
I'll get back to you on that... Corse you'll probly have to wait two weeks as I'm about to go away for 2 weeks for study course. But I'll try it. I'll be so gutted if my suspicions are confirmed and New Gen has killed as much as it's created.
 
Level 7
Joined
Jun 16, 2008
Messages
253
Yeah. It doesn't exist. I guess I'll have to either live without it, or learn some advanced programming skills :D. I don't see either happening any time soon. :(
 
Level 11
Joined
Oct 20, 2007
Messages
342
I have given u a trigger....did you try it??
let me explain more clearly if u don't understand.
1) Create 2 new trigger.
2) 1st trigger let it empty 1st, and 2nd trigger do that...
3) Enter an event - an unit enter <region>
4) <region> choose Playable map.
you like this:
  • Events
    • Unit - A unit enters (Playable map area)
5) add an action, go to trigger > add new event to trigger
6) Trigger - Add <trigger> the event <event>
7) <trigger> is that empty trigger who create in the 1st step.
8) <event> - go to Unit > Specify unit > unit acquires a target.
9) like this "Unit - <unit> Acquires a target"
10) <unit> to triggering unit.
like this:
  • Target
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to <1st trigger> the event (Unit - (Triggering unit) Acquires a target)
And last...
Add the action or condition that you want to the 1st trigger.
like:
  • Generic
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to <First Trigger> the event (Unit - (Triggering unit) Acquires a target)
  • First Trigger
    • Events
    • Conditions
    • Actions
      • Game - Make a message with the text Testing.
 
Level 13
Joined
Nov 4, 2006
Messages
1,239
jareph your trigger does not include the units which are already in the map, but you can get them with a trigger at map initalization which picks every unit in playable map area and adds the event picked unit acquires a target, but for the rest it does work
 
Level 7
Joined
Jun 16, 2008
Messages
253
Sorry, forgot to add thanks for the above trigger! I stuck in a note about it in my map, and I will use it. It's a brilliant idea!
 
Level 6
Joined
Jul 25, 2005
Messages
221
Sure, its a brilliant idea, the only problem is that it leaks enormously...
Look, for every unit that is or will be (I assume you can create units) a new event will be created on one trigger.
Now, if you have 4-10 units on the entire map it's not a problem so far, creating 20 -30 more units will add up to your trigger, so far just a slight lagg I presume.
Let say all your units on the map die and you create an equal amount of units again that will add to your "add trigger event" on trigger, the old events (your old units) will not be deleted, they will in fact remain, so after about, oh, I don't know, 30 mins?, it will start to lagg a bit because of this. To fix this you have to do it in JASS... :cute:

Hope you understand what I'm trying to say here, 'cause I'm a weirdo...
 
Level 7
Joined
Jun 16, 2008
Messages
253
Lol, I get it. Isn't there a remove event thingy though? I have NewGen 1.5, isn't that able to remove event as well as add anyhow?
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
No... Blizzard have no jassfunction (or gui-feature) that removes an event.
There is however ways to remove triggerconditions and triggeractions

To destroy an event you would have to destroy the trigger. Thus making this a tricky matter since it can't be done in pure gui without leaking.
 
Level 7
Joined
Jun 16, 2008
Messages
253
Ah... buggar. What does doing it in Jass offer? Is there a good method for doing it in Jass?
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Well in jass, you could create a separate trigger which would be used for every unit of those you want to register. In the same time you can add a death event for the same unit, and if the unit would die, you can destroy the trigger for that unit.
Thus preventing leaks, but duplicates the amount of handles so it could evolve the memory usage more. I don't think its any larger different though. (handles are everything except reals,strings,codes or integers. For instance units,points,regions,triggers are handles)
 
Level 7
Joined
Jun 16, 2008
Messages
253
Ah is there a create trigger thing, is that what you mean?

In any case, thanks for the info about handles, i always wondered wth everyone was talking about with handles.
 
Level 23
Joined
Nov 29, 2006
Messages
2,482
Yah there is, but not in GUI as told. When you use the "create trigger" alternative in the normal GUI form, a trigger is always created automatically and stored in a global variable. With Jass, you can create a "local" trigger variable and still keep track of it and destroy it by using GetTriggeringTrigger(). In pure Gui this is impossible to do. It is possible however by using the custom script action, but that would involve more than one custom script action (Definition of custom script: an action which is coded in pure Jass language).
 
Level 11
Joined
Oct 20, 2007
Messages
342
ermm, i think that not a problem.
i m tested with my sux and slow computer (play dota also lag like hell)
i m creating 20 unit per sec over 30 seconds.
mean that i m created 600 unit. (the unit[footman] has not decay and can't raise to make it more accuracy)
and using that trigger i provided.
i din't get any lag after 30 seconds.
Trigger:
  • Untitled Trigger 001
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set CenteroftheMap = (Center of (Playable map area))
      • Set Playablemap = (Playable map area)
  • Untitled Trigger 000
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 20, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player 1 (Red) at CenteroftheMap facing Default building facing degrees
          • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
  • Untitled Trigger 002
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Trigger - Turn off Untitled Trigger 000 <gen>
  • Untitled Trigger 003
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Untitled Trigger 004 <gen> the event (Unit - (Triggering unit) Dies)
  • Untitled Trigger 004
    • Events
    • Conditions
    • Actions
      • Set A = (A + 1)
      • Game - Display to (All players) the text: (String(A))
I dint get any lag with this slow computer...
"Intel(R)
Celerom(R) CPU 1.70GHz
1.70GHz, 512 Mb of RAM
NVIDIA GeForce FX5200"
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
That example is bad, the footmen would cause any lag you would get. I can't honestly say I know exactly how bad a performance hit that this leak is, though. However, the leak is obvious, you shouldn't need to test it to see it.

Also, on a side note, your implementation of that shows you don't really understand leaks at all, anyways.

The non-leaky way of doing it in Jass is simply to create a trigger with the right event and action every time a unit enters the map, and remove it when they decay, attaching the trigger to the unit so that this works properly.

Here's an example approach for a similar event - (Unit) takes damage. Note that it's outdated in that it uses CSCache, while vJass is much preferrable.
 
Level 7
Joined
Jun 16, 2008
Messages
253
It looks like there is an inevitable memory buildup (leak), perhaps it is very minimal.
Even so, I would prefer one I can close off, such as destroytrigger, so I would definitely be doing the createtrigger one, since there is no remove event.

Thanks guys! Now I just have to remember why I wanted this in the first place. I know it's something to do with the guards... X.X

Cookehs for all! (If my rep actually means something, apparently if you have low rep you don't really give rep, but it's the thought that counts right? Right?)

EDIT: Btw Eccho, I do at least know a tiny bit about script, I know what custom script is. Just so you know. :D. I feel so degraded. :(
 
Last edited:
Status
Not open for further replies.
Top