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

Where can I find information regarding unit Ai in maps like Castle Fight, Dota, etc

Status
Not open for further replies.
Level 2
Joined
Oct 21, 2019
Messages
11
I'm looking to create Ai for spawned units who are fighting each other, which aren't player owned units. Are there any good resources on here for this goal?

I want to influence things like.
* Attack priority

If I have a bunch of units attacking a building, and one unit spawns-- causing every single attacking unit to switch from attacking building to the spawned unit. Is there a way to manipulate the baseline targeting system?

Currently I just have things very basic. Simply spawning units in a region every 5 sec, triggering every unit in that region to attack move towards the enemy base. Vice versa for the opponent.
 
Level 12
Joined
Jun 15, 2016
Messages
472
I'm looking to create Ai for spawned units who are fighting each other, which aren't player owned units. Are there any good resources on here for this goal?

I want to influence things like.
* Attack priority

If I have a bunch of units attacking a building, and one unit spawns-- causing every single attacking unit to switch from attacking building to the spawned unit. Is there a way to manipulate the baseline targeting system?

Currently I just have things very basic. Simply spawning units in a region every 5 sec, triggering every unit in that region to attack move towards the enemy base. Vice versa for the opponent.

There is no easy way to change the baseline targeting, as far as I'm aware. If those units are computer controlled using an AI script, you can maybe work something out.

Example: you have units with unit type u0001 who are behaving normally. You can give this addition to an AI script:

JASS:
globals
   // Your global variables
   // ...
   // ...
   integer spawned_unit_type = 'evil'
   group spawned_unit_group  = null
   player evil_player = Player(X)
endglobals

function Fill_Spawned_Group takes nothing returns nothing
   loop
       call GroupEnumUnitsOfType(spawned_unit_group, spawned_unit_type, null)
   
       call Sleep(5.0)
   endloop
endfunction

function Attack_Function takes nothing returns nothing
   local unit spawned = FirstOfGroup(spawned_unit_group)
   
   if spawned != null then
       if UnitAlive(spawned) and GetOwningPlayer(spawned) == evil_player then
           AttackMoveKill(spawned)
       endif
   else
       // Your attack function
       // ...
       // ...
   endif
endfunction

function main takes nothing returns nothing
   // Your main function
   // ...
   // ...
   
   call StartThread(function Fill_Spawned_Group)
endfunction

If this script doesn't make sense, try reading about threads, captains and local/global variables (mentioned in AI tutorials here and here). If it is still a problem, post your script here.
 
Level 2
Joined
Oct 21, 2019
Messages
11
I'm pretty much brand new to the whole map development thing. Is it imperative to know how to write scrips in that manner in order to create maps? I have written in C# and C for school courses, so maybe I can learn it quickly. If possible I'd prefer to simplify things and keep it within triggers and such.
 
Last edited:
Level 12
Joined
Jun 15, 2016
Messages
472
I'm pretty much brand new to the whole map development thing. Is it imperative to know how to write scrips in that manner in order to create maps? I have written in C# and C for school courses, so maybe I can learn it quickly. If possible I'd prefer to simplify things and keep it within triggers and such.

It's not imperative. You can use a simple trigger to get a similar result. Something like a trigger when the spawned unit is created go over all units and order those units to attack the spawned. It's simple and will give you a result. There is a case to try scripts, and you might find it easier to get to if you have knowledge in C and C#, but if you start feeling overwhelmed go for the triggers.
 
Status
Not open for further replies.
Top