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

The unit - attack

Status
Not open for further replies.
Level 2
Joined
Feb 1, 2012
Messages
16
Next question, again I can't seem to find the answer elsewhere.

I created a trigger to attempt to make towers prioritize champions last when choosing their next target. It looks something like this:

  • Don't Attack Champs
  • Events
    • Unit - Dark Tower lvl 1 0128 <gen> Aquires a target
    • // Similar events for all other towers desired - other triggers add more events for new towers when they're created
  • Conditions
    • ((Targeted Unit) is A Hero) Equal to True
  • Actions
    • Set TempGroup = (Units within 512 of (Position of (Triggering Unit)) matching ((((Matching Unit) belongs to an enemy of (Owner of (Triggering Unit))) Equal to True) and (((Matching Unit) is alive) Equal to True)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Number of units in TempGroup) Greater then 0
      • Then - Actions
        • Set tempUnit = (Random unit from TempGroup)
        • Unit - Order (Triggering Unit) to Attack tempUnit
      • Else - Actions
By using Game - Display to all players the text x I've deturmined that yes, the trigger does run the then - actions when I want them to and do not run them when I don't want them to, however the tower doesn't show any change when the trigger is called in game, and just continues attacking the hero.

PS - I've tried Unit - Order (Triggering Unit) to Stop as well as and instead of (on different occasions) Unit - Order Triggering Unit) to Attack tempUnit. Stop does not seem to stop the tower from attacking either way.

PPS - Yes I know this function leaks a group or 2, but I'd rather get it working before I clean it up leak wise.
 
Level 2
Joined
Feb 1, 2012
Messages
16
I just switch the priority on all my heroes to 0 -> absolutely nothing new happened.

Perhaps it's because I didn't include Run Melee AI scripts (for computer players) since I want mobs to do what I tell them to. (spawn, attack move to a point which tells them to attack move to other points until they die)

Should I add that AI script? Would it help? Would it start giving minions this silly idea in their head that they should run away while wounded?
 
Level 2
Joined
Feb 1, 2012
Messages
16
Cokemonkey11->
I've done that, tempUnit is always an eligible new target that's not the hero, triggering unit is always the tower.

shinji ->
yes, so setting my heroes to 0 should make them be attacked last right?
Only it doesn't do that. The towers will still sometimes do things like attack heroes (priority 0) before grunts (priority 3) even when the grunts are closer to it.
 
Level 2
Joined
Feb 1, 2012
Messages
16
Because I want the tower to attack heroes only if the hero is the last unit in range. Otherwise I want it to attack units and not have the hero fear having the tower suddenly target them and taking off half their health really quickly.

Perhaps I can give the tower a hero only attack and a unit only attack and disable the hero only attack if it starts attacking heroes. Can you do that with triggers?
 
Level 2
Joined
Feb 1, 2012
Messages
16
So what I'm reading into this is the Warcraft 3 AI over rules triggers and can't be changed to do what I want it to. That's fine, I guess that AI improvement I wanted won't happen.
 
Level 17
Joined
Jul 17, 2011
Messages
1,863
Are you making something similar to the dota towers where in the beginning you have to be careful not to get hit too much, and you are saying that the tower ALWAYS attacks the heroes first instead of the creeps??

If yes then just be careful how you play lol run when the tower starts attacking you and let it attack the creeps, after it kills the creep it should attack the creep next to it if there are no creeps in the tower's range then yes it will attack the hero.
 
Level 7
Joined
Apr 30, 2011
Messages
359
why don't you do . .
  • Unit Group - Pick every units in a unit group and do Actions
    • Loop - Actions
      • If
        • Conditions
      • Then
        • Actions
      • Else
some more tips
  • If conditions
    • Condition - Priority[Unit user data (Picked unit)] less than Priority[Temp_Unit] OR Temp_Unit equal to No unit
  • Then
    • Set Temp_Unit = Picked unit
  • Else
this will need Bribe's Unit Indexer and a variable of type unit named Temp_Unit
and then order the tower to attack Temp_Unit . . . done ~
 
Level 2
Joined
Feb 1, 2012
Messages
16
yes my game is similar to DotA, although the tower is located in such a way that being able to be near towers without it possibly attacking you (if you have creeps nearby) would be nice.

The tower seems to attack the highest damage:survivability enemy in range from what I can tell.

I'm now considering moving the tower so players and mobs can fight without towers in the way, then attack the tower once they've won that battle.

overcold:
My code does have the correct tempUnit (as debug messages have told me), the problem is Unit - Order x to attack y isn't working.
PS. I've also tested with unit - cause x to damage y verifies this conclusion. (and works as I expect it to).

EDIT: I've just changed where my towers are and how troops attack them/each other so this problem is not as detrimental to my map anymore.
 
Last edited:
Level 7
Joined
Apr 30, 2011
Messages
359
if you have probs with the order . . .
use this to check (instead of a normal order action) . .

  • Custom script: if IssueTargetOrder(udg_Tower, "attack", udg_Temp_Unit) then
  • Custom script: call BJDebugMsg("ORDERED")
  • Custom script: endif
before doing that, do:
  • Set Tower = (ordered unit)
  • Set Temp_Unit = (targeted unit)
just replace those ordered unit and targeted unit with your needs . . .

if you see a "ORDERED" message on your game, then the tower attacks it ^_^
else, check the tower's Combat - Attack allowed targets . . .

and this is important:
  • Unit - Issue order with no target, issue Tower to "stop"
  • Unit - Issue order . . . .. . . . . .
notice the stop :D

hope this help ~

edit:
i noticed your trigger's event . . .
it should be Unit - Generic unit is attacked . . . .
that's why it can't be stopped, it hasn't attacking yet ~.~
 
Level 2
Joined
Feb 1, 2012
Messages
16
I was using "acquires a target" for specific units because it called the trigger when I wanted it without calling it every time a unit is attacked, the difference is from about 1/sec calls to 100/sec or so. Not sure how much this would increase performance when I have conditions that have the trigger actually happen about 1ce every 20 or so seconds (depending on how careful the players are).

Despite this I did try your trigger and it does work ty.
 
Status
Not open for further replies.
Top