• 🏆 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!

Very Difficult AI System + Projectile Problems

Status
Not open for further replies.
Level 14
Joined
Aug 31, 2009
Messages
775
Ok, let me introduce the problem first, as this isn't a straight forward quick-reply problem.

I'm making a map called Magi Deathmatch Arena - it's a projectile based free-for-all death match game where items are gathered from the floor to learn your spells and then you basically shoot other people and kill them. Simple.

Now, the thing I want to add to this map before I officially release it is an AI.

I've done the majority of the groundwork for the AI now: It can walk around the map, gather items, learn spells, use items and even change personality from a defensive gathering personality to an aggressive combat personality depending on the situation.

Now.. the problem is, it simply will not cast ANY spells at all. Even though all the spells are based on Channel and given different order strings (Stampede, Silence, Shockwave, Stasis Ward etc.) that are appropriate order strings for a point target, it still refuses to work.


What's more is, out of absolutely freaking nowhere my Firebolt projectiles just stopped working.
Prior to adding this AI system, every spell worked absolutely perfectly, now suddenly without even touching the projectile triggers, Firebolts don't work.

This is how they SHOULD work:
- You shoot a firebolt in a straight line. If it hits, the target is set on fire.
- If the target is already on fire then the damage is instant instead of over time.

What is now happening:
- The target gets the fire graphic, but is not added to the "Fire" unit group, and hence no damage is dealt by the fire.
- If the target is already on fire, it applies ANOTHER fire, but still doesn't add them to the unit group or deal any damage.

As these issues are complex, there's only one way to get some help. The map is attached, and my eternal gratitude and as much rep as I'm actually capable of applying will be given to whoever manages to solve both problems.

I've included trigger comments to point you out to the "broken" sections of code, as well as a test trigger that will periodically tell you with Game messages the current target of Player 2 Blue (if it's an AI that is) and its AI state (1: Gather, 2: Combat, 3: Search) to help with finding the problems.

Map is attached, and again, many many thanks to whoever can help in this. You can change as much as you like as long as it fixes the 2 problems described above.

PS: I know some triggers may be leaky in places, I'm still working on that.

EDIT: Attachment removed as problem is resolved.
 
Last edited:
Level 12
Joined
Apr 15, 2008
Messages
1,063
Allright, the problem with casting is that you changed "Base order ID", but orders are actually in "Text - Order - Use/Turn on", so change that field, too (propably to same value as Base order Id).
As for the fire system, it seemed to work for me, there were some floating text indicating damage, and also the units seemed to lose HP over time.
 
Level 14
Joined
Aug 31, 2009
Messages
775
Great thanks, I'll give this a try now and see if it changes anything.

{EDIT}
Unfortunately, even after changing the Use/Turn on ID, the AI still will not use the spells.

Also... the fireballs ain't working on my PC. But yes, there should be floating text that indicates the damage and reduces over time - so for some reason it's working fine for you, but not me.
 
Last edited by a moderator:
Level 15
Joined
Dec 18, 2007
Messages
1,098
You can't order AI to cast spells based off Channel, I believe it just doesn't work that way.
However, I think there is a way to order the AI to cast the spell, gimme a minute to get the JASS code for it.

Use this script:
IssuePointOrderByIdLoc(udg_CompUnit, OrderId, udg_temploc2)

OrderId for each spell:
Firebolt - 852593
Frostbolt - 852125
Forcebolt - 852658
Stunbolt - 852592
Arcane bolts - 852114

I'll get the ID for Force shield if you need it.


As for Firebolt, I can't really be sure where it bugs.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
You can't order AI to cast spells based off Channel..

I just tested all 3 target versions of channel, they all work when ordered by trigger. I am now trying to implement that into the map.


The problem with fireball appeared for me too (I used more players than in previous test). There is one problem I saw, you use multiple "Pick Units in group" inside each other, which generally doesn't work.

EDIT: For some reason, multiple Pick units inside each other seems to work now (maybe blizzard fixed it in some patch lately). Your problem with Fireball is something else: the unit group "Fire" gets destroyed. One of the "set bj_wantDestroyGroup = true", which I noticed you use only in AI triggers, is called incorrectly (not preceding Pick units), it stays on true until some "Pick Units" is called, which is in the OnFire trigger.

EDIT2: The wrong set bj_wantDestroyGroup = true are the ones before "Pick items in region". This action works differently than pick units, it doesn't create any "Item group", therefore nothing needs to be destroyed, and the setting remains on TRUE.

EDIT3: After examining AI, it seems to me that they receive some orders immidiatelly after they cast the spell, preventing them from finishing the cast (problem is the combat reaction - they are evading from their own spells I think, the (Triggering unit) no longer works after the 0.1 wait, so the test (CompUnit not equal to (Triggering unit)) fails, and he tries to evade his own spell.) But it is possible that also other triggers are interfering, just test whether the unit is casting, and don't issue any other orders, if it is.
And another problem with AI is that sometimes they will walk directly on me, and start issuing "attack" order( which is nonsesce, since there are no regular attacks), and won't even try to cast anything.
 
Last edited:
Level 14
Joined
Aug 31, 2009
Messages
775
Wow M0RT that was quite amazing, sifting through all that and finding the issue.

This is actually one of the first times I've ever used the bj_wantDestroyGroup before, as generally I used the set tempgroup and destroygroup(udg_tempgroup) method. Funnily enough, this makes perfect sense that it is causing the issue here, as it actually once destroyed the Projectiles group and made that obviously made stuff go freaking weird.

So should I be using Zack1996's method of using IssuePointOrderByIdLoc(a,b,c) to issue the orders or is it just because they're being interrupted by other sources?

EDIT: Having said that, the combat reactions shouldn't technically be causing an issue, as it triggers on the Starts the Effect of An Ability, instead of when you start the cast.

EDIT: Fireballs are fixed now, I just deleted the wrongly called wantDestroyGroups and it worked perfectly. Now to solve the AI issues...
 
Last edited:
Level 12
Joined
Apr 15, 2008
Messages
1,063
It is strange, but apparently changing the Base Order Id is enough. (I detected orders, even with all of the abilities have "channel" as order string, the unit was getting different orders.) The abilities should work even when issued by order names, not just by IDs.
Try putting in some cast commands, same as you used to have, and set cast backswing and cast point to 0.0 (for testing purposes only). Then, if the casting works, the problem are interruptions. If not, orders.
 
Level 14
Joined
Aug 31, 2009
Messages
775
I'll give this a try on Sunday when I get back to my PC with War3 on it and see if it works.
Any ideas though why the AI appears to want to move onto the players instead of just standing still and doing nothing/attempting to cast? It shouldn't be ordering them to move onto the enemies at all, especially not an attacking order.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
Attacking order is propably some default AI, since the players are computers, they have some unit-AI. Although it is very strange, they have no attack.

Also I noticed some strange orders beeing issued, just as the game starts, for example, every AI issues the "stop" order about 10 times in 0.1 second or so. Simillary during the game, they issue always like 3 orders at one time.
 
Level 14
Joined
Aug 31, 2009
Messages
775
Yeah it seems pretty weird actually.

Perhaps if I made the units count as Workers that might remove the default behaviour of telling the units to attack.

..this also has the slightly useful effect of putting your mage in the "Idle Workers" slot area whenever they're not doing something making it a bit easier to select them.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
After looking at it once more I saw this problem:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between temploc and temploc2) Less than or equal to 450.00
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Not equal to Lightning Mine
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Not equal to Disruptor Ward
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Not equal to Drainer Ward
    • Then - Actions
      • Custom script: call RemoveLocation(udg_temploc)
      • Set temploc = (temploc2 offset by 450.00 towards (180.00 + (Distance between temploc and temploc2)) degrees)
      • Unit - Order CompUnit to Move To temploc
    • Else - Actions
      • -------- -------------------------------------- --------
      • -------- This is where the cast spells should be added. No matter what I do they don't seem to want to cast at all. --------
      • -------- -------------------------------------- --------
There is a clear mistake here, the direction is not supposed to be (180.00 + (Distance between temploc and temploc2)) degrees, but rather 180 + Angle between points

EDIT: Also, the second part of condition doesn't make sence, it is true when target isn't a ward or isn't a mine. Since it can be only one unit-type, at least two of the sub-conditions are always true.
 
Level 14
Joined
Aug 31, 2009
Messages
775
Ah yeah, thanks for noticing that mistake.

Essentially the function of that part of the trigger is to make it so the AI moves away from Wards/Mines rather than attempting to cast on them immediatly - which in the case of the wards they actually won't be able to do because one drains mana and the other blocks casting altogether.

I edited it to
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Distance between temploc and temploc2) Less than or equal to 450.00
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Equal to Lightning Mine
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Equal to Disruptor Ward
          • (Unit-type of CompTarget[(Player number of tempplayer)]) Equal to Drainer Ward
    • Then - Actions
      • Custom script: call RemoveLocation(udg_temploc)
      • Set temploc = (temploc2 offset by 450.00 towards (180.00 + (Angle from temploc to temploc2)) degrees)
      • Unit - Order CompUnit to Move To temploc
    • Else - Actions
      • (Casting Stuff)
That should probably work a fair bit better now...
 
Level 14
Joined
Aug 31, 2009
Messages
775
Oh wow, I've actually got them casting and attacking now. They are now properly capable of killing one another - and providing a basic easy challenge to a human player.

The problem was apparently that the Search Loop was interfering with the casting one, causing them to right click onto them rather than cast at them.

Thing is, now the Search personality doesn't seem to be working, but I'll work on that now. Once that's fixed, it's just time to get them to fight better such as moving around during combat etc.

M0RT, I don't think I can express enough gratitude to amount of help you've put in here!
 
Status
Not open for further replies.
Top