• 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] attack player according to command

Status
Not open for further replies.

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
I am trying to have this ai attack players according to the command sent by trigger.

is it possible to change the player target in

call SuicideOnPlayerEx(M1,M1,M1,victim)

in the manner below? using if else

JASS:
function get_commands takes nothing returns nothing
    //local integer cmd
    local integer data
    loop
        loop
            exitwhen CommandsWaiting() != 0
            call Sleep(1)
        endloop

        //set cmd  = GetLastCommand()
        set data = GetLastData()
        call PopLastCommand()
        
        if data == 1 then
		set victim = target
		
		elseif data == 2 then
		set victim = target2
			
		elseif data == 3 then
		set victim = target3
				
				
					
			
		
		endif
		
    endloop
endfunction

well apparently the function SuicideOnPlayerEx cannot take integer arguments.... so how do I correct this?
 
JASS:
function main takes nothing returns nothing
    local integer cmd
    local integer nr = 0
    call CampaignAI(NAGA_CORAL,null)

    set campaign_gold_peons = 0
    set campaign_wood_peons = 0
   
    //call SetCaptainHome(BOTH_CAPTAINS,2624,-6496)
    // here you must send a signal for ai to continue 
    set cmd = WaitForSignal()
    if cmd==1 then
        call DisplayTextToPlayer(Player(0), 0, 0, "Reciving command 1")
        set nr = 0
    elseif cmd==2 then
        call DisplayTextToPlayer(Player(0), 0, 0, "Reciving command 2")
        set nr = 1
    endif     
    call SuicideOnPlayerEx(M1,M1,M1,Player(nr)) 
//will attack player red if command=1
// or player blue if command=2

in gui:
  • AI - Send Player 3 (Teal) the AI Command (1, 0)
  • or
    • AI - Send Player 3 (Teal) the AI Command (2, 0)
only 1st parameter works for me, if you have experience with this let us know
 

zzc

zzc

Level 3
Joined
Apr 25, 2016
Messages
20
access violation?

trying it out.

will too many scripts give access violation errors?
 
Last edited:
Status
Not open for further replies.
Top