Skip to content

Commit 98bfd66

Browse files
committed
Bug fixes and AI tracing, 3.26
1 parent 66dda64 commit 98bfd66

File tree

15 files changed

+38117
-43218
lines changed

15 files changed

+38117
-43218
lines changed

wowr.w3x/scripts/common.ai

Lines changed: 87 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,15 +2502,18 @@ endfunction
25022502
//===========================================================================
25032503
function AttackTarget takes unit target, boolean addAlliance returns nothing
25042504
if (target == null) then
2505+
call Trace("Attack target but have nothing\n")
25052506
return
25062507
endif
25072508
if (addAlliance) then
2508-
call SetAllianceTarget( target )
2509+
call Trace("Attack target with alliance target\n")
2510+
call SetAllianceTarget(target)
25092511
endif
2510-
call FormGroup( 3, true )
2511-
call AttackMoveKillA( target )
2512+
call Trace("Attack target form a group and move to kill\n")
2513+
call FormGroup(3, true)
2514+
call AttackMoveKillA(target)
25122515
if (not addAlliance) then
2513-
call SetAllianceTarget( null )
2516+
call SetAllianceTarget(null)
25142517
endif
25152518
endfunction
25162519

@@ -2521,75 +2524,89 @@ function LaunchAttack takes nothing returns nothing
25212524
local unit target = null
25222525
local boolean setAlly = true
25232526

2527+
call Trace("Launch attack\n")
2528+
25242529
if (disabled) then
2530+
call Trace("Launch attack cancel since disabled\n")
25252531
return
25262532
endif
25272533

25282534
// Don't launch any attack while town is threatened
25292535
if (TownThreatened()) then
2536+
call Trace("Launch attack cancel since town is threatened\n")
25302537
call Sleep( 2 )
25312538
return
25322539
endif
25332540

25342541
if (attackTargetLocation) then
2542+
call TraceII("Launch attack (%d|%d)\n", attackTargetLocationX, attackTargetLocationY)
25352543
call AttackMoveXYA(attackTargetLocationX, attackTargetLocationY)
25362544
elseif (attackEnemyPlayers) then
2545+
call Trace("Launch attack enemy player\n")
25372546
// Target Priority #1
25382547
if (target == null) then
25392548
set target = GetAllianceTarget()
2549+
call Trace("Launch attack alliance target\n")
25402550
if (target != null) then
2551+
call Trace("Launch attack alliance target found\n")
25412552
set setAlly = false
25422553
endif
25432554
endif
25442555

25452556
// Target Priority #2
25462557
if (target == null) then
25472558
set target = GetExpansionFoe()
2559+
call Trace("Launch attack expansion foe\n")
25482560
if (target != null) then
2561+
call Trace("Launch attack expansion foe found\n")
25492562
set take_exp = false
25502563
endif
25512564
endif
25522565

25532566
// Target Priority #3
25542567
if (target == null) then
2568+
call Trace("Launch attack mega target\n")
25552569
set target = GetMegaTarget()
25562570
endif
25572571

25582572
// Target Priority #4
25592573
if (target == null) then
2574+
call Trace("Launch attack enemy expansion\n")
25602575
set target = GetEnemyExpansion()
25612576
endif
25622577

25632578
// Target Priority #5
25642579
if (target == null) then
2565-
set target = GetEnemyExpansion()
2566-
if (target == null) then
2567-
call StartGetEnemyBase( )
2568-
loop
2569-
exitwhen (not WaitGetEnemyBase())
2570-
call SuicideSleep( 1 )
2571-
endloop
2572-
set target = GetEnemyBase()
2573-
endif
2580+
call Trace("Launch attack enemy base\n")
2581+
call StartGetEnemyBase()
2582+
loop
2583+
exitwhen (not WaitGetEnemyBase())
2584+
call SuicideSleep(1)
2585+
endloop
2586+
set target = GetEnemyBase()
25742587
endif
25752588
endif
25762589

25772590
// Target Priority #6
25782591
if (target == null) then
2579-
set target = GetCreepCamp( 0, 9, false )
2592+
call Trace("Launch attack creep camp small\n")
2593+
set target = GetCreepCamp(0, 9, false)
25802594
endif
25812595

25822596
// Target Priority #7
25832597
if (target == null) then
2584-
set target = GetCreepCamp( 10, 100, true )
2598+
call Trace("Launch attack creep camp big\n")
2599+
set target = GetCreepCamp(0, 75, true)
25852600
endif
25862601

25872602
// Attack the target and increment attack wave
25882603
if (target != null) then
2589-
call AttackTarget( target, setAlly )
2604+
call Trace("Attack\n")
2605+
call AttackTarget(target, setAlly)
25902606
else
2607+
call Trace("Wait for another attack try\n")
25912608
// If no target was found, sleep a bit before trying again
2592-
call Sleep( 20 )
2609+
call Sleep(20)
25932610
endif
25942611
endfunction
25952612

@@ -2666,6 +2683,7 @@ function UpdateWorkers takes nothing returns nothing
26662683
local integer c = 0
26672684
loop
26682685
if (not disabled) then
2686+
call Trace("Updating gold and wood peons\n")
26692687
call SetGoldPeons(5 + CountHousings() * 3)
26702688
call SetWoodPeons(5)
26712689
endif
@@ -2749,22 +2767,22 @@ function UpdateWorkers takes nothing returns nothing
27492767
endfunction
27502768

27512769
function ConfigureAI takes nothing returns nothing
2752-
call SetTargetHeroes( true )
2753-
call SetUnitsFlee( true )
2754-
call SetHeroesFlee( true )
2755-
call SetPeonsRepair( true )
2756-
call SetHeroesBuyItems( true )
2757-
call SetHeroesTakeItems( true )
2758-
call SetSlowChopping( false )
2759-
call SetWatchMegaTargets( true )
2760-
call SetIgnoreInjured( true )
2761-
call SetGroupsFlee( true )
2762-
call SetCaptainChanges ( false )
2763-
call SetSmartArtillery ( true )
2764-
call GroupTimedLife ( true )
2770+
call SetTargetHeroes(true)
2771+
call SetUnitsFlee(true)
2772+
call SetHeroesFlee(true)
2773+
call SetPeonsRepair(true)
2774+
call SetHeroesBuyItems(true)
2775+
call SetHeroesTakeItems(true)
2776+
call SetSlowChopping(false)
2777+
call SetWatchMegaTargets(true)
2778+
call SetIgnoreInjured(true)
2779+
call SetGroupsFlee(true)
2780+
call SetCaptainChanges(false)
2781+
call SetSmartArtillery(true)
2782+
call GroupTimedLife(true)
27652783
call SetAmphibious()
2766-
call SetRandomPaths( true )
2767-
call SetDefendPlayer( true )
2784+
call SetRandomPaths(true)
2785+
call SetDefendPlayer(true)
27682786
call SetReplacements(1, 2, 3)
27692787

27702788
set attackEnemyPlayers = difficulty == MELEE_INSANE
@@ -2773,66 +2791,75 @@ function ConfigureAI takes nothing returns nothing
27732791
endfunction
27742792

27752793
function BuildingStrategyStandardTier1 takes nothing returns nothing
2776-
call SetBuildUnit( 1, AI_LABORATORY )
2777-
call SetBuildUnit( 2, SHREDDER )
2794+
call SetBuildUnit(1, AI_LABORATORY)
2795+
call SetBuildUnit(2, SHREDDER)
27782796
endfunction
27792797

27802798
function ResearchHighLevelTier3Researches takes nothing returns nothing
27812799
local integer evolutionLevel = GetUpgradeLevel(UPG_EVOLUTION)
2800+
local integer improvedLevel = 0
27822801
if (evolutionLevel < MAX_WOWR_RESEARCH_LEVEL) then
27832802
set evolutionLevel = evolutionLevel + 1
27842803
endif
27852804

2805+
call TraceI("ResearchHighLevelTier3Researches with evolution level %d\n", evolutionLevel)
2806+
27862807
if (not disabled) then
27872808
if (evolutionLevel < MAX_WOWR_RESEARCH_LEVEL) then
2788-
call SetBuildUpgr( evolutionLevel, UPG_EVOLUTION )
2789-
call SetBuildUpgr( evolutionLevel / 10, UPG_IMPROVED_POWER_GENERATOR )
2790-
call SetBuildUpgr( evolutionLevel / 10, UPG_IMPROVED_MOUNT )
2791-
call SetBuildUpgr( evolutionLevel / 10, UPG_IMPROVED_NAVY )
2809+
set improvedLevel = evolutionLevel / 10
2810+
call SetBuildUpgr(evolutionLevel, UPG_EVOLUTION)
2811+
call SetBuildUpgr(improvedLevel, UPG_IMPROVED_POWER_GENERATOR)
2812+
call SetBuildUpgr(improvedLevel, UPG_IMPROVED_MOUNT)
2813+
call SetBuildUpgr(improvedLevel, UPG_IMPROVED_NAVY)
2814+
call TraceI("ResearchHighLevelTier3Researches with improved levell %d\n", improvedLevel)
27922815
else
2793-
call SetBuildUpgr( MAX_WOWR_RESEARCH_LEVEL, UPG_EVOLUTION )
2794-
call SetBuildUpgr( MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_POWER_GENERATOR )
2795-
call SetBuildUpgr( MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_MOUNT )
2796-
call SetBuildUpgr( MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_NAVY )
2816+
call Trace("ResearchHighLevelTier3Researches maximum levels\n")
2817+
call SetBuildUpgr(MAX_WOWR_RESEARCH_LEVEL, UPG_EVOLUTION)
2818+
call SetBuildUpgr(MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_POWER_GENERATOR)
2819+
call SetBuildUpgr(MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_MOUNT)
2820+
call SetBuildUpgr(MAX_WOWR_RESEARCH_LEVEL, UPG_IMPROVED_NAVY)
27972821
endif
27982822
endif
27992823
endfunction
28002824

28012825
function BuildingStrategyStandardTier3 takes nothing returns nothing
2802-
call SetBuildUnit( 1, POWER_GENERATOR )
2803-
call SetBuildUnit( 1, ANTIMAGIC_WARD )
2804-
call SetBuildUnit( 1, RESEARCH_TENT )
2805-
call SetBuildUnit( 1, MARKETPLACE )
2806-
call SetBuildUnit( 1, THIEVES_GUILD )
2807-
call SetBuildUpgr( 1, UPG_TEMPLE_OF_DEMIGODS_BLUEPRINTS )
2808-
call SetBuildUpgr( 1, UPG_STORM_PROTECTION)
2809-
call SetBuildUpgr( 1, UPG_DRAGON_ROOST )
2810-
call SetBuildUnit( 1, DRAGON_ROOST )
2826+
call SetBuildUnit(1, POWER_GENERATOR)
2827+
call SetBuildUnit(1, ANTIMAGIC_WARD)
2828+
call SetBuildUnit(1, RESEARCH_TENT)
2829+
call SetBuildUnit(1, MARKETPLACE)
2830+
call SetBuildUnit(1, THIEVES_GUILD)
2831+
call SetBuildUpgr(1, UPG_TEMPLE_OF_DEMIGODS_BLUEPRINTS)
2832+
call SetBuildUpgr(1, UPG_STORM_PROTECTION)
2833+
call SetBuildUpgr(1, UPG_DRAGON_ROOST)
2834+
call SetBuildUnit(1, DRAGON_ROOST)
28112835
endfunction
28122836

28132837
function BuildingStrategyStandardTier3Freelancer takes nothing returns nothing
2814-
//call SetBuildUnit( 1, POWER_GENERATOR )
2815-
//call SetBuildUnit( 1, ANTIMAGIC_WARD )
2816-
call SetBuildUnit( 1, RESEARCH_TENT )
2817-
//call SetBuildUnit( 1, MARKETPLACE )
2818-
//call SetBuildUnit( 1, THIEVES_GUILD )
2819-
call SetBuildUpgr( 1, UPG_TEMPLE_OF_DEMIGODS_BLUEPRINTS )
2820-
call SetBuildUpgr( 1, UPG_STORM_PROTECTION)
2821-
call SetBuildUpgr( 1, UPG_DRAGON_ROOST )
2822-
call SetBuildUnit( 1, DRAGON_ROOST )
2838+
//call SetBuildUnit(1, POWER_GENERATOR)
2839+
//call SetBuildUnit(1, ANTIMAGIC_WARD)
2840+
call SetBuildUnit(1, RESEARCH_TENT)
2841+
//call SetBuildUnit(1, MARKETPLACE)
2842+
//call SetBuildUnit(1, THIEVES_GUILD)
2843+
call SetBuildUpgr(1, UPG_TEMPLE_OF_DEMIGODS_BLUEPRINTS)
2844+
call SetBuildUpgr(1, UPG_STORM_PROTECTION)
2845+
call SetBuildUpgr(1, UPG_DRAGON_ROOST)
2846+
call SetBuildUnit(1, DRAGON_ROOST)
28232847
endfunction
28242848

28252849
function BasicExpansionIfRequired takes integer ex, integer unitid returns nothing
2850+
call TraceII("Building anothere expansion %d if required with mines owned %d\n", ex, GetMinesOwned())
28262851
call BasicExpansion(GetMinesOwned() < ex, unitid)
28272852
endfunction
28282853

28292854
function GetZeppelinsIfRequired takes nothing returns nothing
28302855
if GetUnitCount(ZEPPELIN) < zeppelins then
2856+
call TraceI("Getting another Zeppelin with zeppelins %d\n", zeppelins)
28312857
call GetZeppelin()
28322858
endif
28332859
endfunction
28342860

28352861
function LoopActionWoWReforged takes nothing returns nothing
2862+
call Trace("LoopActionWoWReforged\n")
28362863
call ResearchHighLevelTier3Researches()
28372864
call GetZeppelinsIfRequired()
28382865
endfunction

0 commit comments

Comments
 (0)