基於神經網絡的人機對抗人工智能系統 part3 文章網址:http://www.playdota.com/forums/2597/22522-20110-31070-32463-32593-32476-30340-20154-26426-23545-25239-20154-24037-26234-33021-31995-32479-65288-29702-35770-65289-a/ 附錄 目前整個系統已完成控制系統,和巡查系統部分功能。 已經完成的DOTA AI代碼如下(JASS語言,以DOTA 6.59為基礎): Code: globals boolean AI_Start=false integer UNIT_GROUP_MAX_LIMIT=20 integer HERO_GROUP_MAX_LIMIT=4 integer ORDER_SEQUENCE_MAX_LIMIT=10 integer AIPlayer_Count=0 real AIPlayer_TimeScale=0.5 real AIPlayer_TimeSize=2 trigger AIPlayer_Respond_Trigger trigger AIPlayer_Trigger integer NONE=0 integer UNLIMITED=-10 integer AGGRESSIVE=1 integer WATCHFULNESS=2 integer FARM=3 integer RESPONSIVE=4 integer COMPREHENSIVENESS=5 integer SENTINEL=1 integer SCOURGE=2 integer NEUTRAL=3 integer NEUTRALCREEP=4 integer NEUTRALSHOP=5 integer PLACE=6 integer ENTRANCE=7 integer RIVERWAY=8 integer FOUNTAIN=9 integer ROSHAN=10 integer POWERUP=11 integer CREEPMEETING=12 integer TOPLANE=13 integer MIDDLELANE=14 integer BOTTOMLANE=15 integer CROSSING=16 integer RIGHTCLICK=851971 integer STOP=851972 integer DISABLED=851973 integer ATTACK=851983 integer PATROL=851990 integer HOLD=851993 integer WAIT=1 integer FARMCREEPTO=2 integer FARMNEUTRALTO=3 integer MOVETO=4 integer ATTACKTO=5 integer SPELLTO=6 integer GANKTO=7 integer MIDDLE=1 integer LEFT=2 integer RIGHT=3 integer TOP=4 integer BOTTOM=5 boolean array Sentinel_AIPlayer_AI player array Sentinel_AIPlayer_PlayerHandle real array Sentinel_AIPlayer_Coefficient_Aggressive real array Sentinel_AIPlayer_Coefficient_Watchfulness real array Sentinel_AIPlayer_Coefficient_Farm real array Sentinel_AIPlayer_Coefficient_Responsive real array Sentinel_AIPlayer_Coefficient_Comprehensiveness integer Sentinel_AIPlayer_Captian group array Sentinel_AIPlayer_UnitGroup location array Sentinel_AIPlayer_UnitLastLoc integer array Sentinel_AIPlayer_UnitGroup_Count integer array Sentinel_AIPlayer_UnitGroup_Sequence_Count integer array Sentinel_AIPlayer_UnitGroup_Order_Sequence unit array Sentinel_AIPlayer_UnitGroup_TargetUnit_Sequence location array Sentinel_AIPlayer_UnitGroup_TargetLoc_Sequence real array Sentinel_AIPlayer_UnitGroup_Order_Sequence_Timer integer array Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe integer array Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe_Target group array Sentinel_AIPlayer_HeroGroup location array Sentinel_AIPlayer_HeroLastLoc integer array Sentinel_AIPlayer_HeroGroup_Count integer array Sentinel_AIPlayer_HeroGroup_Sequence_Count integer array Sentinel_AIPlayer_HeroGroup_Order_Sequence unit array Sentinel_AIPlayer_HeroGroup_TargetUnit_Sequence location array Sentinel_AIPlayer_HeroGroup_TargetLoc_Sequence real array Sentinel_AIPlayer_HeroGroup_Order_Sequence_Timer integer array Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe integer array Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe_Target group array Sentinel_AIPlayer_Nearby_AllyHeroGroup group array Sentinel_AIPlayer_Nearby_EnemyHeroGroup group array Sentinel_AIPlayer_Nearby_AllyCreepGroup group array Sentinel_AIPlayer_Nearby_EnemyCreepGroup group array Sentinel_AIPlayer_Nearby_AllyStructureGroup group array Sentinel_AIPlayer_Nearby_EnemyStructureGroup integer array Sentinel_AIPlayer_Nearby_AllyHeroGroup_Count integer array Sentinel_AIPlayer_Nearby_EnemyHeroGroup_Count integer array Sentinel_AIPlayer_Nearby_AllyCreepGroup_Count integer array Sentinel_AIPlayer_Nearby_EnemyCreepGroup_Count integer array Sentinel_AIPlayer_Nearby_AllyStructureGroup_Count integer array Sentinel_AIPlayer_Nearby_EnemyStructureGroup_Count boolean array Scourge_AIPlayer_AI player array Scourge_AIPlayer_PlayerHandle real array Scourge_AIPlayer_Coefficient_Aggressive real array Scourge_AIPlayer_Coefficient_Watchfulness real array Scourge_AIPlayer_Coefficient_Farm real array Scourge_AIPlayer_Coefficient_Responsive real array Scourge_AIPlayer_Coefficient_Comprehensiveness integer Scourge_AIPlayer_Captian group array Scourge_AIPlayer_UnitGroup location array Scourge_AIPlayer_UnitLastLoc integer array Scourge_AIPlayer_UnitGroup_Count integer array Scourge_AIPlayer_UnitGroup_Sequence_Count integer array Scourge_AIPlayer_UnitGroup_Order_Sequence unit array Scourge_AIPlayer_UnitGroup_TargetUnit_Sequence location array Scourge_AIPlayer_UnitGroup_TargetLoc_Sequence real array Scourge_AIPlayer_UnitGroup_Order_Sequence_Timer integer array Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe integer array Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe_Target group array Scourge_AIPlayer_HeroGroup location array Scourge_AIPlayer_HeroLastLoc integer array Scourge_AIPlayer_HeroGroup_Count integer array Scourge_AIPlayer_HeroGroup_Sequence_Count integer array Scourge_AIPlayer_HeroGroup_Order_Sequence unit array Scourge_AIPlayer_HeroGroup_TargetUnit_Sequence location array Scourge_AIPlayer_HeroGroup_TargetLoc_Sequence real array Scourge_AIPlayer_HeroGroup_Order_Sequence_Timer integer array Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe integer array Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe_Target group array Scourge_AIPlayer_Nearby_AllyHeroGroup group array Scourge_AIPlayer_Nearby_EnemyHeroGroup group array Scourge_AIPlayer_Nearby_AllyCreepGroup group array Scourge_AIPlayer_Nearby_EnemyCreepGroup group array Scourge_AIPlayer_Nearby_AllyStructureGroup group array Scourge_AIPlayer_Nearby_EnemyStructureGroup integer array Scourge_AIPlayer_Nearby_AllyHeroGroup_Count integer array Scourge_AIPlayer_Nearby_EnemyHeroGroup_Count integer array Scourge_AIPlayer_Nearby_AllyCreepGroup_Count integer array Scourge_AIPlayer_Nearby_EnemyCreepGroup_Count integer array Scourge_AIPlayer_Nearby_AllyStructureGroup_Count integer array Scourge_AIPlayer_Nearby_EnemyStructureGroup_Count rect array Rect_PowerUP rect Rect_Roshan rect array Rect_Riverway_Entrance rect Rect_TopLane_CreepMeeting rect Rect_MiddleLane_CreepMeeting rect Rect_BottomLane_CreepMeeting rect array Rect_Riverway_Sentinel_Crossing rect Rect_Fountain_Sentinel rect array Rect_TopLane_Sentinel_Entrance rect array Rect_MiddleLane_Sentinel_Entrance rect array Rect_BottomLane_Sentinel_Entrance rect array Rect_NeutralCreep_Sentinel rect array Rect_NeutralCreep_Sentinel_Entrance rect array Rect_NeutralShop_Sentinel rect array Rect_NeutralShop_Sentinel_Entrance rect array Rect_Riverway_Scourge_Crossing rect Rect_Fountain_Scourge rect array Rect_TopLane_Scourge_Entrance rect array Rect_MiddleLane_Scourge_Entrance rect array Rect_BottomLane_Scourge_Entrance rect array Rect_NeutralCreep_Scourge rect array Rect_NeutralCreep_Scourge_Entrance rect array Rect_NeutralShop_Scourge rect array Rect_NeutralShop_Scourge_Entrance gamecache OOII //CXV boolean I1II //Normal Mode boolean array I //NOV unit array OII0 //B_V integer array I101OO //YFV player OOO0O=null boolean array O0O0O real OOI0O=0 force I010 //Ally Force force IIO0 //Enemy Force unit I1I1IO //'n008' unit I1I11O //'ntav' unit I11OOO //'n01D' unit I11O0O //'n01N' unit I11OIO //'n007' unit I11O1O //'n005' unit I110OO //'n01B' unit I1100O //'n01P' endglobals function IOIOO0O takes nothing returns boolean return false endfunction function O1OOOI takes player TempPlayer returns nothing endfunction function IOIOOIO takes nothing returns nothing endfunction function O01I0I takes handle TempHandle returns integer return TempHandle return 0 endfunction function OI100I takes player OI10II returns boolean if(GetPlayerSlotState(OI10II)==PLAYER_SLOT_STATE_PLAYING)then if(GetPlayerController(OI10II)==MAP_CONTROL_USER) or (GetPlayerController(OI10II)==MAP_CONTROL_COMPUTER) then return true endif endif return false endfunction function OI101I takes player OI10II returns boolean if(GetPlayerSlotState(OI10II)==PLAYER_SLOT_STATE_PLAYING or GetPlayerSlotState(OI10II)==PLAYER_SLOT_STATE_LEFT)then if(GetPlayerController(OI10II)==MAP_CONTROL_USER) or (GetPlayerController(OI10II)==MAP_CONTROL_COMPUTER) then return true endif endif return false endfunction function OI1IOI takes player OI10II returns boolean if GetPlayerSlotState(OI10II)==PLAYER_SLOT_STATE_LEFT then if(GetPlayerController(OI10II)==MAP_CONTROL_USER) or (GetPlayerController(OI10II)==MAP_CONTROL_COMPUTER) then return true endif endif return false endfunction function H2I takes handle TempHandle returns integer return TempHandle return 0 endfunction function H2S takes handle TempHandle returns string return I2S(H2I(TempHandle)) endfunction function StoInt takes string TempString1,string TempString2,integer TempInt returns nothing call StoreInteger(OOII,TempString1,TempString2,TempInt) endfunction function StoReal takes string TempString1,string TempString2,real TempReal returns nothing call StoreReal(OOII,TempString1,TempString2,TempReal) endfunction function StoBoolean takes string TempString1,string TempString2,boolean TempBoolean returns nothing call StoreBoolean(OOII,TempString1,TempString2,TempBoolean) endfunction function StoString takes string TempString1,string TempString2,string TempString3 returns nothing call StoreString(OOII,TempString1,TempString2,TempString3) endfunction function StoHandle takes string TempString1,string TempString2,handle TempHandle returns nothing call StoreInteger(OOII,TempString1,TempString2,H2I(TempHandle)) endfunction function GetStoInt takes string TempString1,string TempString2 returns integer return GetStoredInteger(OOII,TempString1,TempString2) endfunction function GetStoReal takes string TempString1,string TempString2 returns real return GetStoredReal(OOII,TempString1,TempString2) endfunction function GetStoBoolean takes string TempString1,string TempString2 returns boolean return GetStoredBoolean(OOII,TempString1,TempString2) endfunction function GetStoString takes string TempString1,string TempString2 returns string return GetStoredString(OOII,TempString1,TempString2) endfunction function GetStoUnit takes string TempString1,string TempString2 returns unit return GetStoredInteger(OOII,TempString1,TempString2) return null endfunction function GetStoGroup takes string TempString1,string TempString2 returns group return GetStoredInteger(OOII,TempString1,TempString2) return null endfunction function GetStoPlayer takes string TempString1,string TempString2 returns player return GetStoredInteger(OOII,TempString1,TempString2) return null endfunction function IsStoInt takes string TempString1,string TempString2 returns boolean return HaveStoredInteger(OOII,TempString1,TempString2) endfunction function IsStoReal takes string TempString1,string TempString2 returns boolean return HaveStoredReal(OOII,TempString1,TempString2) endfunction function IsStoBoolean takes string TempString1,string TempString2 returns boolean return HaveStoredBoolean(OOII,TempString1,TempString2) endfunction function IsStoString takes string TempString1,string TempString2 returns boolean return HaveStoredString(OOII,TempString1,TempString2) endfunction function ClearSto takes string TempString returns nothing call FlushStoredMission(OOII,TempString) endfunction function LL takes string TempString returns nothing call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,AIPlayer_TimeScale,"|cffffcc00"+TempString+"|r") endfunction function Filter_True takes nothing returns boolean return true endfunction function IsNumIn takes integer WhichNum,integer Num1,integer Num2 returns boolean if WhichNum>Num1 and WhichNum return true else return false endif endfunction function RectCenter2Loc takes rect TempRect returns location return Location(GetRectCenterX(TempRect),GetRectCenterY(TempRect)) endfunction function RectRandomLoc takes rect TempRect,integer TempCenterX,integer TempCenterY,real TempSizeCent returns location local real RectCenterX local real RectCenterY local real RectXSize=GetRectMinX(TempRect)+GetRectMaxX(TempRect) local real RectYSize=GetRectMinY(TempRect)+GetRectMaxY(TempRect) local real RectXMin local real RectXMax local real RectYMin local real RectYMax if TempCenterX==MIDDLE then set RectCenterX=RectXSize/2 elseif TempCenterX==LEFT then set RectCenterX=RectXSize/4 elseif TempCenterY==RIGHT then set RectCenterX=RectXSize*3/4 endif if TempCenterY==MIDDLE then set RectCenterY=RectCenterY/2 elseif TempCenterY==TOP then set RectCenterY=RectCenterY/4 elseif TempCenterY==BOTTOM then set RectCenterY=RectCenterY*3/4 endif if TempCenterX==MIDDLE and TempCenterY==MIDDLE then set TempSizeCent=TempSizeCent*2 endif set RectXMin=RectCenterX-RectXSize*TempSizeCent/4 set RectXMax=RectCenterX+RectXSize*TempSizeCent/4 set RectYMin=RectCenterY-RectYSize*TempSizeCent/4 set RectYMax=RectCenterY+RectYSize*TempSizeCent/4 return Location(GetRandomReal(RectXMin,RectXMax),GetRandomReal(RectYMin,RectYMax)) endfunction function GetMapData takes integer PlayerForce,integer PlaceDes1,integer PlaceDes2,integer PlaceNum returns rect if PlayerForce==NEUTRAL then if PlaceDes1==POWERUP and IsNumIn(PlaceNum,1,2) then return Rect_PowerUP[PlaceNum] elseif PlaceDes1==ROSHAN then return Rect_Roshan elseif PlaceDes1==RIVERWAY and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_Riverway_Entrance[PlaceNum] elseif PlaceDes1==TOPLANE and PlaceDes2==CREEPMEETING then return Rect_TopLane_CreepMeeting elseif PlaceDes1==MIDDLELANE and PlaceDes2==CREEPMEETING then return Rect_MiddleLane_CreepMeeting elseif PlaceDes1==BOTTOMLANE and PlaceDes2==CREEPMEETING then return Rect_BottomLane_CreepMeeting endif elseif PlayerForce==SENTINEL then if PlaceDes1==RIVERWAY and PlaceDes2==CROSSING and IsNumIn(PlaceNum,1,4) then return Rect_Riverway_Sentinel_Crossing[PlaceNum] elseif PlaceDes1==FOUNTAIN then return Rect_Fountain_Sentinel elseif PlaceDes1==TOPLANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_TopLane_Sentinel_Entrance[PlaceNum] elseif PlaceDes1==MIDDLELANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_MiddleLane_Sentinel_Entrance[PlaceNum] elseif PlaceDes1==BOTTOMLANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_BottomLane_Sentinel_Entrance[PlaceNum] elseif PlaceDes1==NEUTRALCREEP and PlaceDes2==PLACE and IsNumIn(PlaceNum,1,6) then return Rect_NeutralCreep_Sentinel[PlaceNum] elseif PlaceDes1==NEUTRALCREEP and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,14) then return Rect_NeutralCreep_Sentinel_Entrance[PlaceNum] elseif PlaceDes1==NEUTRALSHOP and PlaceDes2==PLACE and IsNumIn(PlaceNum,1,2) then return Rect_NeutralShop_Sentinel[PlaceNum] elseif PlaceDes1==NEUTRALSHOP and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,3) then return Rect_NeutralShop_Sentinel_Entrance[PlaceNum] endif elseif PlayerForce==SCOURGE then if PlaceDes1==RIVERWAY and PlaceDes2==CROSSING and IsNumIn(PlaceNum,1,5) then return Rect_Riverway_Scourge_Crossing[PlaceNum] elseif PlaceDes1==FOUNTAIN then return Rect_Fountain_Scourge elseif PlaceDes1==TOPLANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_TopLane_Scourge_Entrance[PlaceNum] elseif PlaceDes1==MIDDLELANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_MiddleLane_Scourge_Entrance[PlaceNum] elseif PlaceDes1==BOTTOMLANE and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,2) then return Rect_BottomLane_Scourge_Entrance[PlaceNum] elseif PlaceDes1==NEUTRALCREEP and PlaceDes2==PLACE and IsNumIn(PlaceNum,1,6) then return Rect_NeutralCreep_Scourge[PlaceNum] elseif PlaceDes1==NEUTRALCREEP and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,10) then return Rect_NeutralCreep_Scourge_Entrance[PlaceNum] elseif PlaceDes1==NEUTRALSHOP and PlaceDes2==PLACE and IsNumIn(PlaceNum,1,2) then return Rect_NeutralShop_Scourge[PlaceNum] elseif PlaceDes1==NEUTRALSHOP and PlaceDes2==ENTRANCE and IsNumIn(PlaceNum,1,3) then return Rect_NeutralShop_Scourge_Entrance[PlaceNum] endif endif return null endfunction function IsPlayerAI takes integer PlayerForce,integer PlayerNumber returns boolean if PlayerForce==SENTINEL then return Sentinel_AIPlayer_AI[PlayerNumber] else return Scourge_AIPlayer_AI[PlayerNumber] endif endfunction function IsUnitDisabled takes unit TempUnit returns boolean return GetUnitCurrentOrder(TempUnit)==DISABLED or GetUnitCurrentOrder(TempUnit)==851975 or GetUnitCurrentOrder(TempUnit)==851987 endfunction function IsOrderDisabled takes integer TempInt returns boolean return TempInt==DISABLED or TempInt==851975 or TempInt==851987 endfunction function IsUnitStopped takes unit TempUnit returns boolean return GetUnitCurrentOrder(TempUnit)==0 endfunction function IsOrderStopped takes integer TempInt returns boolean return TempInt==0 endfunction function GetAIPlayerNumber takes player TempPlayer returns integer local integer i=1 local integer TempInt=0 loop if TempPlayer==Sentinel_AIPlayer_PlayerHandle[i] or TempPlayer==Scourge_AIPlayer_PlayerHandle[i] then set TempInt=i endif set i=i+1 exitwhen TempInt!=0 endloop return TempInt endfunction function SetAIPlayerCaptian takes integer PlayerForce,integer PlayerNumber returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_Captian=PlayerNumber else set Scourge_AIPlayer_Captian=PlayerNumber endif endfunction function GetAIPlayerHandle takes integer PlayerForce,integer PlayerNumber returns player if PlayerForce==SENTINEL then return Sentinel_AIPlayer_PlayerHandle[PlayerNumber] else return Scourge_AIPlayer_PlayerHandle[PlayerNumber] endif endfunction function GetAIPlayerCaptian takes integer PlayerForce returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_Captian else return Scourge_AIPlayer_Captian endif endfunction function AIPlayer_Filter_Player takes nothing returns nothing local integer PlayerNumber=1 loop if PlayerNumber<7> set Sentinel_AIPlayer_AI[PlayerNumber]=false if GetPlayerSlotState(Player(PlayerNumber))==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(PlayerNumber))==MAP_CONTROL_COMPUTER then set AIPlayer_Count=AIPlayer_Count+1 set Sentinel_AIPlayer_AI[PlayerNumber]=true set Sentinel_AIPlayer_PlayerHandle[PlayerNumber]=Player(PlayerNumber) endif else set Scourge_AIPlayer_AI[PlayerNumber-6]=false if GetPlayerSlotState(Player(PlayerNumber))==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(Player(PlayerNumber))==MAP_CONTROL_COMPUTER then set AIPlayer_Count=AIPlayer_Count+1 set Scourge_AIPlayer_AI[PlayerNumber-6]=true set Scourge_AIPlayer_PlayerHandle[PlayerNumber-6]=Player(PlayerNumber) endif endif set PlayerNumber=PlayerNumber+1 if PlayerNumber==6 then set PlayerNumber=7 endif exitwhen PlayerNumber>11 endloop endfunction function SetAIPlayerCoefficient takes integer PlayerForce,integer PlayerNumber,integer Coefficient,real TempReal returns nothing if PlayerForce==SENTINEL then if Coefficient==AGGRESSIVE then set Sentinel_AIPlayer_Coefficient_Aggressive[PlayerNumber]=TempReal elseif Coefficient==WATCHFULNESS then set Sentinel_AIPlayer_Coefficient_Watchfulness[PlayerNumber]=TempReal elseif Coefficient==FARM then set Sentinel_AIPlayer_Coefficient_Farm[PlayerNumber]=TempReal elseif Coefficient==RESPONSIVE then set Sentinel_AIPlayer_Coefficient_Responsive[PlayerNumber]=TempReal elseif Coefficient==COMPREHENSIVENESS then set Sentinel_AIPlayer_Coefficient_Comprehensiveness[PlayerNumber]=Sentinel_AIPlayer_Coefficient_Aggressive[PlayerNumber]*Sentinel_AIPlayer_Coefficient_Watchfulness[PlayerNumber]*Sentinel_AIPlayer_Coefficient_Farm[PlayerNumber]*Sentinel_AIPlayer_Coefficient_Responsive[PlayerNumber] endif else if Coefficient==AGGRESSIVE then set Scourge_AIPlayer_Coefficient_Aggressive[PlayerNumber]=TempReal elseif Coefficient==WATCHFULNESS then set Scourge_AIPlayer_Coefficient_Watchfulness[PlayerNumber]=TempReal elseif Coefficient==FARM then set Scourge_AIPlayer_Coefficient_Farm[PlayerNumber]=TempReal elseif Coefficient==RESPONSIVE then set Scourge_AIPlayer_Coefficient_Responsive[PlayerNumber]=TempReal elseif Coefficient==COMPREHENSIVENESS then set Scourge_AIPlayer_Coefficient_Comprehensiveness[PlayerNumber]=Scourge_AIPlayer_Coefficient_Aggressive[PlayerNumber]*Scourge_AIPlayer_Coefficient_Watchfulness[PlayerNumber]*Scourge_AIPlayer_Coefficient_Farm[PlayerNumber]*Scourge_AIPlayer_Coefficient_Responsive[PlayerNumber] endif endif endfunction function GetAIPlayerCoefficient takes integer PlayerForce,integer PlayerNumber,integer Coefficient returns real local real TempReal if PlayerForce==SENTINEL then if Coefficient==AGGRESSIVE then set TempReal=Sentinel_AIPlayer_Coefficient_Aggressive[PlayerNumber] elseif Coefficient==WATCHFULNESS then set TempReal=Sentinel_AIPlayer_Coefficient_Watchfulness[PlayerNumber] elseif Coefficient==FARM then set TempReal=Sentinel_AIPlayer_Coefficient_Farm[PlayerNumber] elseif Coefficient==RESPONSIVE then set TempReal=Sentinel_AIPlayer_Coefficient_Responsive[PlayerNumber] elseif Coefficient==COMPREHENSIVENESS then set TempReal=Sentinel_AIPlayer_Coefficient_Comprehensiveness[PlayerNumber] endif else if Coefficient==AGGRESSIVE then set TempReal=Scourge_AIPlayer_Coefficient_Aggressive[PlayerNumber] elseif Coefficient==WATCHFULNESS then set TempReal=Scourge_AIPlayer_Coefficient_Watchfulness[PlayerNumber] elseif Coefficient==FARM then set TempReal=Scourge_AIPlayer_Coefficient_Farm[PlayerNumber] elseif Coefficient==RESPONSIVE then set TempReal=Scourge_AIPlayer_Coefficient_Responsive[PlayerNumber] elseif Coefficient==COMPREHENSIVENESS then set TempReal=Scourge_AIPlayer_Coefficient_Comprehensiveness[PlayerNumber] endif endif return TempReal endfunction function AIPlayer_Set_Character takes nothing returns nothing local integer PlayerForce local integer PlayerNumber=1 local real TempReal1=0 local integer TempInt1=0 local real TempReal2=0 local integer TempInt2=0 loop set PlayerForce=SENTINEL if IsPlayerAI(PlayerForce,PlayerNumber)==true then call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,AGGRESSIVE,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,WATCHFULNESS,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,FARM,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,RESPONSIVE,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,COMPREHENSIVENESS,NONE) if TempReal1==0 or TempReal1 set TempReal1=GetAIPlayerCoefficient(PlayerForce,PlayerNumber,COMPREHENSIVENESS) set TempInt1=PlayerNumber endif endif set PlayerForce=SCOURGE if IsPlayerAI(PlayerForce,PlayerNumber)==true then call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,AGGRESSIVE,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,WATCHFULNESS,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,FARM,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,RESPONSIVE,GetRandomInt(75,99)/100) call SetAIPlayerCoefficient(PlayerForce,PlayerNumber,COMPREHENSIVENESS,NONE) if TempReal2==0 or TempReal2 set TempReal2=GetAIPlayerCoefficient(PlayerForce,PlayerNumber,COMPREHENSIVENESS) set TempInt2=PlayerNumber endif endif set PlayerNumber=PlayerNumber+1 exitwhen PlayerNumber>5 endloop if TempInt1>0 then call SetAIPlayerCaptian(SENTINEL,TempInt1) endif if TempInt2>0 then call SetAIPlayerCaptian(SCOURGE,TempInt2) endif endfunction function AIPlayer_Speak takes integer PlayerForce,integer PlayerNumber,string TempString returns nothing local player TempPlayer local string AIPlayer_PlayerName local force TempForce set TempPlayer=GetAIPlayerHandle(PlayerForce,PlayerNumber) set TempForce=I010 set AIPlayer_PlayerName=GetPlayerName(TempPlayer) call DisplayTimedTextToForce(TempForce,10,AIPlayer_PlayerName+":"+TempString) set TempPlayer=null set TempForce=null endfunction function AIPlayer_RandomChoose takes player TempPlayer returns nothing local player OI10II=TempPlayer local trigger t set OOO0O=OI10II if IOIOO0O()and O0O0O[GetPlayerId(OI10II)]==false then set O0O0O[GetPlayerId(OI10II)]=true call O1OOOI(OI10II) call DisplayTimedTextToPlayer(OI10II,0,OOI0O,10,(GetObjectName((1848653633)))) set t=CreateTrigger() call TriggerRegisterTimerEvent(t,6,false) call TriggerAddCondition(t,Condition(function IOIOOIO)) call StoreInteger(OOII,((I2S(O01I0I((t))))),("p"),O01I0I((OI10II))) endif set t=null endfunction function AIPlayer_Choose_Hero takes nothing returns nothing local integer i=1 local boolean TempBoolean loop if IsPlayerAI(SENTINEL,i) then call AIPlayer_Speak(SENTINEL,i,"-random") call AIPlayer_RandomChoose(Sentinel_AIPlayer_PlayerHandle[i]) endif if IsPlayerAI(SCOURGE,i) then call AIPlayer_Speak(SCOURGE,i,"-random") call AIPlayer_RandomChoose(Scourge_AIPlayer_PlayerHandle[i]) endif call TriggerSleepAction(GetRandomReal(1,3)) set i=i+1 exitwhen i>5 endloop endfunction function AIPlayer_MakeSure_ItemBuild takes nothing returns nothing endfunction function GetUnitSequenceIndex takes integer PlayerNumber,integer UnitNumber,integer IndexNumber returns integer local integer Index set Index=UnitNumber+(PlayerNumber-1)*HERO_GROUP_MAX_LIMIT if IndexNumber!=0 then set Index=(Index-1)*ORDER_SEQUENCE_MAX_LIMIT+IndexNumber endif return Index endfunction function SetUnitSequenceCount takes integer PlayerForce,integer UnitIndex,integer TempCount returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_UnitGroup_Sequence_Count[UnitIndex]=TempCount else set Scourge_AIPlayer_UnitGroup_Sequence_Count[UnitIndex]=TempCount endif endfunction function SetUnitSequence takes integer PlayerForce,integer UnitSequenceIndex,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_UnitGroup_Order_Sequence[UnitSequenceIndex]=TempOrder set Sentinel_AIPlayer_UnitGroup_TargetUnit_Sequence[UnitSequenceIndex]=TempTargetUnit set Sentinel_AIPlayer_UnitGroup_TargetLoc_Sequence[UnitSequenceIndex]=TempTargetLoc set Sentinel_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex]=TempTimer set Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe[UnitSequenceIndex]=TempDescribe set Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe_Target[UnitSequenceIndex]=TempDescribeTarget else set Scourge_AIPlayer_UnitGroup_Order_Sequence[UnitSequenceIndex]=TempOrder set Scourge_AIPlayer_UnitGroup_TargetUnit_Sequence[UnitSequenceIndex]=TempTargetUnit set Scourge_AIPlayer_UnitGroup_TargetLoc_Sequence[UnitSequenceIndex]=TempTargetLoc set Scourge_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex]=TempTimer set Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe[UnitSequenceIndex]=TempDescribe set Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe_Target[UnitSequenceIndex]=TempDescribeTarget endif endfunction function SetUnitSequenceTimer takes integer PlayerForce,integer UnitSequenceIndex,real TempTimer returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex]=TempTimer else set Scourge_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex]=TempTimer endif endfunction function GetUnitSequenceCount takes integer PlayerForce,integer UnitIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Sequence_Count[UnitIndex] else return Scourge_AIPlayer_UnitGroup_Sequence_Count[UnitIndex] endif endfunction function GetUnitSequenceOrder takes integer PlayerForce,integer UnitSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Order_Sequence[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_Order_Sequence[UnitSequenceIndex] endif endfunction function GetUnitSequenceTargetUnit takes integer PlayerForce,integer UnitSequenceIndex returns unit if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_TargetUnit_Sequence[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_TargetUnit_Sequence[UnitSequenceIndex] endif endfunction function GetUnitSequenceTargetLoc takes integer PlayerForce,integer UnitSequenceIndex returns location if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_TargetLoc_Sequence[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_TargetLoc_Sequence[UnitSequenceIndex] endif endfunction function GetUnitSequenceTimer takes integer PlayerForce,integer UnitSequenceIndex returns real if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_Order_Sequence_Timer[UnitSequenceIndex] endif endfunction function GetUnitSequenceDescribe takes integer PlayerForce,integer UnitSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe[UnitSequenceIndex] endif endfunction function GetUnitSequenceDescribeTarget takes integer PlayerForce,integer UnitSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Order_Sequence_Describe_Target[UnitSequenceIndex] else return Scourge_AIPlayer_UnitGroup_Order_Sequence_Describe_Target[UnitSequenceIndex] endif endfunction function ClearUnitSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,boolean CompletelyClear returns nothing local integer TempInt local integer TempCount local integer UnitIndex local integer UnitSequenceIndex set UnitIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,0) if CompletelyClear==false then call SetUnitSequenceCount(PlayerForce,UnitIndex,1) endif set TempInt=1 set TempCount=GetUnitSequenceCount(PlayerForce,UnitIndex) loop set UnitSequenceIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempInt) call SetUnitSequence(PlayerForce,UnitSequenceIndex,HOLD,null,null,UNLIMITED,WAIT,NONE) set TempInt=TempInt+1 exitwhen TempInt>TempCount endloop endfunction function ReplaceUnitSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer UnitSequenceIndex set UnitSequenceIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,1) call SetUnitSequence(PlayerForce,UnitSequenceIndex,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) endfunction function InsertUnitSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer UnitIndex local integer UnitSequenceIndex1 local integer UnitSequenceIndex2 local integer UnitSequenceOrder local unit UnitSequenceTargetUnit local location UnitSequenceTargetLoc local real UnitSequenceTimer local integer UnitSequenceDescribe local integer UnitSequenceDescribeTarget local integer TempCount set UnitIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,0) set TempCount=GetUnitSequenceCount(PlayerForce,UnitIndex)+1 call SetUnitSequenceCount(PlayerForce,UnitIndex,TempCount) loop exitwhen TempCount==1 set UnitSequenceIndex1=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempCount) set UnitSequenceIndex2=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempCount-1) set UnitSequenceOrder=GetUnitSequenceOrder(PlayerForce,UnitSequenceIndex2) set UnitSequenceTargetUnit=GetUnitSequenceTargetUnit(PlayerForce,UnitSequenceIndex2) set UnitSequenceTargetLoc=GetUnitSequenceTargetLoc(PlayerForce,UnitSequenceIndex2) set UnitSequenceTimer=GetUnitSequenceTimer(PlayerForce,UnitSequenceIndex2) set UnitSequenceDescribe=GetUnitSequenceDescribe(PlayerForce,UnitSequenceIndex2) set UnitSequenceDescribeTarget=GetUnitSequenceDescribeTarget(PlayerForce,UnitSequenceIndex2) call SetUnitSequence(PlayerForce,UnitSequenceIndex1,UnitSequenceOrder,UnitSequenceTargetUnit,UnitSequenceTargetLoc,UnitSequenceTimer,UnitSequenceDescribe,UnitSequenceDescribeTarget) set TempCount=TempCount-1 endloop call SetUnitSequence(PlayerForce,UnitSequenceIndex2,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) set UnitSequenceTargetUnit=null set UnitSequenceTargetLoc=null endfunction function AddUnitSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer UnitIndex local integer UnitSequenceIndex local integer TempCount local integer OrderSequence set UnitIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,0) set TempCount=GetUnitSequenceCount(PlayerForce,UnitIndex)+1 set UnitSequenceIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempCount) call SetUnitSequence(PlayerForce,UnitSequenceIndex,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) call SetUnitSequenceCount(PlayerForce,UnitIndex,TempCount) endfunction function NextUnitSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber returns nothing local integer TempInt local integer TempCount local integer UnitIndex local integer UnitSequenceIndex1 local integer UnitSequenceIndex2 local integer UnitSequenceOrder local unit UnitSequenceTargetUnit local location UnitSequenceTargetLoc local real UnitSequenceTimer local integer UnitSequenceDescribe local integer UnitSequenceDescribeTarget set UnitIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,0) set TempCount=GetUnitSequenceCount(PlayerForce,UnitIndex) if TempCount==1 then call ClearUnitSequenceOrder(PlayerForce,PlayerNumber,UnitNumber,false) else set TempInt=2 loop set UnitSequenceIndex1=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempInt-1) set UnitSequenceIndex2=GetUnitSequenceIndex(PlayerNumber,UnitNumber,TempInt) set UnitSequenceOrder=GetUnitSequenceOrder(PlayerForce,UnitSequenceIndex2) set UnitSequenceTargetUnit=GetUnitSequenceTargetUnit(PlayerForce,UnitSequenceIndex2) set UnitSequenceTargetLoc=GetUnitSequenceTargetLoc(PlayerForce,UnitSequenceIndex2) set UnitSequenceTimer=GetUnitSequenceTimer(PlayerForce,UnitSequenceIndex2) set UnitSequenceDescribe=GetUnitSequenceDescribe(PlayerForce,UnitSequenceIndex2) set UnitSequenceDescribeTarget=GetUnitSequenceDescribeTarget(PlayerForce,UnitSequenceIndex2) call SetUnitSequence(PlayerForce,UnitSequenceIndex1,UnitSequenceOrder,UnitSequenceTargetUnit,UnitSequenceTargetLoc,UnitSequenceTimer,UnitSequenceDescribe,UnitSequenceDescribeTarget) set TempInt=TempInt+1 exitwhen TempInt>TempCount endloop call SetUnitSequence(PlayerForce,UnitSequenceIndex2,HOLD,null,null,UNLIMITED,WAIT,NONE) call SetUnitSequenceCount(PlayerForce,UnitIndex,TempCount-1) endif set UnitSequenceTargetUnit=null set UnitSequenceTargetLoc=null endfunction function UnitSequenceExecuteOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,unit UnitHandle returns nothing local integer TempIndex local integer TempOrder local unit TempTargetUnit local location TempTargetLoc set TempIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,1) set TempOrder=GetUnitSequenceOrder(PlayerForce,TempIndex) set TempTargetUnit=GetUnitSequenceTargetUnit(PlayerForce,TempIndex) set TempTargetLoc=GetUnitSequenceTargetLoc(PlayerForce,TempIndex) if TempTargetUnit==null then if TempTargetLoc==null then call IssueImmediateOrderById(UnitHandle,TempOrder) else call IssuePointOrderByIdLoc(UnitHandle,TempOrder,TempTargetLoc) endif else call IssueTargetOrderById(UnitHandle,TempOrder,TempTargetUnit) endif set TempTargetUnit=null set TempTargetLoc=null endfunction function UnitDealNewOrder takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,unit UnitHandle returns nothing local integer CurrentOrder=GetUnitCurrentOrder(UnitHandle) if IsOrderDisabled(CurrentOrder) then call ClearUnitSequenceOrder(PlayerForce,PlayerNumber,UnitNumber,true) elseif IsOrderStopped(CurrentOrder) then call NextUnitSequenceOrder(PlayerForce,PlayerNumber,UnitNumber) endif call UnitSequenceExecuteOrder(PlayerForce,PlayerNumber,UnitNumber,UnitHandle) endfunction function UnitCurrentOrderChanged takes integer PlayerForce,integer PlayerNumber,integer UnitNumber,unit UnitHandle returns boolean local integer CurrentOrder local integer OrderSequence local integer UnitSequenceIndex=GetUnitSequenceIndex(PlayerNumber,UnitNumber,1) local integer TempCount=GetUnitSequenceCount(PlayerForce,GetUnitSequenceIndex(PlayerNumber,UnitNumber,0)) local real TempTimer=GetUnitSequenceTimer(PlayerForce,UnitSequenceIndex) set TempTimer=TempTimer-AIPlayer_TimeSize call SetUnitSequenceTimer(PlayerForce,UnitSequenceIndex,TempTimer) set CurrentOrder=GetUnitCurrentOrder(UnitHandle) set OrderSequence=GetUnitSequenceOrder(PlayerForce,GetUnitSequenceIndex(PlayerNumber,UnitNumber,1)) if TempTimer==UNLIMITED then if CurrentOrder==0 and OrderSequence==HOLD then if TempCount==1 then return false else return true endif elseif CurrentOrder==OrderSequence then return false endif elseif TempTimer>0 then if CurrentOrder==OrderSequence then return false endif endif return true endfunction function AIPlayer_Unit_RespondOrder takes integer PlayerForce,integer PlayerNumber returns nothing local group TempGroup=CreateGroup() local unit UnitHandle local string TempString local integer UnitNumber if PlayerForce==SENTINEL then call GroupAddGroup(Sentinel_AIPlayer_UnitGroup[PlayerNumber],TempGroup) else call GroupAddGroup(Scourge_AIPlayer_UnitGroup[PlayerNumber],TempGroup) endif loop set UnitHandle=FirstOfGroup(TempGroup) exitwhen UnitHandle==null call GroupRemoveUnit(TempGroup,UnitHandle) set TempString=H2S(UnitHandle) set UnitNumber=GetStoInt(TempString,"UnitNumber") if UnitCurrentOrderChanged(PlayerForce,PlayerNumber,UnitNumber,UnitHandle) then call UnitDealNewOrder(PlayerForce,PlayerNumber,UnitNumber,UnitHandle) endif endloop call DestroyGroup(TempGroup) endfunction function CountGroupUnit takes integer PlayerForce,integer PlayerNumber returns integer local group TempGroup=CreateGroup() local integer UnitNumber=0 local unit TempUnit local string TempString if PlayerForce==SENTINEL then call GroupAddGroup(Sentinel_AIPlayer_UnitGroup[PlayerNumber],TempGroup) else call GroupAddGroup(Scourge_AIPlayer_UnitGroup[PlayerNumber],TempGroup) endif loop set TempUnit=FirstOfGroup(TempGroup) exitwhen TempUnit==null call GroupRemoveUnit(TempGroup,TempUnit) set UnitNumber=UnitNumber+1 set TempString=H2S(TempUnit) if IsStoInt(TempString,"UnitNumber")==false then call StoInt(TempString,"UnitNumber",UnitNumber) endif endloop call DestroyGroup(TempGroup) set TempGroup=null set TempUnit=null return UnitNumber endfunction function ClearAIPlayerUnitGroup takes integer PlayerForce,integer PlayerNumber returns nothing if PlayerForce==SENTINEL then call GroupClear(Sentinel_AIPlayer_UnitGroup[PlayerNumber]) else call GroupClear(Scourge_AIPlayer_UnitGroup[PlayerNumber]) endif endfunction function SetAIPlayerUnitGroupCount takes integer PlayerForce,integer PlayerNumber,integer TempInt returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_UnitGroup_Count[PlayerNumber]=TempInt else set Scourge_AIPlayer_UnitGroup_Count[PlayerNumber]=TempInt endif endfunction function GetAIPlayerUnitGroupCount takes integer PlayerForce,integer PlayerNumber returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_UnitGroup_Count[PlayerNumber] else return Scourge_AIPlayer_UnitGroup_Count[PlayerNumber] endif endfunction function GetHeroSequenceIndex takes integer PlayerNumber,integer HeroNumber,integer IndexNumber returns integer local integer Index set Index=HeroNumber+(PlayerNumber-1)*HERO_GROUP_MAX_LIMIT if IndexNumber!=0 then set Index=(Index-1)*ORDER_SEQUENCE_MAX_LIMIT+IndexNumber endif return Index endfunction function SetHeroSequenceCount takes integer PlayerForce,integer HeroIndex,integer TempCount returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_HeroGroup_Sequence_Count[HeroIndex]=TempCount else set Scourge_AIPlayer_HeroGroup_Sequence_Count[HeroIndex]=TempCount endif endfunction function SetHeroSequence takes integer PlayerForce,integer HeroSequenceIndex,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_HeroGroup_Order_Sequence[HeroSequenceIndex]=TempOrder set Sentinel_AIPlayer_HeroGroup_TargetUnit_Sequence[HeroSequenceIndex]=TempTargetUnit set Sentinel_AIPlayer_HeroGroup_TargetLoc_Sequence[HeroSequenceIndex]=TempTargetLoc set Sentinel_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex]=TempTimer set Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe[HeroSequenceIndex]=TempDescribe set Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe_Target[HeroSequenceIndex]=TempDescribeTarget else set Scourge_AIPlayer_HeroGroup_Order_Sequence[HeroSequenceIndex]=TempOrder set Scourge_AIPlayer_HeroGroup_TargetUnit_Sequence[HeroSequenceIndex]=TempTargetUnit set Scourge_AIPlayer_HeroGroup_TargetLoc_Sequence[HeroSequenceIndex]=TempTargetLoc set Scourge_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex]=TempTimer set Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe[HeroSequenceIndex]=TempDescribe set Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe_Target[HeroSequenceIndex]=TempDescribeTarget endif endfunction function SetHeroSequenceTimer takes integer PlayerForce,integer HeroSequenceIndex,real TempTimer returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex]=TempTimer else set Scourge_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex]=TempTimer endif endfunction function GetHeroSequenceCount takes integer PlayerForce,integer HeroIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Sequence_Count[HeroIndex] else return Scourge_AIPlayer_HeroGroup_Sequence_Count[HeroIndex] endif endfunction function GetHeroSequenceOrder takes integer PlayerForce,integer HeroSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Order_Sequence[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_Order_Sequence[HeroSequenceIndex] endif endfunction function GetHeroSequenceTargetUnit takes integer PlayerForce,integer HeroSequenceIndex returns unit if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_TargetUnit_Sequence[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_TargetUnit_Sequence[HeroSequenceIndex] endif endfunction function GetHeroSequenceTargetLoc takes integer PlayerForce,integer HeroSequenceIndex returns location if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_TargetLoc_Sequence[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_TargetLoc_Sequence[HeroSequenceIndex] endif endfunction function GetHeroSequenceTimer takes integer PlayerForce,integer HeroSequenceIndex returns real if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_Order_Sequence_Timer[HeroSequenceIndex] endif endfunction function GetHeroSequenceDescribe takes integer PlayerForce,integer HeroSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe[HeroSequenceIndex] endif endfunction function GetHeroSequenceDescribeTarget takes integer PlayerForce,integer HeroSequenceIndex returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Order_Sequence_Describe_Target[HeroSequenceIndex] else return Scourge_AIPlayer_HeroGroup_Order_Sequence_Describe_Target[HeroSequenceIndex] endif endfunction function ClearHeroSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,boolean CompletelyClear returns nothing local integer TempInt local integer TempCount local integer HeroIndex local integer HeroSequenceIndex set HeroIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,0) if CompletelyClear==false then call SetHeroSequenceCount(PlayerForce,HeroIndex,1) endif set TempInt=1 set TempCount=GetHeroSequenceCount(PlayerForce,HeroIndex) loop set HeroSequenceIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempInt) call SetHeroSequence(PlayerForce,HeroSequenceIndex,HOLD,null,null,UNLIMITED,WAIT,NONE) set TempInt=TempInt+1 exitwhen TempInt>TempCount endloop endfunction function ReplaceHeroSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer HeroSequenceIndex set HeroSequenceIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,1) call SetHeroSequence(PlayerForce,HeroSequenceIndex,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) endfunction function InsertHeroSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer HeroIndex local integer HeroSequenceIndex1 local integer HeroSequenceIndex2 local integer HeroSequenceOrder local unit HeroSequenceTargetUnit local location HeroSequenceTargetLoc local real HeroSequenceTimer local integer HeroSequenceDescribe local integer HeroSequenceDescribeTarget local integer TempCount set HeroIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,0) set TempCount=GetHeroSequenceCount(PlayerForce,HeroIndex)+1 call SetHeroSequenceCount(PlayerForce,HeroIndex,TempCount) loop exitwhen TempCount==1 set HeroSequenceIndex1=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempCount) set HeroSequenceIndex2=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempCount-1) set HeroSequenceOrder=GetHeroSequenceOrder(PlayerForce,HeroSequenceIndex2) set HeroSequenceTargetUnit=GetHeroSequenceTargetUnit(PlayerForce,HeroSequenceIndex2) set HeroSequenceTargetLoc=GetHeroSequenceTargetLoc(PlayerForce,HeroSequenceIndex2) set HeroSequenceTimer=GetHeroSequenceTimer(PlayerForce,HeroSequenceIndex2) set HeroSequenceDescribe=GetHeroSequenceDescribe(PlayerForce,HeroSequenceIndex2) set HeroSequenceDescribeTarget=GetHeroSequenceDescribeTarget(PlayerForce,HeroSequenceIndex2) call SetHeroSequence(PlayerForce,HeroSequenceIndex1,HeroSequenceOrder,HeroSequenceTargetUnit,HeroSequenceTargetLoc,HeroSequenceTimer,HeroSequenceDescribe,HeroSequenceDescribeTarget) set TempCount=TempCount-1 endloop call SetHeroSequence(PlayerForce,HeroSequenceIndex2,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) set HeroSequenceTargetUnit=null set HeroSequenceTargetLoc=null endfunction function AddHeroSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,integer TempOrder,unit TempTargetUnit,location TempTargetLoc,real TempTimer,integer TempDescribe,integer TempDescribeTarget returns nothing local integer HeroIndex local integer HeroSequenceIndex local integer TempCount local integer OrderSequence set HeroIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,0) set TempCount=GetHeroSequenceCount(PlayerForce,HeroIndex)+1 set HeroSequenceIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempCount) call SetHeroSequence(PlayerForce,HeroSequenceIndex,TempOrder,TempTargetUnit,TempTargetLoc,TempTimer,TempDescribe,TempDescribeTarget) call SetHeroSequenceCount(PlayerForce,HeroIndex,TempCount) endfunction function NextHeroSequenceOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber returns nothing local integer TempInt local integer TempCount local integer HeroIndex local integer HeroSequenceIndex1 local integer HeroSequenceIndex2 local integer HeroSequenceOrder local unit HeroSequenceTargetUnit local location HeroSequenceTargetLoc local real HeroSequenceTimer local integer HeroSequenceDescribe local integer HeroSequenceDescribeTarget set HeroIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,0) set TempCount=GetHeroSequenceCount(PlayerForce,HeroIndex) if TempCount==1 then call ClearHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,false) else set TempInt=2 loop set HeroSequenceIndex1=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempInt-1) set HeroSequenceIndex2=GetHeroSequenceIndex(PlayerNumber,HeroNumber,TempInt) set HeroSequenceOrder=GetHeroSequenceOrder(PlayerForce,HeroSequenceIndex2) set HeroSequenceTargetUnit=GetHeroSequenceTargetUnit(PlayerForce,HeroSequenceIndex2) set HeroSequenceTargetLoc=GetHeroSequenceTargetLoc(PlayerForce,HeroSequenceIndex2) set HeroSequenceTimer=GetHeroSequenceTimer(PlayerForce,HeroSequenceIndex2) set HeroSequenceDescribe=GetHeroSequenceDescribe(PlayerForce,HeroSequenceIndex2) set HeroSequenceDescribeTarget=GetHeroSequenceDescribeTarget(PlayerForce,HeroSequenceIndex2) call SetHeroSequence(PlayerForce,HeroSequenceIndex1,HeroSequenceOrder,HeroSequenceTargetUnit,HeroSequenceTargetLoc,HeroSequenceTimer,HeroSequenceDescribe,HeroSequenceDescribeTarget) set TempInt=TempInt+1 exitwhen TempInt>TempCount endloop call SetHeroSequence(PlayerForce,HeroSequenceIndex2,HOLD,null,null,UNLIMITED,WAIT,NONE) call SetHeroSequenceCount(PlayerForce,HeroIndex,TempCount-1) endif set HeroSequenceTargetUnit=null set HeroSequenceTargetLoc=null endfunction function HeroSequenceExecuteOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,unit HeroHandle returns nothing local integer TempIndex local integer TempOrder local unit TempTargetUnit local location TempTargetLoc set TempIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,1) set TempOrder=GetHeroSequenceOrder(PlayerForce,TempIndex) set TempTargetUnit=GetHeroSequenceTargetUnit(PlayerForce,TempIndex) set TempTargetLoc=GetHeroSequenceTargetLoc(PlayerForce,TempIndex) if TempTargetUnit==null then if TempTargetLoc==null then call IssueImmediateOrderById(HeroHandle,TempOrder) else call IssuePointOrderByIdLoc(HeroHandle,TempOrder,TempTargetLoc) endif else call IssueTargetOrderById(HeroHandle,TempOrder,TempTargetUnit) endif set TempTargetUnit=null set TempTargetLoc=null endfunction function HeroDealNewOrder takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,unit HeroHandle returns nothing local integer CurrentOrder=GetUnitCurrentOrder(HeroHandle) if IsOrderDisabled(CurrentOrder) then call ClearHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,true) elseif IsOrderStopped(CurrentOrder) then call NextHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber) endif call HeroSequenceExecuteOrder(PlayerForce,PlayerNumber,HeroNumber,HeroHandle) endfunction function HeroCurrentOrderChanged takes integer PlayerForce,integer PlayerNumber,integer HeroNumber,unit HeroHandle returns boolean local integer CurrentOrder local integer OrderSequence local integer HeroSequenceIndex=GetHeroSequenceIndex(PlayerNumber,HeroNumber,1) local integer TempCount=GetHeroSequenceCount(PlayerForce,GetHeroSequenceIndex(PlayerNumber,HeroNumber,0)) local real TempTimer=GetHeroSequenceTimer(PlayerForce,HeroSequenceIndex) set TempTimer=TempTimer-AIPlayer_TimeSize call SetHeroSequenceTimer(PlayerForce,HeroSequenceIndex,TempTimer) set CurrentOrder=GetUnitCurrentOrder(HeroHandle) set OrderSequence=GetHeroSequenceOrder(PlayerForce,GetHeroSequenceIndex(PlayerNumber,HeroNumber,1)) if TempTimer==UNLIMITED then if CurrentOrder==0 and OrderSequence==HOLD then if TempCount==1 then return false else return true endif elseif CurrentOrder==OrderSequence then return false endif elseif TempTimer>0 then if CurrentOrder==OrderSequence then return false endif endif return true endfunction function AIPlayer_Hero_RespondOrder takes integer PlayerForce,integer PlayerNumber returns nothing local group TempGroup=CreateGroup() local unit HeroHandle local string TempString local integer HeroNumber if PlayerForce==SENTINEL then call GroupAddGroup(Sentinel_AIPlayer_HeroGroup[PlayerNumber],TempGroup) else call GroupAddGroup(Scourge_AIPlayer_HeroGroup[PlayerNumber],TempGroup) endif loop set HeroHandle=FirstOfGroup(TempGroup) exitwhen HeroHandle==null call GroupRemoveUnit(TempGroup,HeroHandle) set TempString=H2S(HeroHandle) set HeroNumber=GetStoInt(TempString,"HeroNumber") if HeroCurrentOrderChanged(PlayerForce,PlayerNumber,HeroNumber,HeroHandle) then call HeroDealNewOrder(PlayerForce,PlayerNumber,HeroNumber,HeroHandle) endif endloop call DestroyGroup(TempGroup) endfunction function CountGroupHero takes integer PlayerForce,integer PlayerNumber returns integer local group TempGroup=CreateGroup() local integer HeroNumber=0 local unit TempUnit local string TempString if PlayerForce==SENTINEL then call GroupAddGroup(Sentinel_AIPlayer_HeroGroup[PlayerNumber],TempGroup) else call GroupAddGroup(Scourge_AIPlayer_HeroGroup[PlayerNumber],TempGroup) endif loop set TempUnit=FirstOfGroup(TempGroup) exitwhen TempUnit==null call GroupRemoveUnit(TempGroup,TempUnit) set HeroNumber=HeroNumber+1 set TempString=H2S(TempUnit) if IsStoInt(TempString,"HeroNumber")==false then call StoInt(TempString,"HeroNumber",HeroNumber) endif endloop call DestroyGroup(TempGroup) set TempGroup=null set TempUnit=null return HeroNumber endfunction function ClearAIPlayerHeroGroup takes integer PlayerForce,integer PlayerNumber returns nothing if PlayerForce==SENTINEL then call GroupClear(Sentinel_AIPlayer_HeroGroup[PlayerNumber]) else call GroupClear(Scourge_AIPlayer_HeroGroup[PlayerNumber]) endif endfunction function SetAIPlayerHeroGroupCount takes integer PlayerForce,integer PlayerNumber,integer TempInt returns nothing if PlayerForce==SENTINEL then set Sentinel_AIPlayer_HeroGroup_Count[PlayerNumber]=TempInt else set Scourge_AIPlayer_HeroGroup_Count[PlayerNumber]=TempInt endif endfunction function GetAIPlayerHeroGroupCount takes integer PlayerForce,integer PlayerNumber returns integer if PlayerForce==SENTINEL then return Sentinel_AIPlayer_HeroGroup_Count[PlayerNumber] else return Scourge_AIPlayer_HeroGroup_Count[PlayerNumber] endif endfunction function AIPlayerEnumUnits takes integer PlayerForce,integer PlayerNumber,player PlayerHandle returns nothing if PlayerForce==SENTINEL then call GroupEnumUnitsOfPlayer(Sentinel_AIPlayer_UnitGroup[PlayerNumber],PlayerHandle,Condition(function Filter_True)) else call GroupEnumUnitsOfPlayer(Scourge_AIPlayer_UnitGroup[PlayerNumber],PlayerHandle,Condition(function Filter_True)) endif endfunction function AIPlayer_FilterGroup takes integer PlayerForce,integer PlayerNumber returns nothing local group TempGroup=CreateGroup() local unit TempUnit if PlayerForce==SENTINEL then call GroupAddGroup(Sentinel_AIPlayer_UnitGroup[PlayerNumber],TempGroup) else call GroupAddGroup(Scourge_AIPlayer_UnitGroup[PlayerNumber],TempGroup) endif loop set TempUnit=FirstOfGroup(TempGroup) exitwhen TempUnit==null call GroupRemoveUnit(TempGroup,TempUnit) if IsUnitAliveBJ(TempUnit) and GetUnitTypeId(TempUnit)!='ncop' then if IsUnitType(TempUnit,UNIT_TYPE_HERO)then if PlayerForce==SENTINEL then call GroupRemoveUnit(Sentinel_AIPlayer_UnitGroup[PlayerNumber],TempUnit) call GroupAddUnit(Sentinel_AIPlayer_HeroGroup[PlayerNumber],TempUnit) else call GroupRemoveUnit(Scourge_AIPlayer_UnitGroup[PlayerNumber],TempUnit) call GroupAddUnit(Scourge_AIPlayer_HeroGroup[PlayerNumber],TempUnit) endif endif else if PlayerForce==SENTINEL then call GroupRemoveUnit(Sentinel_AIPlayer_UnitGroup[PlayerNumber],TempUnit) else call GroupRemoveUnit(Scourge_AIPlayer_UnitGroup[PlayerNumber],TempUnit) endif endif endloop call DestroyGroup(TempGroup) set TempGroup=null endfunction function AIPlayer_GroupCount takes integer PlayerForce,integer PlayerNumber returns nothing local player AIPlayer_PlayerHandle set AIPlayer_PlayerHandle=GetAIPlayerHandle(PlayerForce,PlayerNumber) call ClearAIPlayerUnitGroup(PlayerForce,PlayerNumber) call ClearAIPlayerHeroGroup(PlayerForce,PlayerNumber) call AIPlayerEnumUnits(PlayerForce,PlayerNumber,AIPlayer_PlayerHandle) call AIPlayer_FilterGroup(PlayerForce,PlayerNumber) call SetAIPlayerUnitGroupCount(PlayerForce,PlayerNumber,CountGroupUnit(PlayerForce,PlayerNumber)) call SetAIPlayerHeroGroupCount(PlayerForce,PlayerNumber,CountGroupHero(PlayerForce,PlayerNumber)) set AIPlayer_PlayerHandle=null endfunction function AIPlayer_Responding takes nothing returns nothing local integer PlayerForce local integer PlayerNumber=1 loop set PlayerForce=SENTINEL if IsPlayerAI(PlayerForce,PlayerNumber)==true then call AIPlayer_GroupCount(PlayerForce,PlayerNumber) if GetAIPlayerUnitGroupCount(PlayerForce,PlayerNumber)>0 then call AIPlayer_Unit_RespondOrder(PlayerForce,PlayerNumber) endif if GetAIPlayerHeroGroupCount(PlayerForce,PlayerNumber)>0 then call AIPlayer_Hero_RespondOrder(PlayerForce,PlayerNumber) endif endif set PlayerForce=SCOURGE if IsPlayerAI(PlayerForce,PlayerNumber)==true then call AIPlayer_GroupCount(PlayerForce,PlayerNumber) if GetAIPlayerUnitGroupCount(PlayerForce,PlayerNumber)>0 then call AIPlayer_Unit_RespondOrder(PlayerForce,PlayerNumber) endif if GetAIPlayerHeroGroupCount(PlayerForce,PlayerNumber)>0 then call AIPlayer_Hero_RespondOrder(PlayerForce,PlayerNumber) endif else endif set PlayerNumber=PlayerNumber+1 exitwhen PlayerNumber>5 endloop endfunction function AIPlayer_Unit_Clear takes nothing returns nothing if IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO)==false or IsUnitIllusion(GetTriggerUnit())==true then call ClearSto(H2S(GetTriggerUnit())) endif endfunction function AIPlayer_TakeOver_HeroeControlling takes nothing returns nothing local integer i=1 local trigger t local string TempString loop set Sentinel_AIPlayer_UnitGroup_Count[i]=0 set Sentinel_AIPlayer_HeroGroup_Count[i]=0 if IsPlayerAI(SENTINEL,i)==true then set Sentinel_AIPlayer_UnitGroup[i]=CreateGroup() set TempString=H2S(Sentinel_AIPlayer_UnitGroup[i]) call StoInt(TempString,"PlayerForce",SENTINEL) set Sentinel_AIPlayer_HeroGroup[i]=CreateGroup() set TempString=H2S(Sentinel_AIPlayer_HeroGroup[i]) call StoInt(TempString,"PlayerForce",SENTINEL) set Sentinel_AIPlayer_Nearby_AllyHeroGroup[i]=CreateGroup() set Sentinel_AIPlayer_Nearby_EnemyHeroGroup[i]=CreateGroup() set Sentinel_AIPlayer_Nearby_AllyCreepGroup[i]=CreateGroup() set Sentinel_AIPlayer_Nearby_EnemyCreepGroup[i]=CreateGroup() set Sentinel_AIPlayer_Nearby_AllyStructureGroup[i]=CreateGroup() set Sentinel_AIPlayer_Nearby_EnemyStructureGroup[i]=CreateGroup() endif set Scourge_AIPlayer_UnitGroup_Count[i]=0 set Scourge_AIPlayer_HeroGroup_Count[i]=0 if IsPlayerAI(SCOURGE,i)==true then set Scourge_AIPlayer_UnitGroup[i]=CreateGroup() set TempString=H2S(Scourge_AIPlayer_UnitGroup[i]) call StoInt(TempString,"PlayerForce",SCOURGE) set Scourge_AIPlayer_HeroGroup[i]=CreateGroup() set TempString=H2S(Scourge_AIPlayer_HeroGroup[i]) call StoInt(TempString,"PlayerForce",SCOURGE) set Scourge_AIPlayer_Nearby_AllyHeroGroup[i]=CreateGroup() set Scourge_AIPlayer_Nearby_EnemyHeroGroup[i]=CreateGroup() set Scourge_AIPlayer_Nearby_AllyCreepGroup[i]=CreateGroup() set Scourge_AIPlayer_Nearby_EnemyCreepGroup[i]=CreateGroup() set Scourge_AIPlayer_Nearby_AllyStructureGroup[i]=CreateGroup() set Scourge_AIPlayer_Nearby_EnemyStructureGroup[i]=CreateGroup() endif set i=i+1 exitwhen i>5 endloop set t=CreateTrigger() call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_DEATH) call TriggerAddAction(t,function AIPlayer_Unit_Clear) set t=null endfunction function AIPlayer_CommandCenter takes nothing returns nothing local integer CurrentTime=GetTriggerEvalCount(AIPlayer_Trigger) local integer PlayerNumber=2 local integer PlayerForce local integer HeroNumber=1 local integer HeroIndex if CurrentTime>AIPlayer_TimeSize*10 then set AIPlayer_Respond_Trigger=CreateTrigger() call TriggerRegisterTimerEvent(AIPlayer_Respond_Trigger,AIPlayer_TimeScale,true) call TriggerAddAction(AIPlayer_Respond_Trigger,function AIPlayer_Responding) call DisableTrigger(AIPlayer_Trigger) set PlayerForce=SENTINEL loop if IsPlayerAI(PlayerForce,PlayerNumber)==true then call ClearHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,false) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_TopLane_Sentinel_Entrance[1]),UNLIMITED,MOVETO,TOPLANE) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_Riverway_Entrance[1]),UNLIMITED,MOVETO,RIVERWAY) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_PowerUP[1]),UNLIMITED,MOVETO,POWERUP) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_MiddleLane_CreepMeeting),UNLIMITED,MOVETO,MIDDLELANE) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_PowerUP[2]),UNLIMITED,MOVETO,POWERUP) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_MiddleLane_Sentinel_Entrance[1]),UNLIMITED,MOVETO,MIDDLELANE) call AddHeroSequenceOrder(PlayerForce,PlayerNumber,HeroNumber,RIGHTCLICK,null,RectCenter2Loc(Rect_Fountain_Sentinel),UNLIMITED,MOVETO,FOUNTAIN) endif set PlayerNumber=PlayerNumber+1 exitwhen PlayerNumber>5 endloop endif endfunction function AIPlayer_Start_HeroControlling takes nothing returns nothing set AIPlayer_Trigger=CreateTrigger() call TriggerRegisterTimerEvent(AIPlayer_Trigger,AIPlayer_TimeScale,true) call TriggerAddAction(AIPlayer_Trigger,function AIPlayer_CommandCenter) endfunction function StartAI takes nothing returns nothing call DestroyTrigger(GetTriggeringTrigger()) set AI_Start=true call AIPlayer_Filter_Player() call AIPlayer_Set_Character() call AIPlayer_Choose_Hero() call AIPlayer_MakeSure_ItemBuild() call AIPlayer_TakeOver_HeroeControlling() call AIPlayer_Start_HeroControlling() endfunction function InitAIData_Hero takes nothing returns nothing endfunction function InitAIData_Map takes nothing returns nothing set Rect_PowerUP[1]=Rect(-3104,2176,-2304,1632) set Rect_PowerUP[2]=Rect(2816,-2944,3520,-3296) set Rect_Roshan=Rect(2112,-448,2880,-1120) set Rect_Riverway_Entrance[1]=Rect(-5920,3168,-5312,2336) set Rect_Riverway_Entrance[2]=Rect(5024,-2976,5632,-3552) set Rect_TopLane_CreepMeeting=Rect(-6560,6112,-5344,4864) set Rect_MiddleLane_CreepMeeting=Rect(-1440,64,64,-1088) set Rect_BottomLane_CreepMeeting=Rect(4896,6272,-7040,-5792) set Rect_Riverway_Sentinel_Crossing[1]=Rect(-3168,1600,-2752,1280) set Rect_Riverway_Sentinel_Crossing[2]=Rect(-2240,864,-1696,576) set Rect_Riverway_Sentinel_Crossing[3]=Rect(-1440,-512,-640,-1088) set Rect_Riverway_Sentinel_Crossing[4]=Rect(1984,-2720,2368,-2976) set Rect_Fountain_Sentinel=Rect(-7260,-6500,-6560,-7230) set Rect_TopLane_Sentinel_Entrance[1]=Rect(-6880,-3328,-5824,-3744) set Rect_TopLane_Sentinel_Entrance[2]=Rect(-6848,-2176,-5952,-2400) set Rect_MiddleLane_Sentinel_Entrance[1]=Rect(-4544,-4288,-3872,-4928) set Rect_MiddleLane_Sentinel_Entrance[2]=Rect(-3936,-3168,-3072,-4128) set Rect_BottomLane_Sentinel_Entrance[1]=Rect(-3360,-6336,-3040,-7360) set Rect_BottomLane_Sentinel_Entrance[2]=Rect(-1376,-6720,-1152,-7296) set Rect_NeutralCreep_Sentinel[1]=Rect(2848,-3552,3424,-4288) set Rect_NeutralCreep_Sentinel[2]=Rect(2688,-4960,3392,-5568) set Rect_NeutralCreep_Sentinel[3]=Rect(1280,-3840,1984,-4480) set Rect_NeutralCreep_Sentinel[4]=Rect(-576,-3232,-64,-3680) set Rect_NeutralCreep_Sentinel[5]=Rect(-1440,-4256,-704,-4832) set Rect_NeutralCreep_Sentinel[6]=Rect(-3360,64,-2688,-608) set Rect_NeutralCreep_Sentinel_Entrance[1]=Rect(5376,-3648,5472,-4032) set Rect_NeutralCreep_Sentinel_Entrance[2]=Rect(5184,-4960,5344,-5728) set Rect_NeutralCreep_Sentinel_Entrance[3]=Rect(3456,-6144,4288,-6304) set Rect_NeutralCreep_Sentinel_Entrance[4]=Rect(2112,-3488,2496,-3680) set Rect_NeutralCreep_Sentinel_Entrance[5]=Rect(-480,-6048,1984,-6176) set Rect_NeutralCreep_Sentinel_Entrance[6]=Rect(896,-2752,1120,-3136) set Rect_NeutralCreep_Sentinel_Entrance[7]=Rect(32,-2880,256,-3264) set Rect_NeutralCreep_Sentinel_Entrance[8]=Rect(-672,-1376,-512,-2016) set Rect_NeutralCreep_Sentinel_Entrance[9]=Rect(-1216,-6496,-960,-6592) set Rect_NeutralCreep_Sentinel_Entrance[10]=Rect(-1760,-2624,-1376,-2944) set Rect_NeutralCreep_Sentinel_Entrance[11]=Rect(-2528,-3648,-2400,-4448) set Rect_NeutralCreep_Sentinel_Entrance[12]=Rect(-2496,224,-2112,0) set Rect_NeutralCreep_Sentinel_Entrance[13]=Rect(-3648,-1888,-3104,-2336) set Rect_NeutralCreep_Sentinel_Entrance[14]=Rect(-5664,-1440,-5504,-2464) set Rect_NeutralShop_Sentinel[1]=Rect(6752,-3936,7488,-4704) set Rect_NeutralShop_Sentinel[2]=Rect(-4896,1312,-4064,608) set Rect_NeutralShop_Sentinel_Entrance[1]=Rect(-3456,1088,-3264,832) set Rect_NeutralShop_Sentinel_Entrance[2]=Rect(-3936,-960,-3584,-1312) set Rect_NeutralShop_Sentinel_Entrance[3]=Rect(-5632,544,-5376,-32) set Rect_Riverway_Scourge_Crossing[1]=Rect(-3296,3744,-2624,3360) set Rect_Riverway_Scourge_Crossing[2]=Rect(-2144,3392,-1920,3008) set Rect_Riverway_Scourge_Crossing[3]=Rect(-1376,1216,-1152,832) set Rect_Riverway_Scourge_Crossing[4]=Rect(-576,64,64,-704) set Rect_Riverway_Scourge_Crossing[5]=Rect(2144,-1504,3552,-2048) set Rect_Fountain_Scourge=Rect(6150,6400,6950,5760) set Rect_TopLane_Scourge_Entrance[1]=Rect(1952,6336,2368,5312) set Rect_TopLane_Scourge_Entrance[2]=Rect(1120,6336,1376,5312) set Rect_MiddleLane_Scourge_Entrance[1]=Rect(3264,3392,3904,2784) set Rect_MiddleLane_Scourge_Entrance[2]=Rect(2528,2528,3424,1696) set Rect_BottomLane_Scourge_Entrance[1]=Rect(5952,2080,6848,1792) set Rect_BottomLane_Scourge_Entrance[2]=Rect(5952,864,6720,576) set Rect_NeutralCreep_Scourge[1]=Rect(-4704,3840,-4000,3200) set Rect_NeutralCreep_Scourge[2]=Rect(-3392,4608,-2688,4160) set Rect_NeutralCreep_Scourge[3]=Rect(-1824,2624,-1344,2144) set Rect_NeutralCreep_Scourge[4]=Rect(-640,3744,-64,3264) set Rect_NeutralCreep_Scourge[5]=Rect(960,3296,1472,2880) set Rect_NeutralCreep_Scourge[6]=Rect(4000,-2112,4928,-2816) set Rect_NeutralCreep_Scourge_Entrance[1]=Rect(-5600,4864,-5376,3264) set Rect_NeutralCreep_Scourge_Entrance[2]=Rect(-3680,5472,-3072,5216) set Rect_NeutralCreep_Scourge_Entrance[3]=Rect(-1472,3744,-832,3456) set Rect_NeutralCreep_Scourge_Entrance[4]=Rect(-992,2880,-768,2496) set Rect_NeutralCreep_Scourge_Entrance[5]=Rect(-960,5216,1152,4992) set Rect_NeutralCreep_Scourge_Entrance[6]=Rect(-448,1312,64,928) set Rect_NeutralCreep_Scourge_Entrance[7]=Rect(1152,2336,1504,1696) set Rect_NeutralCreep_Scourge_Entrance[8]=Rect(1184,4416,1504,3648) set Rect_NeutralCreep_Scourge_Entrance[9]=Rect(5024,-352,5152,-1632) set Rect_NeutralCreep_Scourge_Entrance[10]=Rect(3616,-1440,3872,1888) set Rect_NeutralShop_Scourge[1]=Rect(-7360,4608,-6720,3584) set Rect_NeutralShop_Scourge[2]=Rect(3008,160,3552,-352) set Rect_NeutralShop_Scourge_Entrance[1]=Rect(3392,992,4032,704) set Rect_NeutralShop_Scourge_Entrance[2]=Rect(4672,256,4864,-192) set Rect_NeutralShop_Scourge_Entrance[3]=Rect(3904,-640,4352,-992) endfunction function main takes nothing returns nothing local integer O00I1I=0 local integer O00III local trigger t call InitAIData_Map() call InitAIData_Hero() set t=CreateTrigger() call TriggerRegisterTimerEvent(t,18,false) call TriggerAddAction(t,function StartAI) set t=null if(GetPlayerController(Player(O00III))==MAP_CONTROL_COMPUTER and GetPlayerSlotState(Player(O00III))==PLAYER_SLOT_STATE_PLAYING)then set O00I1I=O00I1I+1 endif endfunction |
暴雪英霸是未來很看好的遊戲! 站長最近都玩 英雄聯盟 或 Mstar 。 以前站長擅長幫熱門的 魔獸3 地圖加入 AI, 可以和電腦英雄對戰,電腦懂的和人對話。
##EasyReadMore##
2009年12月13日 星期日
基於神經網絡的人機對抗人工智能系統 part3
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言