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

[AI] Creating a Dota Style AI <-- 1/2 finished need a guide

Status
Not open for further replies.
Level 2
Joined
Apr 25, 2008
Messages
17
Im creating a dota style AI <-- inspired by Dota All Stars AI. This is my first jass work and triggers work. In fact first work with game modification/map making. So ... people may criticise my work and how i do/doing it, but this is how i learn, i try do the impossible and work from it. I've spent a couple of days working on this script including research and reading tutorials.

Anyway to the point, i need a guide to create an AI similar to the one above! Or any Dota AI scripts. Ive tried to look at that map's script but its protected. Not sure if xdep does mess things up but i use that as well and then i couldnt read it, way to unfriendly. Any pointers to any unprotected maps, or any scripts? thanks

BTW: theres many memory leaks, repeting triggers etc, i know but im working on it :D

Edited* with the updated AI script
 
Last edited:
Level 2
Joined
Apr 25, 2008
Messages
17
hmm ... i done the AI in jass script so i thought i'll post here, but i guess i could move to the AI thread :p
 
Level 2
Joined
Apr 29, 2008
Messages
7
It might be easier to critique if you added a link to your map file. It is hard to comment on AI unless it can be seen in action.

From skimming your code it looks like your Mutex stuff isn't being used at all (neat idea though).

Otherwise it seems like your code lets the heroes return to base for healing and buying items, and also allows them to navigate the battlefield, and upgrade thier str/agi/int stats.

I don't see anything about casting/learning abilities or using items. Also the DotA AI that I've seen seems pretty smart in combat...it will deny kills on creeps and towers and gang up to gank heroes.

Hope that helps!
 
Level 2
Joined
Apr 25, 2008
Messages
17
mutex idea found on jassvault made by some one, didnt realise his name wasnt in the script. anyway credit to him :D
didnt use the mutex since i have handle vars passing values across triggers.

I'll post a map, but the map isnt mine, and i dont really have any right to edit it as it "was" protected and seems the guy who made it hasnt been active since 2007.
The map required user to buy spells etc and their ability upgrades are stats. err... atm i havent implemented them casting spells as such as they already cast spells (because of their build in ai)

i've had a problem where say 6 mins in the game (for 2 players <- 1 player, 1 ai) the game suddenly freezes. like intense lag or something, but i've checked my code and cant find any leaks .. to my knowledge. I assume its cos i have at least 2 triggers triggering every 1 second for each ai. So throughout the game there will be at least 10 triggers triggering every second and they when the players are in the home zone .. another 10. and then each ai has 1 looping trigger to check life ... another 10. So theres at least 30 + triggers running simultaneously every second.

When the game starts its ok but then you can feel it slowly lagging to death. Are these triggers a problem?
 
Level 2
Joined
Apr 29, 2008
Messages
7
You could always apply your code to the free DotA template...if your are trying make a DotA AI it is probably a closer fit than the map you are hacking. The template is here:

http://world-editor-tutorials.thehelper.net/maps.php?view=137

When the game freezes 6 min in does it totally lock up, or does it just hitch for a second? If it outright freezes, maybe there is a bug in a trigger or your code, such as an infinite loop?

With memory leaks you will see the game get progressively slower and slower, but it could also happen if you have code that runs very often (dozens or hundreds of times per second) for each unit. Code that runs once a second shouldn't be a big deal and at worst would have the game 'hiccup' every second instead of just bogging down.
 
Level 2
Joined
Apr 25, 2008
Messages
17
Much better, lless - no lag. although i havent thoroughly tested it. I reduced the number of periodic triggers ... just one and turned it to a timer. Max triggers running at one time is prolly about 10 or something now i think. Still problem of units getting stuck buying an item. Also item buying lags, dont know y. This ai creates an item at a players feet then adds it to their inventory. Seems theres some sorta lagging when a item is created. Is there a way for AI to buy from a shop interactively as in they come in contact with a shop then randomly choose an item? not just having a simulated buy system

When units built in ai casts a spell.. they stop. need to somehow fix that .. anyway i'll upload the map

responding to that question .. there are plenty of Dota maps with ai already. e.g. Dota Allstars with AI+. Im making a Dota 'like' ai.. i assume thats what i would call it since that has inspired me but for a different kind of map.

*Edit* Oh yeh.. map is by spectralizer. Sorry for hacking your map if you ever read this thread :D
 
Last edited:
Level 2
Joined
Apr 29, 2008
Messages
7
Wow the whole map is run with Jass...no GUI triggers at all? That must be tough to debug!

I see the lag at the beginning when the AIs buy items....it seems to happen when the 'executing buy loop' text pops up. Could it be that the item isn't preloaded, so when it is bought the game loads it from disc?

Also a few seconds later I"m getting an access violation at 0x001C.
 
Level 2
Joined
Apr 25, 2008
Messages
17
hmm .. i duno if the map was originally made in GUI or Jass. Erm doing it in jass seem easier than GUI ... gui is confusing to me plus i havent really used it. Changeing the code is easier also, i think i mentioned changing large chunks of the ai.

Um the lag happens when an item is moved to the unit inventory, not when the item is created. I tried a test where item is just created at the units feet and not transferred and it seems ok. Then adding the transfer code ... <-- lag. or maybe its because both of them have a lag factor and when done simultaneously by a few units .... the lag factor would be big! hmm i think im going to try having an item premade and then transfer it to the unit when its premade.

Hmm i have no problems with a memory access error tho... have you tried running it again? i now have a problem, say a unit goes to the battle zone which triggers that unit to pick a random path and go to the next region. when unit dies and revives, he will instantly go to the battle zone but it would not trigger when he enters region. thats been bugging me for a while now ..
 
Level 2
Joined
Apr 25, 2008
Messages
17
haha .. just realised what i done wrong. The main AI function is run using ExecuteFunc so it runs waits.

I put a triggersleepaction(50) before a load of RemoveRegions for the triggers assuming the wait will halt the code there but ... it didnt. I've deleted the whole load of remove regions now .. should work .. here is the map

just looked in the GUI for making a buy item script from and it seems that way uses UnitAddItemSwapped which just calls UnitAddItem... it must be the custom items causing the lag? hmm
 
Last edited:
Level 2
Joined
Apr 25, 2008
Messages
17
almost finished now, The map can do Almost everything other than retreating correctly, it just retreats when life is less than 30%, Also need to code in locking on to enemy heroes, and charging at them when it is sensible to do so. I have decided to implement a threat system so that if the unit is threatened it will retreat.

The contributions to the units threat is the distance from home base, total life, nearby friendly heroes, nearby enemby heroes, frendly(expendable) units nearby, enemy units nearby.

Im trying to think of a formula which will incorporate all these points but im not a very maths person, cant think of how it will work.

has anybody got suggestions or a better system?
 
Status
Not open for further replies.
Top