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

[AI] AI Malfunction

Status
Not open for further replies.
Level 24
Joined
May 15, 2013
Messages
3,782
Dear HIvers

I need help on a certain AI,

JASS:
//==================================================================================================
globals
    player user = Player(2)

    constant integer A_THUG         = 'h60G' // Thug
    constant integer A_ROGUE        = 'n600' // Rogue
    constant integer A_ASSASSIN     = 'n601' // Assassin
    constant integer A_WIZARD       = 'h600' // Wizard
    constant integer A_SHADOWPRIEST = 'n602' // Shadowpriest
    constant integer A_TENT         = 'h60A' // Tent
endglobals

//--------------------------------------------------------------------------------------------------
//  main
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing
    call CampaignAI(HOUSE,null)
    call SetReplacements(1,1,2)
    call SetSlowChopping(true)
    set campaign_wood_peons = 3

    call SetBuildUnitEx ( 7,7,7, A_THUG             )

    call CampaignDefenderEx( 2,2,2, A_ROGUE         )
    call CampaignDefenderEx( 1,1,2, A_ASSASSIN      )
    call CampaignDefenderEx( 0,1,1, A_WIZARD        )
    call CampaignDefenderEx( 0,0,2, A_SHADOWPRIEST  )

    call SetBuildUpgrEx( 0,1,1, UPG_ORC_ARMOR       )   
    call SetBuildUpgrEx( 0,1,1, UPG_ORC_MELEE       )
    call SetBuildUpgrEx( 0,1,1, UPG_ORC_RANGED      )
    call SetBuildUpgrEx( 0,0,1, UPG_ORC_VENOM       )

    call WaitForSignal()

    //*** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,3, A_ROGUE         )
    call CampaignAttackerEx( 2,2,2, A_ASSASSIN      )
    call SuicideOnPlayerEx(M3,M3,M3,user)

    loop
        //*** WAVE 2+ ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 2,2,3, A_ROGUE         )
        call CampaignAttackerEx( 1,1,2, A_ASSASSIN      )
        call CampaignAttackerEx( 1,1,1, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 2,2,3, A_ROGUE         )
        call CampaignAttackerEx( 1,1,2, A_SHADOWPRIEST  )
        call CampaignAttackerEx( 2,2,2, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 3,3,3, A_ASSASSIN      )
        call CampaignAttackerEx( 2,2,2, A_ROGUE         )
        call CampaignAttackerEx( 0,1,2, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)
    endloop
endfunction
//==================================================================================================

This AI was based on HumanEX Campaign 06, Orange Chaos Orcs. I've made edits to make it fit for my map,
problems is, it doesn't work. Well, not in the text itself I guess, let me explain:

The AI is turned on after an Intro Cinematic, by a Gameplay trigger which is run by an Intro Cleanup

-----

  • Alterac AI
    • Events
    • Conditions
    • Actions
      • AI - Start campaign AI script for P_ConfederacyOrange: KaWx1 Orange.ai
-----

The AI remains passive for a while, it will train and build defenders, but this part doesn't work. On the other hand, if the player user attacks its units, then a command is sent to the AI to be aggressive, and it will attack, sadly, it doesn't work as well, propably.

-----

  • Alterac Base Orange
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Owner of (Attacked unit)) Equal to P_ConfederacyOrange
      • (Owner of (Attacking unit)) Equal to P_PlayerBlue
      • GameOver Equal to False
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- Start AI --------
      • Trigger - Run Orange AI Command <gen> (checking conditions)
  • Orange AI Command
    • Events
    • Conditions
    • Actions
      • -------- Send Command --------
      • AI - Send P_ConfederacyOrange the AI Command (0, 0)
-----

Now this wierd thing happens, once I attacked the AI, I let it survive. Then I go on to an Optional Cine,
then after that, I checked the AI player, it was training units and replacing those who died, it also trains
a Thug, but only one (See the AI, it was suppose to train 7).
I checked the Cinematic triggers, but I don't see anything that relates to the AI, not Pause All Units, not Hides, nor any other.
What is happening to this AI? Is it from the map or from itself?

Also, since I'm a little sucky on AI's, I need someone to make AI's for me, or check my p... and
find triggers or functions relating to AI's and fix it as well as my own-made or edited AI. If anyone's interested, PM me.

- Edge45
 
Level 28
Joined
Feb 18, 2014
Messages
3,576
Wait is it a map or a campaign? I see you have made " AI : Start Campaign AI script " above, which is used for campaign btw, use instead " AI : Start Map AI " for a map, also make sure everything works normal in the AI functions,
 
Level 18
Joined
Nov 21, 2012
Messages
835
Tell AI what is your "farm" (food providing) building first.
If it is A_TENT, (already defined) then use this line:
JASS:
     call CampaignAI(A_TENT,null)
instead of this:
JASS:
    call CampaignAI(HOUSE,null)
HOUSE is a constant 'hhou' which is regular human farm.:D

If your units cost food you must order AI to build farms *before* train units:
JASS:
    call SetBuildUnitEx( 6, 6, 6, A_TENT )

moreover SetReplacements means how many times preplaced units will be replaced

zibi
 
Level 24
Joined
May 15, 2013
Messages
3,782
Bumping this thread, gonna try to tackle it once again. NEED HELP

JASS:
//==================================================================================================
globals
    player user = Player(2)

    constant integer A_THUG         = 'h60G' // Thug
    constant integer A_ROGUE        = 'n600' // Rogue
    constant integer A_ASSASSIN     = 'n601' // Assassin
    constant integer A_WIZARD       = 'h600' // Wizard
    constant integer A_SHADOWPRIEST = 'n602' // Shadowpriest
    constant integer A_TENT         = 'h60A' // Tent
endglobals

//--------------------------------------------------------------------------------------------------
//  main
//--------------------------------------------------------------------------------------------------
function main takes nothing returns nothing
    call CampaignAI(A_TENT,null)
    call SetReplacements(1,1,2)
    call SetSlowChopping(true)
    set campaign_wood_peons = 3

    call SetBuildUnitEx ( 7,7,7, A_THUG             )

    call CampaignDefenderEx( 2,2,2, A_ROGUE         )
    call CampaignDefenderEx( 1,1,2, A_ASSASSIN      )
    call CampaignDefenderEx( 0,1,1, A_WIZARD        )
    call CampaignDefenderEx( 0,0,2, A_SHADOWPRIEST  )

    call SetBuildUpgrEx( 0,1,1, UPG_ORC_ARMOR       )   
    call SetBuildUpgrEx( 0,1,1, UPG_ORC_MELEE       )
    call SetBuildUpgrEx( 0,1,1, UPG_ORC_RANGED      )
    call SetBuildUpgrEx( 0,0,1, UPG_ORC_VENOM       )

    call WaitForSignal()

    //*** WAVE 1 ***
    call InitAssaultGroup()
    call CampaignAttackerEx( 2,2,3, A_ROGUE         )
    call CampaignAttackerEx( 2,2,2, A_ASSASSIN      )
    call SuicideOnPlayerEx(M3,M3,M3,user)

    loop
        //*** WAVE 2+ ***
        call InitAssaultGroup()
        call CampaignAttackerEx( 2,2,3, A_ROGUE         )
        call CampaignAttackerEx( 1,1,2, A_ASSASSIN      )
        call CampaignAttackerEx( 1,1,1, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 2,2,3, A_ROGUE         )
        call CampaignAttackerEx( 1,1,2, A_SHADOWPRIEST  )
        call CampaignAttackerEx( 2,2,2, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)

        call InitAssaultGroup()
        call CampaignAttackerEx( 3,3,3, A_ASSASSIN      )
        call CampaignAttackerEx( 2,2,2, A_ROGUE         )
        call CampaignAttackerEx( 0,1,2, A_WIZARD        )
        call SuicideOnPlayerEx(M5,M5,M4,user)
    endloop
endfunction
//==================================================================================================
 
Which part it breaks?

Make sure resources and food are sufficient for AI to execute commands.
Also, you need to send a
  • AI - Send Command
or sort of that to make the attacking part runs, since it will wait for signal first (ori AI uses this to allow AI to run but don't attack with certain wave too early (ex. Undead08 Rush)

Or try delete the call WaitForSignal and report back the result.
 
Status
Not open for further replies.
Top