I want AI (computer player)

nnieheayp

Member
Reaction score
2
I also made hero defence map same as DotA. But it is still in beta. I want ai for that map. How can i make that. Please help me . This is my map.
 

Admit

New Member
Reaction score
25
Trigger it, using either Jass or GUI.
I recomend using Jass when programing AI's but it can be done in GUI. (i have done a few in GUI)
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
I'm not going to one for you, because I'm busy with my own, but here's how I did mine:

I had a string array that held the current AI order for each AI hero, with array number realting to owning player
Every second, I ran a series of checks for each AI hero, to check what their current status was.

The check worked like this:
  • If the AI had low health, it was ordered to retreat.
  • If it was idle, it would start 'roaming', or looking for heroes.
  • If it was attacking, it would check if there were enemies in range, and if not, start roaming again.
  • If it was attacking, it would try to use abilities.
  • If it had retreated, it would check if it had enough health again, and make it roam.
  • If it was attacking, it would also pick every enemy in range and calculate it's chances of winning, and push forward or fall back depending on the outcome.
Create a periodic trigger that checks the unit's status, then runs a trigger just for it. That's were JASS comes in, you can run functions for single units.

Just a hint, with a thread title like that, you won't get many replies, you actually sound pretty rude. Rather say "AI help please" or "AoS AI system requested" or "Does anyone have an AoS AI system?".
 

nnieheayp

Member
Reaction score
2
I'm not going to one for you, because I'm busy with my own, but here's how I did mine:

I had a string array that held the current AI order for each AI hero, with array number realting to owning player
Every second, I ran a series of checks for each AI hero, to check what their current status was.

The check worked like this:
  • If the AI had low health, it was ordered to retreat.
  • If it was idle, it would start 'roaming', or looking for heroes.
  • If it was attacking, it would check if there were enemies in range, and if not, start roaming again.
  • If it was attacking, it would try to use abilities.
  • If it had retreated, it would check if it had enough health again, and make it roam.
  • If it was attacking, it would also pick every enemy in range and calculate it's chances of winning, and push forward or fall back depending on the outcome.
Create a periodic trigger that checks the unit's status, then runs a trigger just for it. That's were JASS comes in, you can run functions for single units.

Just a hint, with a thread title like that, you won't get many replies, you actually sound pretty rude. Rather say "AI help please" or "AoS AI system requested" or "Does anyone have an AoS AI system?".

Sorry for my rude title because i'm very poor in english. And, can you show me a sample ai trigger.
 

Sevion

The DIY Ninja
Reaction score
413
AI are very complicated. No AI should be the same.

When you ask for a sample, there's just too many aspects to put into the sample. And showing the very basics wouldn't really help as it's just be stating the same thing da1nOnlyEd said OR it'd be showing another method.

Personally, I'd use events. They fire much faster.
 

LurkerAspect

Now officially a Super Lurker
Reaction score
118
It's really hard to explain or show someone how to do it, but what I do is put every AI-controlled hero into one group, then for each unit, check what that unit's status (string variable array) is, and then call a function to make him do something.

I'm still working on one now, I'll show you wat I have so far: In this, the hero is checking to see were he is and then moves along a lane. It looks really complicated, but it just takes a little math:
JASS:
scope AIEasyLevelFunctions

public function Roam takes integer int returns nothing
    local unit u = udg_AI_Hero[int]
    local real array tX
    local real array tY
    local real uX = GetUnitX(u)
    local real uY = GetUnitY(u)
    local real array stepdist
    local real array unitdist
    call BJDebugMsg("...roam function called successfully.")
    if udg_AI_CurrentLane[int] == "left" then
        if IsPlayerInForce(GetOwningPlayer(u), udg_Defenders_AIPlayers) == true then
            set stepdist[1] = CustomFunctions_Distance(GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress), GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))-10
            set unitdist[1] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))
            set stepdist[2] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft), GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))+10
            set unitdist[2] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))
            set stepdist[3] = CustomFunctions_Distance(GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft), GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))+10
            set unitdist[3] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))
            call BJDebugMsg("distances set")
            if unitdist[1] < stepdist[1] and unitdist[2] > stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))
                call BJDebugMsg("unit issued order to attack to topleft")
            elseif unitdist[2] < stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))
                call BJDebugMsg("unit issued order to attack to bottomleft")
            elseif unitdist[2] < stepdist[2] and unitdist[3] < stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))
                call BJDebugMsg("unit issued order to attack to OCenter")
            endif
        elseif IsPlayerInForce(GetOwningPlayer(u), udg_Raiders_AIPlayers) == true then
            set stepdist[1] = CustomFunctions_Distance(GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress), GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))-10
            set unitdist[1] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))
            set stepdist[2] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft), GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))+10
            set unitdist[2] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))
            set stepdist[3] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft), GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))+10
            set unitdist[3] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))
            call BJDebugMsg("distances set (right)")
            if unitdist[1] < stepdist[1] and unitdist[2] > stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_BottomLeft), GetRectCenterY(gg_rct_BottomLeft))
                call BJDebugMsg("unit issued order to attack to bottomleft")
            elseif unitdist[2] < stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_TopLeft), GetRectCenterY(gg_rct_TopLeft))
                call BJDebugMsg("unit issued order to attack to topleft")
            elseif unitdist[2] < stepdist[2] and unitdist[3] < stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))
                call BJDebugMsg("unit issued order to attack to HCenter")
            endif
        endif
    elseif udg_AI_CurrentLane[int] == "right" then
        if IsPlayerInForce(GetOwningPlayer(u), udg_Defenders_AIPlayers) == true then
            set stepdist[1] = CustomFunctions_Distance(GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress), GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))-10
            set unitdist[1] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))
            set stepdist[2] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight), GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))+10
            set unitdist[2] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))
            set stepdist[3] = CustomFunctions_Distance(GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight), GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))+10
            set unitdist[3] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))
            call BJDebugMsg("distances set (right)")
            if unitdist[1] < stepdist[1] and unitdist[2] > stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))
                call BJDebugMsg("unit issued order to attack to topright")
            elseif unitdist[2] < stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))
                call BJDebugMsg("unit issued order to attack to bottomright")
            elseif unitdist[2] < stepdist[2] and unitdist[3] < stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))
                call BJDebugMsg("unit issued order to attack to OCenter")
            endif
        elseif IsPlayerInForce(GetOwningPlayer(u), udg_Raiders_AIPlayers) == true then
            set stepdist[1] = CustomFunctions_Distance(GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress), GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))-10
            set unitdist[1] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))
            set stepdist[2] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight), GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))+10
            set unitdist[2] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))
            set stepdist[3] = CustomFunctions_Distance(GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight), GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))+10
            set unitdist[3] = CustomFunctions_Distance(uX, uY, GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))
            call BJDebugMsg("distances set (right)")
            if unitdist[1] < stepdist[1] and unitdist[2] > stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_BottomRight), GetRectCenterY(gg_rct_BottomRight))
                call BJDebugMsg("unit issued order to attack to bottomright")
            elseif unitdist[2] < stepdist[2] and unitdist[3] > stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_TopRight), GetRectCenterY(gg_rct_TopRight))
                call BJDebugMsg("unit issued order to attack to topright")
            elseif unitdist[2] < stepdist[2] and unitdist[3] < stepdist[3] then
                call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))
                call BJDebugMsg("unit issued order to attack to HCenter")
            endif
        endif
    elseif udg_AI_CurrentLane[int] == "center" then
        if IsPlayerInForce(GetOwningPlayer(u), udg_Defenders_AIPlayers) == true then
            call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_OFortress), GetRectCenterY(gg_rct_OFortress))
            call BJDebugMsg("unit ordered to attack to OBase")
        elseif IsPlayerInForce(GetOwningPlayer(u), udg_Raiders_AIPlayers) == true then
            call IssuePointOrder(u, "attack", GetRectCenterX(gg_rct_HFortress), GetRectCenterY(gg_rct_HFortress))
            call BJDebugMsg("unit ordered to attack to HBase")
        endif
    endif
    set u = null
endfunction

endscope

scope AIEasyLevel initializer init

private function GroupActions takes nothing returns nothing
    local unit u = GetEnumUnit()
    local string o = udg_AI_CurrentOrder[GetConvertedPlayerId(GetOwningPlayer(u))]
    if GetUnitCurrentOrder(u) == null and o != "retreat" then
        call AIEasyLevelFunctions_Roam(GetConvertedPlayerId(GetOwningPlayer(u)))
        call BJDebugMsg("roam function called...")
    endif
    set u = null
endfunction    

private function EasyActions takes nothing returns nothing
    call ForGroup(udg_AI_HeroGroup, function GroupActions)
endfunction

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    call TriggerRegisterTimerEventPeriodic(t, 1.00)
    call TriggerAddAction(t, function EasyActions)
endfunction

endscope


And sorry about being mean about your title, I didn't realise you weren't english :'(
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top