• 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] need Simple AI to atack players

Status
Not open for further replies.
Level 1
Joined
Apr 1, 2008
Messages
7
Hey guys... need some help...
all what i want is a Simple AI to kill players....

example.. 2 enemy creeps spawn @ corner... and they run to a random player and atack him...
i know how i can spawn creeps ect...
i want same AI like @ the survival maps.. like jurassicpark.. or aliven invasion.. ect...
What must i do for it? my enemys stay only arround... :sad:
can i use a human-Ki or something? and how do i load this for computer?

ps. i know im a noob :gg:
i still learning :razz:
 
Level 1
Joined
Apr 1, 2008
Messages
2
You can trigger it. Whenever a unit owned by your CPU player is trained/summoned/spawned issue it to attack-move a random point in playable map.
 
Level 3
Joined
Aug 24, 2007
Messages
77
Instead of attack-moving to a random point they generally are ordered to attack a player's unit. If your going for a Jurrasic Park type of attack then randomly spawn them across the map and give them the "Wander" ability which will make them walk around the map.
 
Level 1
Joined
Apr 1, 2008
Messages
7
Hmm that wander ability is not really usefull for my map....
my enemys spawn at a single point... and i want: Spawnt unit seek a random player and atack him... no specific point on map or location...

i need something like that:

Order "the spawnt enemy unit" to Atack Player1 or Player 2 or Player 3 ect.... and if player 1 is dead... atack a other random player.....

like Kodo-tag
 
Level 5
Joined
Oct 27, 2007
Messages
158
Hmm that wander ability is not really usefull for my map....
my enemys spawn at a single point... and i want: Spawnt unit seek a random player and atack him... no specific point on map or location...

i need something like that:

Order "the spawnt enemy unit" to Atack Player1 or Player 2 or Player 3 ect.... and if player 1 is dead... atack a other random player.....

like Kodo-tag


This can be done very simply with a create unit trigger and an AI script running for the AI player. Whenever a unit is created the AI can send it on a suicide mission on a random player. It's sort of like the Campaign demon gate mission in the Frozen Throne campaign, only not random in that case.

Whenever the map trigger creates a unit you can send an command to the AI script telling it to suicide the unit on a random player.
 
Level 5
Joined
Oct 27, 2007
Messages
158
höh?
Cant find a Deamon Gate mission :confused:

Act II: Curse of the Blood Elves

Chapter 5: Gates of the Abyss



JASS:
//==================================================================================================
//  $Id: h05xD.ai,v 1.26 2003/05/04 21:19:47 rpardo Exp $
//==================================================================================================
globals
    constant integer SET_SLOT       = 1
    constant integer TURN_ON        = 2
    constant integer TURN_OFF       = 3
    constant integer CAPT_X         = 4
    constant integer CAPT_Y         = 5

    constant integer FEL_GUARD      = 'nfgu'
    constant integer BLOODFIEND     = 'nfgb'
    constant integer FEL_BEAST      = 'npfl'
    constant integer ELDER_VOID     = 'nvde'
    constant integer GREATER_VOID   = 'nvdg'
    constant integer NETHER_DRAKE   = 'nndk'
    constant integer NETHER_HATCH   = 'nnht'
    constant integer OVERLORD       = 'nfov'
    constant integer SORCEROR       = 'ners' //lvl 3 abolish
    constant integer DIABOLIST      = 'nerd' //lvl 6 curse, firebolt, parasite
    constant integer FEL_RAVAGER    = 'npfm'
    constant integer ERE_WARLOCK    = 'nerw'
    constant integer NETHER_DRAGON  = 'nndr'
    constant integer TORMENTOR      = 'ndqv'
    constant integer TEMPTRESS      = 'ndqt'
    constant integer MAIDEN         = 'ndqp'
    constant integer QUEEN          = 'ndqs'

    constant integer ILLIDAN_SLOT   = 11

    integer slot                    = 0
    boolean gate_open               = false
    boolean suicide_off             = true

    integer array suicide_list
    integer next_suicide            = 0
    integer next_declare            = 0
endglobals

//--------------------------------------------------------------------------------------------------
//  suicide_next
//--------------------------------------------------------------------------------------------------
function suicide_next takes nothing returns nothing
    local integer unitid

    if suicide_off then
        if gate_open then
            set suicide_off = false
        else
            return
        endif
    endif

    set unitid = suicide_list[next_suicide]
    if unitid == -1 then
        set unitid = suicide_list[0]
        set next_suicide = 0
    endif

    call SuicideUnitEx(3,unitid,ILLIDAN_SLOT)
    set next_suicide = next_suicide + 1
endfunction

//--------------------------------------------------------------------------------------------------
//  declare_unit
//--------------------------------------------------------------------------------------------------
function declare_unit takes integer unitid returns nothing
    set suicide_list[next_declare] = unitid
    set next_declare = next_declare + 1
    set suicide_list[next_declare] = -1
endfunction

//--------------------------------------------------------------------------------------------------
//  command_loop
//--------------------------------------------------------------------------------------------------
function command_loop takes nothing returns nothing

    local integer x = -1
    local integer y = -1

    local integer cmd
    local integer data
    loop
        loop
            call suicide_next()
            call Sleep(0.1)
            exitwhen CommandsWaiting() > 0
        endloop
        set cmd  = GetLastCommand()
        set data = GetLastData()
        call PopLastCommand()

        //------------------------------------------------------------------------------------------
        if cmd == SET_SLOT then
        //------------------------------------------------------------------------------------------
            set slot = data

        //------------------------------------------------------------------------------------------
        elseif cmd == TURN_ON then
        //------------------------------------------------------------------------------------------
            set gate_open = true

        //------------------------------------------------------------------------------------------
        elseif cmd == TURN_OFF then
        //------------------------------------------------------------------------------------------
            set gate_open = false

        //------------------------------------------------------------------------------------------
        elseif cmd == CAPT_X then
        //------------------------------------------------------------------------------------------
            set x = data

        //------------------------------------------------------------------------------------------
        elseif cmd == CAPT_Y then
        //------------------------------------------------------------------------------------------
            set y = data
        endif

        //------------------------------------------------------------------------------------------
        if (cmd == CAPT_X or cmd == CAPT_Y) and (x != -1 and y != -1) then
            call SetCaptainHome(BOTH_CAPTAINS,x,y)
        endif
    endloop
endfunction

//--------------------------------------------------------------------------------------------------
//  send_one
//--------------------------------------------------------------------------------------------------
function send_one takes integer unitid, integer seconds returns nothing
    call SetProduce(1,unitid,-1)
    call Sleep(seconds)
endfunction

//--------------------------------------------------------------------------------------------------
//  send
//--------------------------------------------------------------------------------------------------
function send takes integer unitid, integer seconds returns nothing
    if gate_open then
        call send_one(unitid,seconds)
    endif
endfunction

//--------------------------------------------------------------------------------------------------
//  send_group
//--------------------------------------------------------------------------------------------------
function send_group takes integer qty, integer unitid returns nothing
    if gate_open then
        loop
            exitwhen qty <= 0
            set qty = qty - 1
            call send_one(unitid,2)
        endloop
    endif
endfunction

//--------------------------------------------------------------------------------------------------
//  send_sleep
//--------------------------------------------------------------------------------------------------
function send_sleep takes integer seconds returns nothing
    if gate_open then
        call Sleep(seconds)
    endif
endfunction


//**************************************************************************************************
//***  NORMAL GATES ***
//**************************************************************************************************
//--------------------------------------------------------------------------------------------------
//  gate1_normal
//--------------------------------------------------------------------------------------------------
function gate1_normal takes nothing returns nothing
    call send_sleep(15)                   // 3:00
    call send_group( 4, FEL_BEAST       ) // 2:45
    call send_group( 3, FELLHOUND       ) // 2:37

    call send_sleep(15)                   // 2:31
    call send_group( 6, FEL_GUARD       ) // 2:16
    call send_group( 1, DIABOLIST       ) // 2:04
    call send_group( 4, BLOODFIEND      ) // 2:02

    call send_sleep(20)                   // 1:54

    call send_group( 6, FEL_BEAST       ) // 1:34
    call send_group( 1, GREATER_VOID    ) // 1:22
    call send_group( 4, FELLHOUND       ) // 1:20

    call send_sleep(20)                   // 1:12

    call send_group( 5, FEL_GUARD       ) // 0:52
    call send_group( 3, BLOODFIEND      ) // 0:42
    call send_group( 1, OVERLORD        ) // 0:36
    call send_group( 3, BLOODFIEND      ) // 0:34
    call send_group( 1, DOOMGUARD       ) // 0:28
    call send_group( 4, FEL_BEAST       ) // 0:26
    call send_group( 1, ELDER_VOID      ) // 0:18
    call send_group( 7, FEL_BEAST       ) // 0:16

endfunction

//--------------------------------------------------------------------------------------------------
//  gate2_normal
//--------------------------------------------------------------------------------------------------
function gate2_normal takes nothing returns nothing
    call send_sleep(5)                   // 3:00
    call send_group( 4, NETHER_HATCH    ) // 2:55

    call send_sleep(20)                   // 2:47

    call send_group( 6, FEL_BEAST       ) // 2:27
    call send_group( 3, FELLHOUND       ) // 2:15

    call send_sleep(20)                   // 2:09

    call send_group( 3, NETHER_HATCH    ) // 1:49
    call send_group( 1, GREATER_VOID    ) // 1:43
    call send_group( 3, NETHER_HATCH    ) // 1:41
    call send_group( 1, NETHER_DRAKE    ) // 1:35

    call send_sleep(20)                   // 1:33

    call send_group( 5, FEL_BEAST       ) // 1:13
    call send_group( 3, FELLHOUND       ) // 1:03
    call send_group( 1, FEL_RAVAGER     ) // 0:57
    call send_group( 1, DIABOLIST       ) // 0:55

    call send_sleep(20)                   // 0:53

    call send_group( 4, NETHER_HATCH    ) // 0:33
    call send_group( 2, GREATER_VOID    ) // 0:25
    call send_group( 3, NETHER_DRAKE    ) // 0:21

    call send_sleep(5)                   // 0:15
    call send_group( 1, INFERNAL        ) // 0:10
    call send_group( 1, ELDER_VOID      ) // 0:08
    call send_group( 1, INFERNAL        ) // 0:06

endfunction

//--------------------------------------------------------------------------------------------------
//  gate3_normal
//--------------------------------------------------------------------------------------------------
function gate3_normal takes nothing returns nothing
    call send_sleep(5)                   // 3:00
    call send_group( 6, TORMENTOR       ) // 2:55
    call send_group( 1, TEMPTRESS       ) // 2:43

    call send_sleep(20)                   // 2:41

    call send_group( 5, BLOODFIEND      ) // 2:21
    call send_group( 1, OVERLORD        ) // 2:11
    call send_group( 1, DIABOLIST       ) // 2:09

    call send_sleep(20)                   // 2:07

    call send_group( 5, TORMENTOR       ) // 1:47
    call send_group( 2, TEMPTRESS       ) // 1:37
    call send_group( 1, MAIDEN          ) // 1:33
    call send_group( 5, TORMENTOR       ) // 1:31
    call send_group( 1, QUEEN           ) // 1:21

    call send_sleep(20)                   // 1:19

    call send_group( 4, BLOODFIEND      ) // 0:59
    call send_group( 2, OVERLORD        ) // 0:51
    call send_group( 1, DOOMGUARD       ) // 0:47
    call send_group( 5, BLOODFIEND      ) // 0:45

    call send_sleep(10)                   // 0:35

    call send_group( 1, DOOMGUARD       ) // 0:25
    call send_group( 1, ERE_WARLOCK     ) // 0:23
    call send_group( 1, QUEEN           ) // 0:21
    call send_group( 8, TORMENTOR       ) // 0:19

endfunction

//--------------------------------------------------------------------------------------------------
//  gate4_normal
//--------------------------------------------------------------------------------------------------
function gate4_normal takes nothing returns nothing
    call send_sleep(5)                   // 3:00

    call send_group( 2, INFERNAL        ) // 2:55

    call send_sleep(5)                   // 2:51

    call send_group( 1, DOOMGUARD       ) // 2:46

    call send_sleep(15)                   // 2:44

    call send_group( 2, FEL_BEAST       ) // 2:29
    call send_group( 4, FELLHOUND       ) // 2:25
    call send_group( 1, FEL_RAVAGER     ) // 2:17
    call send_group( 1, QUEEN           ) // 2:15
    call send_group( 1, MAIDEN          ) // 2:13

    call send_sleep(20)                   // 2:11

    call send_group( 5, NETHER_DRAKE    ) // 1:51
    call send_group( 1, NETHER_DRAGON   ) // 1:41
    call send_group( 1, DOOMGUARD       ) // 1:39
    call send_group( 1, INFERNAL        ) // 1:37

    call send_sleep(20)                   // 1:35

    call send_group( 1, INFERNAL        ) // 1:15

    call send_sleep(10)                   // 1:13

    call send_group( 1, QUEEN           ) // 1:03

    call send_sleep(10)                   // 1:01

    call send_group( 1, DOOMGUARD       ) // 0:51

    call send_sleep(15)                   // 0:49

    call send_group( 5, FEL_BEAST       ) // 0:34
    call send_group( 2, FELLHOUND       ) // 0:24
    call send_group( 2, FEL_RAVAGER     ) // 0:20
    call send_group( 1, TEMPTRESS       ) // 0:16
    call send_group( 1, MAIDEN          ) // 0:14
    call send_group( 5, FEL_BEAST       ) // 0:12

endfunction


//**************************************************************************************************
//***  HARD GATES ***
//**************************************************************************************************
//--------------------------------------------------------------------------------------------------
//  gate1_hard
//--------------------------------------------------------------------------------------------------
function gate1_hard takes nothing returns nothing
    call send_sleep(10)                   // 3:00
    call send_group( 8, FEL_BEAST       ) // 2:50
    call send_group( 2, FELLHOUND       ) // 2:34
    call send_group( 2, GREATER_VOID    ) // 2:30

    call send_sleep(10)                   // 2:26
    call send_group( 6, FEL_GUARD       ) // 2:16
    call send_group( 6, BLOODFIEND      ) // 2:04
    call send_group( 2, DOOMGUARD       ) // 1:52

    call send_sleep(10)                   // 1:48
    call send_group( 8, FEL_BEAST       ) // 1:38
    call send_group( 4, FEL_RAVAGER     ) // 1:22
    call send_group( 2, GREATER_VOID    ) // 1:14
    call send_group( 2, ELDER_VOID      ) // 1:10

    call send_sleep(10)                   // 1:06
    call send_group( 2, DOOMGUARD       ) // 0:56
    call send_group( 5, BLOODFIEND      ) // 0:52
    call send_group( 5, FEL_GUARD       ) // 0:42
    call send_group( 2, OVERLORD        ) // 0:32
    call send_group( 2, DOOMGUARD       ) // 0:28
    call send_group( 5, BLOODFIEND      ) // 0:24
    call send_group( 1, OVERLORD        ) // 0:14
    call send_group( 2, DOOMGUARD       ) // 0:12
    call send_group( 3, FEL_GUARD       ) // 0:08

endfunction

//--------------------------------------------------------------------------------------------------
//  gate2_hard
//--------------------------------------------------------------------------------------------------
function gate2_hard takes nothing returns nothing
    call send_sleep(5)                   // 3:00
    call send_group( 4, NETHER_HATCH    ) // 2:55
    call send_group( 2, NETHER_DRAKE    ) // 2:47

    call send_sleep(5)                   // 2:43
    call send_group( 4, FELLHOUND       ) // 2:38
    call send_group( 6, FEL_BEAST       ) // 2:30
    call send_group( 3, FEL_RAVAGER     ) // 2:18
    call send_group( 2, DIABOLIST       ) // 2:12

    call send_sleep(5)                   // 2:08
    call send_group( 6, NETHER_DRAKE    ) // 2:03
    call send_group( 3, NETHER_HATCH    ) // 1:51
    call send_group( 3, GREATER_VOID    ) // 1:45
    call send_group( 3, NETHER_DRAKE    ) // 1:39
    call send_group( 3, ELDER_VOID      ) // 1:33

    call send_sleep(5)                   // 1:27
    call send_group( 5, FELLHOUND       ) // 1:22
    call send_group( 5, FEL_BEAST       ) // 1:12
    call send_group( 2, DIABOLIST       ) // 1:02
    call send_group( 2, FEL_RAVAGER     ) // 0:58
    call send_group( 3, ERE_WARLOCK     ) // 0:54

    call send_sleep(5)                   // 0:48
    call send_group( 4, ELDER_VOID      ) // 0:43
    call send_group( 3, INFERNAL        ) // 0:35
    call send_group( 3, NETHER_DRAKE    ) // 0:29

    call send_sleep(5)                   // 0:23
    call send_group( 1, DIABOLIST       ) // 0:18
    call send_group( 2, FEL_RAVAGER     ) // 0:16
    call send_group( 1, ERE_WARLOCK     ) // 0:12
    call send_group( 5, FELLHOUND       ) // 0:10


endfunction

//--------------------------------------------------------------------------------------------------
//  gate3_hard
//--------------------------------------------------------------------------------------------------
function gate3_hard takes nothing returns nothing
    call send_sleep(5)                   // 3:00
    call send_group( 6, TORMENTOR       ) // 2:55
    call send_group( 4, TEMPTRESS       ) // 2:43
    call send_group( 3, MAIDEN          ) // 2:35
    call send_group( 2, QUEEN           ) // 2:29

    call send_sleep(5)                   // 2:25
    call send_group( 3, BLOODFIEND      ) // 2:20
    call send_group( 2, OVERLORD        ) // 2:14
    call send_group( 1, DIABOLIST       ) // 2:10
    call send_group( 3, BLOODFIEND      ) // 2:08
    call send_group( 3, OVERLORD        ) // 2:02
    call send_group( 2, ERE_WARLOCK     ) // 1:56
    call send_group( 3, BLOODFIEND      ) // 1:52
    call send_group( 3, OVERLORD        ) // 1:46
    call send_group( 2, DOOMGUARD       ) // 1:40

    call send_sleep(5)                   // 1:36
    call send_group( 2, QUEEN           ) // 1:31
    call send_group( 6, TORMENTOR       ) // 1:27
    call send_group( 4, TEMPTRESS       ) // 1:15
    call send_group( 3, MAIDEN          ) // 1:07
    call send_group( 3, QUEEN           ) // 1:01

    call send_sleep(5)                   // 0:55
    call send_group( 4, BLOODFIEND      ) // 0:50
    call send_group( 3, DOOMGUARD       ) // 0:42
    call send_group( 2, ERE_WARLOCK     ) // 0:36
    call send_group( 3, QUEEN           ) // 0:32
    call send_group( 8, TORMENTOR       ) // 0:26
    call send_group( 3, TEMPTRESS       ) // 0:10


endfunction

//--------------------------------------------------------------------------------------------------
//  gate4_hard
//--------------------------------------------------------------------------------------------------
function gate4_hard takes nothing returns nothing
    call send_sleep(2)                   // 3:00
    call send_group( 4, INFERNAL        ) // 2:58

    call send_sleep(5)                   // 2:50
    call send_group( 3, DOOMGUARD       ) // 2:45

    call send_sleep(5)                   // 2:39
    call send_group( 2, FEL_BEAST       ) // 2:34
    call send_group( 5, FELLHOUND       ) // 2:30
    call send_group( 4, FEL_RAVAGER     ) // 2:20
    call send_group( 3, QUEEN           ) // 2:12
    call send_group( 2, MAIDEN          ) // 2:06

    call send_sleep(5)                   // 2:02
    call send_group( 5, NETHER_DRAKE    ) // 1:57
    call send_group( 3, NETHER_DRAGON   ) // 1:47
    call send_group( 2, DOOMGUARD       ) // 1:41
    call send_group( 2, INFERNAL        ) // 1:37
    call send_group( 2, NETHER_DRAKE    ) // 1:33

    call send_sleep(8)                   // 1:29
    call send_group( 2, FEL_BEAST       ) // 1:21
    call send_group( 4, FELLHOUND       ) // 1:17
    call send_group( 4, FEL_RAVAGER     ) // 1:09
    call send_group( 2, TEMPTRESS       ) // 1:01
    call send_group( 3, QUEEN           ) // 0:57
    call send_group( 3, FEL_RAVAGER     ) // 0:51

    call send_sleep(5)                   // 0:45
    call send_group( 4, INFERNAL        ) // 0:40
    call send_group( 3, DOOMGUARD       ) // 0:32
    call send_group( 5, INFERNAL        ) // 0:26
    call send_group( 3, QUEEN           ) // 0:16
    call send_group( 5, INFERNAL        ) // 0:10

endfunction
//**************************************************************************************************


//--------------------------------------------------------------------------------------------------
//  main
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing

    call CampaignAI(BURROW,null)
    call SetReplacements(0,0,0)

    call declare_unit( FEL_GUARD        )
    call declare_unit( BLOODFIEND       )
    call declare_unit( FEL_BEAST        )
    call declare_unit( ELDER_VOID       )
    call declare_unit( GREATER_VOID     )
    call declare_unit( NETHER_DRAKE     )
    call declare_unit( NETHER_HATCH     )
    call declare_unit( OVERLORD         )
    call declare_unit( SORCEROR         )
    call declare_unit( DIABOLIST        )
    call declare_unit( FEL_RAVAGER      )
    call declare_unit( ERE_WARLOCK      )
    call declare_unit( NETHER_DRAGON    )
    call declare_unit( TORMENTOR        )
    call declare_unit( TEMPTRESS        )
    call declare_unit( MAIDEN           )
    call declare_unit( QUEEN            )
    call declare_unit( INFERNAL         )
    call declare_unit( DOOMGUARD        )
    call declare_unit( FELLHOUND        )

    call StartThread(function command_loop)

    loop
        loop
            exitwhen gate_open
            call Sleep(0.5)
        endloop

        if difficulty == HARD then
            if slot == 1 then
                call gate1_hard()
            elseif slot == 2 then
                call gate2_hard()
            elseif slot == 3 then
                call gate3_hard()
            elseif slot == 4 then
                call gate4_hard()
            endif
        else
            if slot == 1 then
                call gate1_normal()
            elseif slot == 2 then
                call gate2_normal()
            elseif slot == 3 then
                call gate3_normal()
            elseif slot == 4 then
                call gate4_normal()
            endif
        endif

        loop
            exitwhen not gate_open
            call Sleep(0.5)
        endloop
    endloop
endfunction
 
Level 5
Joined
Oct 27, 2007
Messages
158
humm... i undestand nothing how that crap work :eekani:


First of all.... this is not crap.
It may seems jibberish now, but it doesn't take that much time to learn a thing or two about Jass. With basic Jass knowledge you can do the thing you want with your map. I have told you a way to do it...

  1. Have triggers ready that spawn the units.
  2. Use the Command AI function to send the unit id and amount to the CPU.
  3. Have the AI script setup to process commands.
  4. Have the AI suicide the just created units on a random player.
I have done this myself already with summoned/possessed units through the combined use of map triggers and an AI script. I know for a fact that this is one of the better solutions.
 
Level 1
Joined
Apr 1, 2008
Messages
7
humm... do i need the JASS knowlege? i dont like it :gg:
the standart wc3 editor style looks much easyer for noobys @ mapping...
hmm... can you send me this ähhmm.. "SIMPLE" methode @ a map? so i can learning by doing :razz:
and i see it how it works.
 
Status
Not open for further replies.
Top