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

Need AI like Melee AI, only...

Status
Not open for further replies.
Level 6
Joined
Jun 18, 2011
Messages
147
Want AI to cast spells, but not randomly issue move orders

I need computer controlled units to stop running to their start location when they are created (whether they enter by trigger or by being trained.) Another example of this AI problem is that sometimes (usually happens after a battle) a computer controlled unit (that had been placed in the map using the WE) will run to a region that it has an order to move to in a trigger, but that trigger was never activated and was not even enabled.

Edit: More and better detail in my second post below.

I am using melee AI script because I want computer controlled units to cast spells.

My question:

Part 1
Is this a bug or is this a problem that everyone faces when creating an RPG?

Part 2
If it is a normal problem, is there an easy fix?

If you are a philanthropist and this problem sounds abnormal, would you mind dowloading and taking a look at my map.

Alternatively, I could take out the Run Melee AI and use a custom (JASS/vJASS/GUI) AI (not .wai) that makes units cast spells, but I don't see this being very efficient or effective if it is going to command around 20 different units and be triggered by, the only event I have only had small success with, "A Unit Is Attacked".


Edit: I explain the problem more below.

Edit: Solved
I had the AI casting spells and not bugging spells for one day, but I also noticed around that same day when I opened the map the next day, many of my changes from the previous day were not saved. I wonder if I used AI commands to use that .wai it would work.
That's what I needed to do. I needed to use
  • Player Group - Pick every player in (All players controlled by a Computer player) and do (AI - Start melee AI script for Player 1 (Red): KOTR AI.wai)
which has no build/attack orders, it has no guard position checked, and it has the condition (if town has gold mine) it would order attack/guard commands, and there are no gold mines in my map, so the AI doesn't order the units to move. Now I can finish making this single player with the help of the AI! I'm still having a lag issue with Drachen Fire, though. That spell worked fine when I transferred onto another map, but it lags on my map. I tried deleting all the doodads, but that didn't work. I'm going to try disabling all the triggers, next and I'll make a thread for help with this soon. THANK YOU FOR YOUR HELP I REALLY APPRECIATE IT, PM ME IF YOU DIDN'T RECIEVE REP.
 
Last edited:
Level 6
Joined
Jun 18, 2011
Messages
147
I have tried to use a customi AI. I imported the .wai and that actually worked for about a day. Then, the problem came back. Someone, please, test my map. The abilities are all cool and fun.

This is part of the problem: Choose a hero with the blue wisp and the newly created hero, owned by computer controlled blue, will take off and run into a corner, because the terrain is blocking the path.

To give you another visual... Cast the red King Arthur's Drachen Fire. Then, cast that spell using the blue King Arthur. The dragon flies to the left (blue) instead of straight up (red). This is because the dragon unit is given a move order by the AI, but it is only triggered to play its death animation.
 
Last edited:
Level 11
Joined
Jun 21, 2007
Messages
505
I've made a map where there's a knight controlled by computer player blue, and 2 trolls controlled by neutral hostile, and they pursue your footmen forever if you attack them.

The trick is to order them to attack-move to their current positions periodically.

..I'm starting to wonder what can not be done using periodic events..

EDIT: I'd suggest that the thread's name is changed to, like, Make Units not Come Back to Guard Positions
EDIT2: I don't really understand what your problem is.
 

Attachments

  • NotFollow.w3m
    12.6 KB · Views: 62
Last edited:
Level 6
Joined
Jun 18, 2011
Messages
147
@Mechanical Man

I'm really not sure that this is my problem, but it is definetly a good possibility.

Edit: I did
  • Player Group - Pick every player in (All players controlled by a Computer player) and do (AI - Ignore the guard positions of all (Picked player) units)
, but that didn't fix my problem

@kkots

Edit: I tested your map and its not going to fix my problem. I know this because: I let the blue knight chase my red knights to the corner. Next, let him kill all my footmen. Then, the computer controlled knight runs back to his starting location. That is my problem or at least something very similar to that. He is issued a move order after the battle.
 
Last edited:
Level 6
Joined
Jun 18, 2011
Messages
147
When I open your map it says, this map was saved with a more recent version of WE. Could this be causing the glitch? Can you check my JNGP in my signature, please?

I do like what I see in this workaround, but I'm not sure it will address the problem. I'll see if I can figure out how to test it in my map.

Edit: Why can't I just use something like Ignore/Recycle/Lock All Guard Positions.

Edit 2: I don't understand how this works. Do you have this set to issue Stop on a periodic timer?

Edit 3: I can't just issue the stop command to every unit on the map, and then periodically order newly created units to stop because I create dummy units for spells (which I create for the owner to cause dmg for that owner) and this could interrupt spellcasting.

Edit 4: Imagine this footman (in the map below) is a dummy for a spell, or is channeling a spell. I made the periodic check if he is channeling so I think that is sort of resolved with this workaround. However, the dummy unit is still going to move while it is being issued my Last Created Unit orders.
 

Attachments

  • NotFollow.w3x
    608.9 KB · Views: 54
Last edited:
Level 11
Joined
Jun 21, 2007
Messages
505
Just run the map in warcraft. Here is all you can learn from it:
JASS:
function Trig_Melee_Initialization_Actions takes nothing returns nothing
    call IssueImmediateOrder(gg_unit_hkni_0006,"stop")//the blue knight
    call IssueImmediateOrder(gg_unit_nftb_0005,"stop")//troll
    call IssueImmediateOrder(gg_unit_nftb_0004,"stop")//troll
endfunction

//===========================================================================
function InitTrig_Melee_Initialization takes nothing returns nothing
    set gg_trg_Melee_Initialization = CreateTrigger(  )
    call FogEnable(false)
    call FogMaskEnable(false)
    call TriggerRegisterTimerEvent( gg_trg_Melee_Initialization, 8.00,true )
    call TriggerAddAction( gg_trg_Melee_Initialization, function Trig_Melee_Initialization_Actions )
endfunction
EDIT for post below: you can place conditions into Unit Group loops like this:
Unit Group - Pick every unit in Units in Playable map area matching Unit-Type of Matching unit equal to Footman and do (Actions)
And yes the "stop" order will issued to units that have been recently produced and might prevent them from going somewhere. But you can use an order condition Current Order of Triggering Unit not equal to Order(move)

@Meticulous Neutral hostile can cast Unholy Frenzy without turning on melee AI scripts. Computer controlled players cast for example Slow with Sorceress when it's autocast, without turning on any melee AI scripts. I'm sure that training attack groups, constructing expansions and picking up items has got nothing to do with casting spells.
 
Last edited:
Level 6
Joined
Jun 18, 2011
Messages
147
I did, why won't you run mine >.>

look at my last post

This is not going to work. Please, try to understand why above or by testing my map.

Just removing "Run Melee AI Script" from the Initialization fixes the problem. However, then I have to create a trigger for every unit on the map or that will be on the map that has spells to get them to cast their spells.

eg.
  • Untitled Trigger 002
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Dark Ranger
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Life of (Attacked unit)) Greater than or equal to 100.00
        • Then - Actions
          • If ((Life of (Attacking unit)) Greater than or equal to 500.00) then do (Do nothing) else do (Unit - Order (Attacking unit) to Neutral Dark Ranger - Life Drain (Attacked unit))
        • Else - Actions
 
Last edited:
Level 12
Joined
Apr 16, 2007
Messages
262
I have a solution (albeit cheap, I agree)... try to use the trigger


  • Actions
    • Unit - Pause AI_Unit
    • Set temp_point = (Position of AI_Unit)
    • Unit - Order AI_Unit to Move To temp_point
    • Custom script: remove point(udg_temp_point)
    • Unit - Unpause AI_Unit
Something in that fashion may work, I'm not sure; triggers are not my strength to be quite honest. Normally that trigger would force your unit to stop, then while paused wipe the old order that made them senselessly wonder towards some point, and leave them standing where they spawned (in theory, at least).
 
Level 11
Joined
Nov 15, 2007
Messages
781
Base your abilities on blizzard ones, and computer will cast them normally, for example, unit will cast storm bolt on you instantly, thunder clap only at 3+ units, heal when you damage it and so on...

Only when melee AI scripts are run, which is the point of the thread.
 
Level 9
Joined
Nov 19, 2011
Messages
516
Not rly. You can make auto-cast ablilties so they will work even without AI.

-------------------------------------------------------------------------------------------------------------------------------------------

Base skil is Orb of Lighting (new).
Set chances to 100% (for all) and damage to 0 (set mana cost too if you wish so).
Make your skill (for e.g. Chain Lighting) with all data (even cd!).
Pin it onto Orb skill.
Auto cast ready.

-------------------------------------------------------------------------------------------------------------------------------------------

Of course you don't need it for heal or rage. Then just set it as main usege skill in editor, so it will be on autocast from begin.

-------------------------------------------------------------------------------------------------------------------------------------------
@hellblazer-14

It will not work couse fo that AI will make order once again. More usefull is makeing AI by triggers, becouse RPG AI usualy never fall back.
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
Not rly. You can make auto-cast ablilties so they will work even without AI.

-------------------------------------------------------------------------------------------------------------------------------------------

Base skil is Orb of Lightning (new).
Set chances to 100% (for all) and damage to 0 (set mana cost too if you wish so).
Make your skill (for e.g. Chain Lighting) with all data (even cd!).
Pin it onto Orb skill.
Auto cast ready.

-------------------------------------------------------------------------------------------------------------------------------------------

Of course you don't need it for heal or rage. Then just set it as main usege skill in editor, so it will be on autocast from begin.

-------------------------------------------------------------------------------------------------------------------------------------------
@hellblazer-14

It will not work couse fo that AI will make order once again. More usefull is makeing AI by triggers, becouse RPG AI usualy never fall back.

its nice coz could give auto purge and usefull with item abilities too like item purge and item rune buffs
 
Level 9
Joined
Nov 19, 2011
Messages
516
its nice coz could give auto purge and usefull with item abilities too like item purge and item rune buffs

It not gives auto-purge. It works this way:

If NOT <<puted_skill>> in cooldown then order - cast <<puted_skill>> on target of attack;

It will not purge if puted skill won't be it. This skill can cripple, hex, course, slow, stun etc. Unlucky only offensive spells.
 
Level 6
Joined
Jun 18, 2011
Messages
147
Thanks everyone,

Once I figure out what MajorKaza's idea is I'll report back. It sounds good, but I haven't tried it. I just read it and it was a little confusing at first glance. It might not work for every spell, though.

Edit: After reading that it only works for single target spells. Its definetly not gonna work >.>
 
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
It not gives auto-purge. It works this way:

If NOT <<puted_skill>> in cooldown then order - cast <<puted_skill>> on target of attack;

It will not purge if puted skill won't be it. This skill can cripple, hex, course, slow, stun etc. Unlucky only offensive spells.

i know how it work

so my warcraft buggy? coz for me work the auto purge also its default ability with Orb of lightning but maybe ur warcraft is different than mine :p :D

since blizard made item purge ability its work well also detectable by trigger when orb of lightning item auto cast a item purge [2] :p
 

Attachments

  • 1.jpg
    1.jpg
    69.8 KB · Views: 80
  • 2.JPG
    2.JPG
    76.3 KB · Views: 83
Level 11
Joined
Jun 21, 2007
Messages
505
I don't understand what your problem is.
Why don't you want to pick every player that's controlled by a computer and then pick all his units and order them to stop, every 8 seconds? That will make them not go anywhere and stay where they are.

I've downloaded your map, opened it and saw that although there is an ai script imported, it doesn't have any build orders, attack waves, hero training, and it is never turned on for any computer players in triggers.

For example, we have a Knight controlled by Player 2 (Blue) and a Footman controlled by Player 1 (Red). Now, red Footman comes to blue Knight and Knight starts chasing Footman to a corner.
Footman dies. POINTA= "Now Knight goes back to where it was placed in World Editor."

If you use my fix, then POINTA will change to "Now Knight stands where he is after he killed Footman in the corner." And it will work not only for Knight, for any unit.

For example, if you make a trigger in which you order a unit to move to a region, then turn that trigger off by unchecking it in the Trigger Editor, then test the map and see that the order is issued to the unit anyway, then hmm that's impossible. Probably you turn it on somewhere.

EDIT: you could check if a unit is a dummy and not issue stop order to him...
EDIT2: Do you really need an AI at all? Computer can cast spells without AI.
And AI - Start melee AI script require a file with extension .ai, not .wai which is used to automatically generate .ai script in editor.
 
Last edited:
Level 6
Joined
Jun 18, 2011
Messages
147
Edit: I figured it out!!! First post has detailed solution.

I don't understand what your problem is.
Why don't you want to pick every player that's controlled by a computer and then pick all his units and order them to stop, every 8 seconds? That will make them not go anywhere and stay where they are.
How does every 8 seconds account for a spell with a computer controlled dummy that is created and expires in one second. Half of my spells are bugged when used by a computer controlled unit because the dummies are made for the owner. Then, the computer orders them to move and the orders and conditions of the spell get all messed up. So, your workaround really doesn't help me.

I've downloaded your map, opened it and saw that although there is an ai script imported, it doesn't have any build orders, attack waves, hero training, and it is never turned on for any computer players in triggers.

Hmm, I read that Run Melee AI Scripts (for computer players) uses the imported AI if you have one. And, I thought I only used that action when the map was working with it. I had the AI casting spells and not bugging spells for one day, but I also noticed around that same day when I opened the map the next day, many of my changes from the previous day were not saved. I wonder if I used AI commands to use that .wai it would work. I was hoping for someone to be able to tell me just use... call setAI_For(All_Computer_Controlled) to only cast spells and not get issued any other orders. Haha... Not exactly, but I mean I thought this would be an easier problem to solve.

For example, if you make a trigger in which you order a unit to move to a region, then turn that trigger off by unchecking it in the Trigger Editor, then test the map and see that the order is issued to the unit anyway, then hmm that's impossible. Probably you turn it on somewhere.

Well, something happens first. For example, I aggro a mob, then computer blue comes to help. Next, something happens like: I unaggro the mob before the computer controlled unit comes to my aid, and instead of going back to its initial position, it moves to the region that it is ordered to move to, but the trigger is not even on. This made me think my map is bugged.

I also wonder if something happened to my jassnewgenpack. I thought it was updated, but everytime I open a map it says asks if I really want to open it because the map was saved with a more recent version of WE.

OMG I figured it out. First post has detailed solution.
 
Last edited:
Level 9
Joined
Nov 19, 2011
Messages
516
i know how it work

so my warcraft buggy? coz for me work the auto purge also its default ability with Orb of lightning but maybe ur warcraft is different than mine :p :D

since blizard made item purge ability its work well also detectable by trigger when orb of lightning item auto cast a item purge [2] :p

I thought that you said that this skill will purge with each hit AND cast spell, but its not.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I thought that you said that this skill will purge with each hit AND cast spell, but its not.

item ability cast another item ability :p so orb of lightning cast item purge ability on target and default got chance but u can make it purge target with each hit too, u can test urself just give item lightning orb new ability(or item what have this ability) to ur unit and change the percentage, and its work fine :p
 
Status
Not open for further replies.
Top