Добавлен
Почему ящерицы и сатиры в карте Монолит глючные? Через некоторое время после начала игры они начинают ходить туда-сюда и перестают атаковать вражеский лагерь. Я решил попробовать дать ящерицам ИИ призраков из другого Монолита, поменял в данных ИИ войска и здания... Добывает золото. Строит. Нанимает войска. Но всё время стоит на месте и не качается на карте! Может, что-то можно поменять в коде?
раскрыть
===========================================================================

Revenant AI

Warcraft III AI script
Generated by the Warcraft III World Editor
Date: Thu Sep 29 22:31:06 2016

===========================================================================
***************************************************************************
*
* Global Variables
*
***************************************************************************
globals
integer attackWave = 1
integer nextDelay = 0
integer awGold = 0
integer awWood = 0
Conditions
boolean gCond_Attack_Enemy = false
boolean gCond_Attack_Strong_Creeps = false
boolean gCond_Have_Lumber = false
boolean gCond_Need_Expansion = false
endglobals
***************************************************************************
*
* Utility Functions
*
***************************************************************************
===========================================================================
function CheckLastCommand takes boolean pop returns integer
local integer cmd = GetLastCommand()
if (pop) then
call PopLastCommand( )
endif
return cmd
endfunction
===========================================================================
function CheckLastCommandData takes boolean pop returns integer
local integer data = GetLastData()
if (pop) then
call PopLastCommand( )
endif
return data
endfunction
===========================================================================
function TotalFoodProduced takes nothing returns integer
return GetPlayerState(ai_player,PLAYER_STATE_RESOURCE_FOOD_CAP)
endfunction
===========================================================================
function ExpansionNeeded takes nothing returns boolean
return take_exp
endfunction
===========================================================================
function BuildExpansion takes integer hallID, integer mineID returns nothing
if (HallsCompleted(hallID)) then
call SetBuildExpa( TownCount(hallID) + 1, mineID )
endif
endfunction
===========================================================================
function CurrentAttackWave takes nothing returns integer
return attackWave
endfunction
===========================================================================
function ResetAttackUnits takes nothing returns nothing
set awGold = 0
set awWood = 0
call InitAssaultGroup( )
endfunction
===========================================================================
function AddAttackUnit takes integer minQty, integer maxQty, integer unitID returns nothing
Track attacking gold workers
if (unitID == 'n00J') then
set awGold = awGold + minQty
endif
Track attacking wood workers
if (unitID == 'n00J') then
set awWood = awWood + minQty
endif
call SetAssaultGroup( minQty, maxQty, unitID )
endfunction
***************************************************************************
*
* Basic Options
*
***************************************************************************
===========================================================================
function InitOptions takes nothing returns nothing
call SetMeleeAI( )
call SetDefendPlayer( false )
call SetRandomPaths( false )
call SetTargetHeroes( true )
call SetPeonsRepair( true )
call SetHeroesFlee( true )
call SetHeroesBuyItems( false )
call SetUnitsFlee( true )
call SetGroupsFlee( true )
call SetWatchMegaTargets( true )
call SetIgnoreInjured( true )
call SetHeroesTakeItems( true )
call SetSlowChopping( false )
call SetCaptainChanges( false )
call SetSmartArtillery( true )
endfunction
***************************************************************************
*
* Conditions
*
***************************************************************************
===========================================================================
Updates the values of all preset conditions
===========================================================================
function UpdateConditions takes nothing returns nothing
set gCond_Attack_Enemy = ( CheckLastCommand( false ) == 1 )
set gCond_Attack_Strong_Creeps = ( FoodUsed( ) >= 40 )
set gCond_Have_Lumber = ( GetWood( ) > 0 )
set gCond_Need_Expansion = ( ( GetGold( ) < 2000 ) and ( GetGoldOwned( ) < 2000 ) )
endfunction
***************************************************************************
*
* Heroes
*
***************************************************************************
===========================================================================
Stores hero ID and skills
===========================================================================
function SetHero takes integer order, integer heroid returns nothing
if (order == 1) then
set hero_id = heroid
if (heroid == 'O00K') then
set skills1[ 1] = 'ANso'
set skills1[ 2] = 'A008'
set skills1[ 3] = 'A009'
set skills1[ 4] = 'ANso'
set skills1[ 5] = 'A008'
set skills1[ 6] = 'ANfd'
set skills1[ 7] = 'A009'
set skills1[ 8] = 'ANso'
set skills1[ 9] = 'A008'
set skills1[10] = 'A009'
endif
endif
endfunction
===========================================================================
Selects hero IDs for three possible heroes
===========================================================================
function SelectHeroes takes nothing returns nothing
local integer roll = GetRandomInt(1,100)
call SetHero( 1, 'O00K' )
endfunction
===========================================================================
Returns the hero skill for the given hero and level
===========================================================================
function ChooseHeroSkill takes nothing returns integer
local integer curHero = GetHeroId()
local integer level = GetHeroLevelAI()
if (level > max_hero_level) then
set max_hero_level = level
endif
if (curHero == hero_id) then
return skills1[level]
elseif (curHero == hero_id2) then
return skills2[level]
elseif (curHero == hero_id3) then
return skills3[level]
endif
return 0
endfunction
***************************************************************************
*
* Building and Harvesting
*
***************************************************************************
===========================================================================
Specifies building priorities for workers
===========================================================================
function BuildPriorities takes nothing returns nothing
local integer mine = TownWithMine()
call SetBuildAll( BUILD_UNIT, 1, 'o000', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'n00J', -1 )
if (gCond_Need_Expansion) then
call BuildExpansion( 'o00J', 'o00J' )
endif
call SetBuildAll( BUILD_UNIT, 2, 'n00J', -1 )
call SetBuildAll( BUILD_UNIT, 3, 'n00J', -1 )
call SetBuildAll( BUILD_UNIT, 4, 'n00J', -1 )
call SetBuildAll( BUILD_UNIT, 5, 'n00J', -1 )
call SetBuildAll( BUILD_UNIT, 2, 'o00J', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'O00K', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'ntrv', -1 )
call SetBuildAll( BUILD_UNIT, 2, 'ntrv', -1 )
call SetBuildAll( BUILD_UNIT, 3, 'ntrv', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 1, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 1, 'nrvs', -1 )
call SetBuildAll( BUILD_UNIT, 2, 'nrvs', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 2, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 1, 'nsrv', -1 )
call SetBuildAll( BUILD_UNIT, 3, 'o00J', -1 )
call SetBuildAll( BUILD_UNIT, 2, 'nsrv', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 3, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 1, 'nrvl', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'nrvi', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 4, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 1, 'ndrv', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'nrvd', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 5, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 1, 'nlrv', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 6, 'h000', 0 )
endif
call SetBuildAll( BUILD_UNIT, 4, 'ntrv', -1 )
call SetBuildAll( BUILD_UNIT, 1, 'nrvf', -1 )
call SetBuildAll( BUILD_UNIT, 3, 'nrvs', -1 )
if (gCond_Have_Lumber) then
call SetBuildAll( BUILD_UNIT, 7, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 8, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 9, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 10, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 11, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 12, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 13, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 14, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 15, 'h000', 0 )
call SetBuildAll( BUILD_UNIT, 16, 'h000', 0 )
endif
endfunction
===========================================================================
Specifies harvesting priorities for workers
===========================================================================
function HarvestPriorities takes nothing returns nothing
local integer mine = TownWithMine()
local integer allGold = GetUnitCountDone('n00J')
local integer allWood = GetUnitCountDone('n00J')
local integer numWorkers
set numWorkers = 5
call HarvestGold( 0, numWorkers )
set numWorkers = 5
call HarvestGold( 1, numWorkers )
endfunction
===========================================================================
Determines all building and harvesting assignments for workers
===========================================================================
function WorkerAssignment takes nothing returns nothing
loop
call UpdateConditions( )
Harvesting
call ClearHarvestAI( )
call HarvestPriorities( )
Building
call InitBuildArray( )
call BuildPriorities( )
call Sleep( 2 )
endloop
endfunction
***************************************************************************
*
* Attacking
*
***************************************************************************
===========================================================================
Returns true if the minimum forces for an attack exist
===========================================================================
function HaveMinimumAttackers takes nothing returns boolean
local integer count
Check for attack wave limit
if (attackWave > 1) then
return false
endif
Attack Group: Minimum
set count = GetUnitCountDone( 'ntrv' )
if (count < 3) then
return false
endif
return true
endfunction
===========================================================================
Assigns units to attack based on the given attack group
===========================================================================
function PrepareAttackGroup takes integer groupID returns nothing
local integer all
Attack Group #1: All Units
if (groupID == 1) then
set all = GetUnitCountDone( 'nrvs' )
call AddAttackUnit( all, all, 'nrvs' )
set all = GetUnitCountDone( 'O00K' )
call AddAttackUnit( all, all, 'O00K' )
set all = GetUnitCountDone( 'nrvf' )
call AddAttackUnit( all, all, 'nrvf' )
set all = GetUnitCountDone( 'ntrv' )
call AddAttackUnit( all, all, 'ntrv' )
set all = GetUnitCountDone( 'nsrv' )
call AddAttackUnit( all, all, 'nsrv' )
set all = GetUnitCountDone( 'nrvl' )
call AddAttackUnit( all, all, 'nrvl' )
set all = GetUnitCountDone( 'nrvi' )
call AddAttackUnit( all, all, 'nrvi' )
set all = GetUnitCountDone( 'nrvd' )
call AddAttackUnit( all, all, 'nrvd' )
set all = GetUnitCountDone( 'ndrv' )
call AddAttackUnit( all, all, 'ndrv' )
set all = GetUnitCountDone( 'nlrv' )
call AddAttackUnit( all, all, 'nlrv' )
Attack Group #2: Minimum
elseif (groupID == 2) then
set all = GetUnitCountDone( 'O00K' )
call AddAttackUnit( all, all, 'O00K' )
call AddAttackUnit( 3, 3, 'ntrv' )
endif
endfunction
===========================================================================
Prepares an attack group based on the current attack wave
===========================================================================
function PrepareForces takes nothing returns nothing
if (attackWave == 1) then
call PrepareAttackGroup( 1 )
endif
endfunction
===========================================================================
Sleep delays for each attack wave
===========================================================================
function AttackWaveDelay takes integer inWave returns nothing
if (inWave < nextDelay) then
return
endif
set nextDelay = inWave + 1
endfunction
===========================================================================
Advances attack wave counter
===========================================================================
function AttackWaveUpdate takes nothing returns nothing
call AttackWaveDelay( attackWave )
set attackWave = attackWave + 1
if (attackWave > 1) then
set attackWave = 1
set nextDelay = attackWave + 1
endif
endfunction
===========================================================================
Basic attack functionality
===========================================================================
function AttackTarget takes unit target, boolean addAlliance returns nothing
if (target == null) then
return
endif
if (addAlliance) then
call SetAllianceTarget( target )
endif
call FormGroup( 3, true )
call AttackMoveKillA( target )
if (not addAlliance) then
call SetAllianceTarget( null )
endif
endfunction
===========================================================================
Initiates an attack based on target priorities
===========================================================================
function LaunchAttack takes nothing returns nothing
local unit target = null
local boolean setAlly = true
Don't launch any attack while town is threatened
if (TownThreatened()) then
call Sleep( 2 )
return
endif
Target Priority #1
if (target == null) then
set target = GetAllianceTarget()
if (target != null) then
set setAlly = false
endif
endif
Target Priority #2
if (gCond_Attack_Strong_Creeps) then
if (target == null) then
set target = GetExpansionFoe()
if (target != null) then
set take_exp = false
endif
endif
Target Priority #3
endif
if (gCond_Attack_Enemy) then
if (target == null) then
set target = GetMegaTarget()
endif
Target Priority #4
if (target == null) then
set target = GetEnemyExpansion()
endif
Target Priority #5
if (target == null) then
set target = GetEnemyExpansion()
if (target == null) then
call StartGetEnemyBase( )
loop
exitwhen (not WaitGetEnemyBase())
call SuicideSleep( 1 )
endloop
set target = GetEnemyBase()
endif
endif
Target Priority #6
endif
if (target == null) then
set target = GetCreepCamp( 0, 6, false )
endif
Target Priority #7
if (gCond_Attack_Strong_Creeps) then
if (target == null) then
set target = GetCreepCamp( 7, 15, true )
endif
Target Priority #8
if (target == null) then
set target = GetCreepCamp( 16, 100, true )
endif
endif
Attack the target and increment attack wave
if (target != null) then
call AttackTarget( target, setAlly )
call AttackWaveUpdate( )
else
If no target was found, sleep a bit before trying again
call Sleep( 20 )
endif
endfunction
===========================================================================
Determines all attacking assignments
===========================================================================
function AttackAssignment takes nothing returns nothing
call StaggerSleep( 0, 2 )
if (attackWave == 1) then
call AttackWaveDelay( 0 )
endif
loop
loop
call UpdateConditions( )
exitwhen (HaveMinimumAttackers() and not CaptainRetreating())
call Sleep( 2 )
endloop
call RemoveInjuries( )
call ResetAttackUnits( )
call PrepareForces( )
call LaunchAttack( )
endloop
endfunction
***************************************************************************
*
* Main Entry Point
*
***************************************************************************
===========================================================================
function main takes nothing returns nothing
call InitAI( )
call InitOptions( )
call SelectHeroes( )
call CreateCaptains( )
call SetHeroLevels( function ChooseHeroSkill )
call Sleep( 0.1 )
call StartThread( function WorkerAssignment )
call StartThread( function AttackAssignment )
call PlayGame( )
endfunction

Принятый ответ

Для решения таких задач нужно хоть чуть-чуть почитать статьи
`
ОЖИДАНИЕ РЕКЛАМЫ...
0
19
6 лет назад
0
Похожие вопросы:

ответ
вопросы типа сделайте за меня не принимаются
по поводу того как это делать написано здесь xgm.guru/p/wc3/articles
ответ
BrEd Pitt, что значит использовать
берёшь и создаёшь юнитов для резервного игрока а потом отдаёшь им приказ
ответ
Возможно listfile.txt повредился.
Перекачай его.
ответ
есть событие - юнит получает урон. в нём отслеживается как жертва, так и наносящий урон. можно хоть через хэш, хоть через структуру Юнита записывать всё, что угодно. Кто от кого конкретно сколько получил урона, кто кому сколько нанёс, сколько провисел на ком-то бафф яда и т.п. (Сначала был loop, а теперь периодический триггер). Каждые N секунд, перебираешь всех юнитов в массиве или списке, и отслеживаешь всё, что надо.
Структура - Unit. У неё есть двойной список с юнитами и уроном от яда (полученным или нанесённым - зависит от того, у кого будет этот список - у жертв или у тех, кто наносит яд). Типа DoubleList. В DoubleList есть элементы DoubleElement. В каждом таком элементе записаны unit и real (урон от яда от этого юнита). При получении урона от яда перебирается список, если юнит уже есть, урон от него (или ему) прибавляется. Если нет, то создаётся новый элемент с новым юнитом.
Периодически у нужных юнитов эти списки перебираются. Всё.
ответ
Diazon, прочти статьи по массивам/структурам
после чего юзай двухмерные массивы/поля-массивы

0
32
4 года назад
0
Для решения таких задач нужно хоть чуть-чуть почитать статьи
Принятый ответ
Чтобы оставить комментарий, пожалуйста, войдите на сайт.