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

[Crash] Map seems to crash when the AI trains a certain unit?

Status
Not open for further replies.
Level 26
Joined
Nov 5, 2010
Messages
1,383
I've been having an odd crash on one map I'm working on. At some point I quicksaved some 20 seconds before it crashed, and multiple times when I loaded it would crash at the same time, and I figured out it happens when the orc AI trains a shaman unit. Weird thing is, if I kill a shaman unit it already has, it will train the next one fine and the map won't crash, but then the next shaman will crash the map. It would also crash if I destroyed the building while it was training the shaman that crashes the map.

However, when I replayed the map normally from the beginning, it did not crash, even when I used the warpten cheat. It only seems to crash a few minutes into the game. I am not sure then if this is even specific to the shaman unit.

I've attached the error log, if it might be of any help.
 

Attachments

  • Crash.txt
    29.1 KB · Views: 48
Level 12
Joined
Jun 15, 2016
Messages
472
Does this happen only when the unit is trained by an AI player? Perhaps trying one of the following will help:

1. Is the trained unit a 'vanilla' shaman? If not, try replacing it with a vanilla shaman and see if the problem persists.
2. You say if

Weird thing is, if I kill a shaman unit it already has, it will train the next one fine and the map won't crash, but then the next shaman will crash the map.

Could the crash be related to the number of shamans in the map?
3. Try giving the training order manually, with the AI disabled and without it. Can be done with this trigger:
  • Unit - Order (Last created unit) to train/upgrade to a Footman
4. Last thing I can think of, also because of what you said above: does the AI assign the shaman which crashes the game to a different role? Let's say attack group instead of defense group, guard post, etc...
 
Level 26
Joined
Nov 5, 2010
Messages
1,383
Yeah, it only happens when the AI trains the unit (or if the structure training that unit dies), the player controls only heroes in this map. The AI also uses no custom units in this map, they are all vanilla units. I tried replacing the shaman with the warlock unit, but then the map crashed at some point when a tauren unit got trained. However, every time it crashed, it specifically happened because of the red player AI.

I tried taking control of the AI and killing and training units and it didn't crash. I tried using cheats to murder all of its units then letting them train again, and it didn't crash. I tried letting other AIs murder almost all of its units, then helping the red AI train them all again, but it didn't crash either. I tried importing custom object data to the AI, even though it uses no custom units, and this time I played the map as intended and this it crashed at some point. I honestly have no idea... it just feels random when it happens.

4. Last thing I can think of, also because of what you said above: does the AI assign the shaman which crashes the game to a different role? Let's say attack group instead of defense group, guard post, etc...

This sounds possible to me, but this AI specifically has no attack groups because it's a defense map.
 
Level 26
Joined
Nov 5, 2010
Messages
1,383
Okay, this is the AI I'm using. Sorry I had to post it as .rar, couldn't upload the file itself. If there are no issues with this, could the AI maybe have a problem with pathing or something like that? I'm wondering since it has a base in a bit of an odd place, it's split with a river with a bridge, and it's not too open of a space.
 

Attachments

  • CotFChapterFiveRed.rar
    420 bytes · Views: 29
Level 12
Joined
Jun 15, 2016
Messages
472
Okay, this is the AI I'm using. Sorry I had to post it as .rar, couldn't upload the file itself. If there are no issues with this, could the AI maybe have a problem with pathing or something like that? I'm wondering since it has a base in a bit of an odd place, it's split with a river with a bridge, and it's not too open of a space.

It's possible, I never tested that sort of thing but the AI has never been good at base building in tight spaces, choosing odd locations for it's buildings. (Also the current script you sent me uses warlocks)

However, now that I see that your script is made with the AI editor, which IIRC might cause some problems, seeing as in the current script you have no attack group, and your AI is instructed to attack enemy towns and expansions without any conditions. I do not know if this is the problem as I don't know much about the AI editor, but perhaps creating attack and defense groups (while keeping them empty), as well as setting the conditions to all targets as something that always amounts to false (True Equals False should do the trick).

If that does not work, might I suggest you try moving on to custom scripts? catering to all your AI needs :grin:

I made this script, which should work as a replacement (few functionalities so it wasn't complicated):


JASS:
//=================================================================================================
// GLOBAL VARIABLES
//=================================================================================================

globals
    integer GoldWorkers = 5
    integer WoodWorkers = 2
    player  Dbg_plr  = Player(0)
endglobals

//=================================================================================================
// BUILDINGS PRIORITIES & AI SETTINGS
//=================================================================================================

function InitOptions takes nothing returns nothing
    call SetMeleeAI(  )
    call SetDefendPlayer( true )
    call SetRandomPaths( false )
    call SetTargetHeroes( false )
    call SetPeonsRepair( true )
    call SetHeroesFlee( false )
    call SetHeroesBuyItems( true )
    call SetUnitsFlee( true )
    call SetGroupsFlee( false )
    call SetWatchMegaTargets( true )
    call SetIgnoreInjured( true )
    call SetHeroesTakeItems( true )
    call SetSlowChopping( true )
    call SetCaptainChanges( false )
    call SetSmartArtillery( true )
endfunction

function BuildPriorities takes nothing returns nothing
    call SetBuildAll( BUILD_UNIT, 1, 'ogre', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 6, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 7, 'opeo', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'obar', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'npgf', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'oalt', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ofor', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ovln', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'npgf', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ostr', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'osld', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'nw2w', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'obea', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ohun', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 4, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 6, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'nw2w', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ofrt', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'ocat', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'orai', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 7, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'odoc', -1 )
    call SetBuildAll( BUILD_UNIT, 5, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'npgf', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'owyv', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'nw2w', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'orai', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'ohun', -1 )
    call SetBuildAll( BUILD_UNIT, 6, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'otto', -1 )
    call SetBuildAll( BUILD_UNIT, 1, 'otau', -1 )
    call SetBuildAll( BUILD_UNIT, 6, 'otrb', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'odoc', -1 )
    call SetBuildAll( BUILD_UNIT, 8, 'owtw', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'owyv', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'ohun', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'orai', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'ocat', -1 )
    call SetBuildAll( BUILD_UNIT, 7, 'ogru', -1 )
    call SetBuildAll( BUILD_UNIT, 2, 'otau', -1 )
    call SetBuildAll( BUILD_UNIT, 3, 'owyv', -1 )
endfunction

//=================================================================================================
// UTILITY FUNCTIONS
//=================================================================================================

function OneHarvestLoop takes nothing returns nothing
    call ClearHarvestAI()

    call HarvestGold(0,GoldWorkers)
    call HarvestWood(0,WoodWorkers)
endfunction

function GuardUpdate takes nothing returns nothing
    call FillGuardPosts()
    call ReturnGuardPosts()
endfunction

function StartHarvestLoop takes nothing returns nothing
    call OneHarvestLoop()
    call GuardUpdate()
    call StaggerSleep(1,2)
    loop
        call OneHarvestLoop()
        call GuardUpdate()
        call Sleep(2)
    endloop
endfunction

//=================================================================================================
// MAIN FUNCTION
//=================================================================================================

function main takes nothing returns nothing
    // call DisplayTextToPlayer(Dbg_plr,0,0,"Script received")
    call InitAI()
   
   
    call InitOptions()
    call BuildPriorities()
   
    //call DisplayTextToPlayer(Dbg_plr,0,0,"AI priorities set")
    call StartThread(function StartHarvestLoop)
    call PlayGame()
endfunction


I tested it only in a normal melee map so I know it works, but I don't know if it will cause the same crash.
 
Level 26
Joined
Nov 5, 2010
Messages
1,383
Well, I've never had any issues with the AI editor in all these years I've been making maps, but I will check out custom scripts.

But I think I might have been wrong all along. I ruled out triggers causing issues because I thought it was an AI training issue, but I decided to test it now nevertheless. This map has side quests that will turn on waygates and additional AIs if you complete them. I tried enabling these AI without the waygates, and the map went on with no issues. As soon as I enabled the waygates, the map crashed within 30 seconds or so. I had a quicksave right before the moment you could trigger the waygates, so I had the hero just stand before that location for two minutes and the map did not crash. Then I had the hero trigger the waygates, and the map crashed. I also tried by not waiting and triggering them immediately, and then it also crashed.

So, it appears these waygates were causing issues, and I did not even realise. Still, thank you for taking the time to help me out! Hopefully, it really was the waygates causing issues, it certainly seems that way now.
 
Status
Not open for further replies.
Top