Inscrit le: 12 Sep 2009 Messages: 801 Sujets: 64 Spécialité en worldedit: Ne pas.
Posté le: 19/06/10 21:34 Sujet du message: Comment faire une IA intelligente
Bonjour à tous,
J'aimerais si possible un tutoriel disant comment faire pour faire une IA intelligente. (L'IA de Blizzard est bien conne... : elle n'attaque pas par le chemin le plus court...)
Ou alors quelqu'un qui me dit pourquoi mes zombies n'attaquent pas tous à l'endroit où ils doivent attaquer, ils partent aux autres spots d'attaque... (Et du coup ils attaquent tous au même endroit.) _________________
Inscrit le: 21 Fév 2010 Messages: 1785 Sujets: 22 Spécialité en worldedit: La modestie Médailles: 1 (En savoir plus...)
Posté le: 20/06/10 13:08 Sujet du message:
Euh, t'as 2 façons de faire une IA.
Soit c'est une IA de type mélée ou n'importe quoi d'autre qui utilise les bâtiments, la construction d'unité et la formation de groupes d'attaque/défense et ça se fait plus facilement avec un script IA.
Soit c'est une IA pour un jeu dont le gameplay est différent de celui de W3 et là, faut faire ça en jass/éditeur de déclencheurs. Dans ce cas, ça dépend totalement du type de map et ce serait plutôt à inclure dans un tuto qui apprend comment créer ce type de map (et pas seulement son IA).
Comme t'es dans le second cas, il faut que tu fasses ça par déclencheur...
De base, les ennemis ont une IA un peu particulière (qui peut se cumuler avec un script IA, je crois) : ils lancent leurs sorts selon certains critères et retournent automatiquement à l'endroit où ils ont été créés. Il te faut donc donner des ordres périodiquement à tes zombies. _________________
Inscrit le: 12 Sep 2009 Messages: 801 Sujets: 64 Spécialité en worldedit: Ne pas.
Posté le: 21/06/10 11:24 Sujet du message:
Ouais sauf que mes zombies, même avec des points où ils doivent passer avant d'attaquer leur spot d'attaque, puis la ville passent tous au même endroit...
Ca me désespère de plus en plus. _________________
Inscrit le: 30 Jan 2009 Messages: 669 Sujets: 56 Spécialité en worldedit: Faire des bug Médailles: 1 (En savoir plus...)
Posté le: 21/06/10 11:54 Sujet du message:
T'as fait quoi, des déclos ? Peut être que l'ont pourrais mieux t'aider si tu nous montrais ta map ou tes déclo, ou n'importe quoi, mais quelque choses sur lequel on puisse t'aider. Parce que là, ça me semble plus du bug que de l'IA ... _________________
Inscrit le: 12 Sep 2009 Messages: 801 Sujets: 64 Spécialité en worldedit: Ne pas.
Posté le: 21/06/10 12:06 Sujet du message:
Tout simplement :
Evenement :
Game time - elapsed time égal à X seconds
Pas de conditions
Action :
Create X zombies for player 12 at center of (MAregionDErepop)
Groupe unité - Pick every unit in MAregionDErepop and do - unité - order to picked unit to move to MAregionATTAQUE
Cétout (Le gui est écrit approximativement[/Gui] selon mes souvenirs.) _________________
Inscrit le: 12 Sep 2009 Messages: 801 Sujets: 64 Spécialité en worldedit: Ne pas.
Posté le: 21/06/10 14:26 Sujet du message:
Enfin l'action c'est attaquer avancer hein.
Sinon oui, tu pourras mettre 20000² creeps ils viendront tous.
Non je suis sur de ne pas m'être trompé de région, déjà vérifié et re-vérifié.
T'inquiète pas pour les actions elles le font toutes, vérifié IG avec des fermes intuables avec la portée maxi, ils se déplacent bien, mais au mauvais endroit... _________________
Si tu vas sur http://jk2pach.1fr1.net dans la rubrique open-source j'ai posté certains de mes systèmes de Restricted Complex 601. Dont, entre autres, le système qui gère les déplacement des creeps.
Les principes globaux sont:
-Les joueurs (jass) 11, 13 et 14 gèrent les creeps. Empiriquement, sur Warcraft III, pour gérer beaucoup d'unités AI, il vaut mieux les séparer en plusieurs joueurs. (Sur RC y'a jusqu'à 120 creeps en même temps).
-Le spawn des creeps est fait à partir de région qui changent en fonction des quêtes.
-Les creeps sont invoqués également de façon semi-aléatoire (autour des héros, hors des bases) comme vagues secondaires
-Troisième type de vagues, des rushs (une troupe compacte d'unités aériennes ou cavalerie)
Le système permet également de faire attaquer les creeps vers la cible générale du jeu (n'importe quelle unité) de façon régulière; si cette cible est détruite ou morte, il va attribuer à chaque creeps une cible unique (un héros) et les creeps vont donc poursuivre les héros vivants du jeu.
Il est complètement personnalisable: tu peux modifier le type d'unités invoquées, les régions de spawn, la vitesse d'invocation et j'en passe en pleine partie (parce que pour les besoins de Restricted Complex 601 tout doit être modifiable en cours de jeu).
Bref, jette un regard au besoin, pose-moi des questions si nécessaire (pour les besoins de la carte il renvoit à beaucoup d'autres libraries en Vjass). _________________
private function SetSpawnVariables takes nothing returns nothing
local integer i = 0
set BaseRect[i]=gg_rct_ExternalOutpost
set i = i + 1
set BaseRect[i]=gg_rct_Barracks
set i = i + 1
set BaseRect[i]=gg_rct_ShipBase
set i = i + 1
set BaseRect[i]=gg_rct_AirfieldBase
set i = i + 1
set BaseRect[i]=gg_rct_MechanoidsFacilities
set i = i + 1
set BaseRect[i]=gg_rct_TeleporterBase
set i = i + 1
set BaseRect[i]=gg_rct_ContainerBase
set BaseRectMax = i
set i = 1
set SpawnRect[i]=gg_rct_Spawn001
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn002
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn003
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn004
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn005
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn006
set SpawnIsCave[i]=true
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn007
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn008
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn009
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn010
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn011
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn012
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn013
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn014
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn015
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn016
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn017
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn018
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn019
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn020
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn021
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn022
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn023
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn024
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn025
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn026
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn027
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn028
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn029
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn030
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn031
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn032
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn033
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn034
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn035
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn036
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn037
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn038
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn039
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn040
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn041
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn042
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn043
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn044
set SpawnIsCave[i]=false
set i = i + 1
set SpawnRect[i]=gg_rct_Spawn045
set SpawnIsCave[i]=false
set SpawnMax = i
endfunction
function CreepsCheckHeroAmount takes nothing returns integer
local integer i = 0
local integer k = 0
loop
exitwhen i > MAXPLAYER
if not (IsUnitType(Hero[i],UNIT_TYPE_DEAD)) and Hero[i]!= null then
set k = k + 1
endif
set i = i + 1
endloop
return k
endfunction
function CreepsRemoveUnitFromGroup takes unit creeps returns nothing
set CreepsPop = CreepsPop - 1
if IsUnitInGroup(creeps,NormalGroup) then
call GroupRemoveUnit(NormalGroup,creeps)
set NormalPop = NormalPop - 1
elseif IsUnitInGroup(creeps,RushGroup) then
call GroupRemoveUnit(RushGroup,creeps)
set RushPop = RushPop - 1
elseif IsUnitInGroup(creeps,HeroGroup) then
call GroupRemoveUnit(HeroGroup,creeps)
set HeroPop = HeroPop - 1
endif
endfunction
private function SetRandomHeroTarget takes nothing returns integer
local integer i = 0
local integer random = 0
loop
exitwhen i > MAXPLAYER
set random = GetRandomInt(0,MAXPLAYER)
if not (IsUnitType(Hero[i],UNIT_TYPE_DEAD)) and Hero[i]!=null then
return random
endif
set i = i + 1
endloop
return random
endfunction
private struct s_targetId
integer targetId = 0
private static method createFilter takes unit u returns boolean
return (GetOwningPlayer(u)==Player(OWNER_NORMAL) or GetOwningPlayer(u)==Player(OWNER_RUSH) or GetOwningPlayer(u)==Player(OWNER_HERO)) and not (IsUnitType(u,UNIT_TYPE_TAUREN))
endmethod
private method onCreate takes nothing returns nothing
local integer ownerId = GetPlayerId(GetOwningPlayer(me))
set CreepsPop = CreepsPop + 1
if ownerId == OWNER_NORMAL then
set NormalPop = NormalPop + 1
call GroupAddUnit(NormalGroup,me)
elseif ownerId == OWNER_RUSH then
set RushPop = RushPop + 1
call GroupAddUnit(RushGroup,me)
elseif ownerId == OWNER_HERO then
set HeroPop = HeroPop + 1
call GroupAddUnit(HeroGroup,me)
endif
if not (IsUnitType(GeneralTarget,UNIT_TYPE_DEAD)) and GeneralTarget!= null then
call IssuePointOrder(me,"attack",GetUnitX(GeneralTarget)+GetRandomReal(-500.,500.),GetUnitY(GeneralTarget)+GetRandomReal(-500.,500.))
else
if IsUnitType(Hero[.targetId],UNIT_TYPE_DEAD) or Hero[.targetId]==null then
set .targetId = SetRandomHeroTarget()
endif
call IssuePointOrder(me,"attack",GetUnitX(Hero[.targetId]),GetUnitY(Hero[.targetId]))
endif
endmethod
implement AutoCreate
function SpawnCreeps takes integer unitId,integer ownerId, real x, real y returns nothing
local unit creeps = CreateUnit(Player(ownerId),unitId,x,y,0.)
call SetUnitAbilityLevel(creeps,UP_DMG,XpAverageCoeff)
call SetUnitAbilityLevel(creeps,UP_HP,XpAverageCoeff)
set creeps = null
endfunction
private function SetAllDestination takes unit creeps returns nothing
local s_targetId dat = s_targetId[creeps]
if not (IsUnitType(GeneralTarget,UNIT_TYPE_DEAD)) and GeneralTarget!= null then
call IssuePointOrder(creeps,"attack",GetUnitX(GeneralTarget)+GetRandomReal(-500.,500.),GetUnitY(GeneralTarget)+GetRandomReal(-500.,500.))
else
if IsUnitType(Hero[dat.targetId],UNIT_TYPE_DEAD) or Hero[dat.targetId]==null then
set dat.targetId = SetRandomHeroTarget()
endif
call IssuePointOrder(creeps,"attack",GetUnitX(Hero[dat.targetId]),GetUnitY(Hero[dat.targetId]))
endif
endfunction
private function CreepsOrderPlayerGroup takes player owner returns boolean
local group g = NewGroup()
local unit creeps = null
call GroupEnumUnitsOfPlayer(g,owner,null)
loop
set creeps = FirstOfGroup(g)
exitwhen creeps == null
call SetAllDestination(creeps)
call GroupRemoveUnit(g,creeps)
endloop
call ReleaseGroup(g)
set g = null
set creeps = null
return false
endfunction
private function SpawnHero takes nothing returns nothing
local integer i = 0
local integer j = 0
local integer r = 0
local real x1 = 0.
local real y1 = 0.
local real x2 = 0.
local real y2 = 0.
local real x3 = 0.
local real y3 = 0.
local real angle = 0.
local real distance = 0
if ChapterIntermission == false then
loop
exitwhen i > MAXPLAYER
if CreepsPop <= CREEPS_TOTALMAX and HeroPop <= HERO_MAX and GetRandomInt(0,100)<=REBORN_CHANCE and XpAverage >= REBORN_REQ then
call SpawnCreeps(REBORN_ID,OWNER_HERO,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
set j = 0
loop
exitwhen j > CREEPS_RANDOMMAX
if not (IsUnitType(Hero[i],UNIT_TYPE_DEAD)) and Hero[i]!=null and CreepsPop <= CREEPS_TOTALMAX and HeroPop <= HERO_MAX then
set angle = GetRandomReal(0,6.28)
set x1 = GetUnitX(Hero[i])
set y1 = GetUnitY(Hero[i])
set distance = GetRandomReal(RANDOMSPAWN_DISTANCEMIN,RANDOMSPAWN_DISTANCEMAX)
set x2 = CheckPointValidity(x1+distance*Cos(angle),MapXMin,MapXMax)
set y2 = CheckPointValidity(y1+distance*Sin(angle),MapYMin,MapYMax)
set r = 0
loop
exitwhen r > BaseRectMax
set x3 = CheckPointValidity(x2,BaseXMin[i],BaseXMax[i])
set y3 = CheckPointValidity(y2,BaseYMin[i],BaseYMax[i])
set x2 = x3
set y2 = y3
set r = r + 1
endloop
call SpawnCreeps(SpawnCreepsId[GetRandomInt(0,SpawnCreepsIdMax)],OWNER_RUSH,x2,y2)
endif
set j = j + 1
endloop
set i = i + 1
endloop
endif
endfunction
private function SpawnRush takes nothing returns nothing
local integer i = 0
if ChapterIntermission == false then
set i = 0
loop
exitwhen i > SpawnCreepsWaveAmount
if CreepsPop <= CREEPS_TOTALMAX and RushPop <= RUSH_MAX then
call SpawnCreeps(SpawnRushId,OWNER_RUSH,SpawnRushX,SpawnRushY)
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > SpawnCreepsWaveAmount
if CreepsPop <= CREEPS_TOTALMAX and RushPop <= RUSH_MAX then
call SpawnCreeps(SpawnAirId,OWNER_RUSH,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
set i = i + 1
endloop
endif
endfunction
private function SpawnNormal takes nothing returns nothing
local integer spawnRectIndex = 1
local integer i = 0
set SpawnCreepsAmount = CREEPS_BASE_SPAWN+PlayerAmount
set SpawnCreepsWaveAmount = SpawnCreepsAmount+CREEPS_WAVEMAXCOEFF*R2I((1+(PlayerAmount/8)))
if ChapterIntermission == false then
if GetRandomInt(0,100)<=CHANCE_AIR then
set i = 0
loop
exitwhen i > SpawnCreepsWaveAmount
if CreepsPop <= CREEPS_TOTALMAX and RushPop <= RUSH_MAX then
call SpawnCreeps(SpawnAirId,OWNER_RUSH,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
set i = i + 1
endloop
endif
if CreepsPop <= CREEPS_TOTALMAX and NormalPop <= NORMAL_MAX and GetRandomInt(0,100)<=WINDSTALKER_CHANCE and XpAverage >= WINDSTALKER_REQ then
call SpawnCreeps(WINDSTALKER_ID,OWNER_NORMAL,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
if CreepsPop <= CREEPS_TOTALMAX and RushPop <= RUSH_MAX and GetRandomInt(0,100)<=DEGENERESCENCE_CHANCE and XpAverage >= DEGENERESCENCE_REQ then
call SpawnCreeps(DEGENERESCENCE_ID,OWNER_RUSH,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
if CreepsPop <= CREEPS_TOTALMAX and RushPop <= RUSH_MAX and GetRandomInt(0,100)<=IMMORTAL_CHANCE and ((GameMode != 3 and XpAverage >= IMMORTAL_REQ) or (GameMode ==3)) then
call SpawnCreeps(IMMORTAL_ID,OWNER_RUSH,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
loop
exitwhen spawnRectIndex > SpawnMax
set i = 0
loop
exitwhen i > SpawnCreepsWaveAmount
if SpawnTrue[spawnRectIndex]==true and not (SpawnCaveDestroyed[spawnRectIndex]) then
if CreepsPop <= CREEPS_TOTALMAX and NormalPop <= NORMAL_MAX then
call SpawnCreeps(SpawnCreepsId[GetRandomInt(0,SpawnCreepsIdMax)],OWNER_NORMAL,SpawnX[spawnRectIndex],SpawnY[spawnRectIndex])
endif
if CreepsPop <= CREEPS_TOTALMAX and NormalPop <= NORMAL_MAX and GetRandomInt(0,100)<XpAverageCoeff*SpecialCreepsChance[GameMode] then
call SpawnCreeps(SpawnSpecialId[GetRandomInt(0,SpawnSpecialIdMax)],OWNER_NORMAL,SpawnX[spawnRectIndex],SpawnY[spawnRectIndex])
endif
endif
set i = i + 1
endloop
set spawnRectIndex = spawnRectIndex + 1
endloop
endif
endfunction
function CreepsSpawnFirstWave takes nothing returns nothing
local integer spawnRectIndex = 1
local integer i = 0
set SpawnCreepsAmount = CREEPS_BASE_SPAWN+PlayerAmount
set SpawnCreepsWaveAmount = SpawnCreepsAmount+CREEPS_WAVEMAXCOEFF*R2I((1+(PlayerAmount/8)))
if CreepsPop <= CREEPS_TOTALMAX and NormalPop <= NORMAL_MAX and XpAverage >= DEGENERESCENCE_REQ then
call SpawnCreeps(DEGENERESCENCE_ID,OWNER_NORMAL,GetRandomReal(MapXMin,MapXMax),GetRandomReal(MapYMin,MapYMax))
endif
loop
exitwhen spawnRectIndex > 6//Caves only
set i = 0
if not (SpawnCaveDestroyed[spawnRectIndex]) then
loop
exitwhen i > SpawnCreepsWaveAmount
if NormalPop <NORMAL_MAX and CreepsPop <= CREEPS_TOTALMAX then
call SpawnCreeps(SpawnCreepsId[GetRandomInt(0,SpawnCreepsIdMax)],OWNER_RUSH,SpawnX[spawnRectIndex],SpawnY[spawnRectIndex])
endif
set i = i + 1
endloop
endif
set spawnRectIndex = spawnRectIndex + 1
endloop
endfunction
function CreepsResetCreepsId takes nothing returns nothing
local integer i = 0
loop
exitwhen i > SpawnCreepsIdMax
set SpawnCreepsId[i]= 0
set i = i + 1
endloop
set SpawnCreepsIdMax = 0
set i = 0
loop
exitwhen i > SpawnSpecialIdMax
set SpawnSpecialId[i]= 0
set i = i + 1
endloop
set SpawnCreepsIdMax = 0
set SpawnSpecialIdMax = 0
endfunction
function CreepsAddRushId takes integer idcreeps returns nothing
set SpawnRushId = idcreeps
endfunction
function CreepsAddAirId takes integer idcreeps returns nothing
set SpawnAirId = idcreeps
endfunction
function CreepsAddCreepsId takes integer idcreeps returns nothing
set SpawnCreepsId[SpawnCreepsIdMax] = idcreeps
set SpawnCreepsIdMax = SpawnCreepsIdMax + 1
endfunction
function CreepsAddSpecialId takes integer idcreeps returns nothing
set SpawnSpecialId[SpawnSpecialIdMax] = idcreeps
set SpawnSpecialIdMax = SpawnSpecialIdMax + 1
endfunction
function CreepsChangeTimerRate takes real whichTimeout returns nothing
set TimeOutNormal = whichTimeout
set TimeOutHero = whichTimeout
call ReleaseTimer(TimerSpawnNormal)
call ReleaseTimer(TimerSpawnHero)
set TimerSpawnNormal = NewTimer()
set TimerSpawnHero = NewTimer()
call TimerStart( TimerSpawnNormal, TimeOutNormal, true, function SpawnNormal )
call TimerStart( TimerSpawnHero, TimeOutHero, true, function SpawnHero )
endfunction
function CreepsResetSpawn takes nothing returns nothing
local integer i = 0
loop
exitwhen i > SpawnMax
set SpawnTrue[i]=false
set i = i + 1
endloop
endfunction
function CreepsAddAmount takes integer whichInteger returns nothing
set SpawnCreepsAmount = SpawnCreepsAmount + whichInteger
endfunction
private function FilterAllNormalCreeps takes nothing returns boolean
if (GetOwningPlayer(GetFilterUnit())==Player(OWNER_NORMAL) or GetOwningPlayer(GetFilterUnit())==Player(OWNER_RUSH) or GetOwningPlayer(GetFilterUnit())==Player(OWNER_HERO)) and not (IsUnitType(GetFilterUnit(),UNIT_TYPE_MECHANICAL)) and not (IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE)) then
call KillUnit(GetFilterUnit())
endif
return true
endfunction
function CreepsKillAllNormal takes nothing returns nothing
call GroupEnumUnitsInRect(ENUM_GROUP,bj_mapInitialPlayableArea,Filter(function FilterAllNormalCreeps))
set CreepsPop = 0
set NormalPop = 0
set RushPop = 0
set HeroPop = 0
endfunction
private function CreepsInitializeSpawns takes nothing returns boolean
local integer i = 0
set PlayerAmount = 0
set NormalGroup = NewGroup()
set RushGroup = NewGroup()
set HeroGroup = NewGroup()
loop
exitwhen i > 9
if GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING then
set PlayerAmount = PlayerAmount + 1
endif
set i = i + 1
endloop
set SpawnCreepsAmount = CREEPS_BASE_SPAWN+PlayerAmount
set TimerSpawnNormal = NewTimer()
set TimerSpawnRush = NewTimer()
set TimerSpawnHero = NewTimer()
call TimerStart(TimerSpawnNormal, TimeOutNormal, true, function SpawnNormal)
call TimerStart(TimerSpawnRush, TimeOutRush, true, function SpawnRush)
call TimerStart(TimerSpawnHero, TimeOutHero, true, function SpawnHero)
return false
endfunction
private function CreepsDeath takes nothing returns boolean
local player killerOwner = GetOwningPlayer(GetKillingUnit())
local integer killerOwnerId = GetPlayerId(killerOwner)
call CreepsRemoveUnitFromGroup(GetTriggerUnit())
if GetPlayerSlotState(killerOwner)==PLAYER_SLOT_STATE_PLAYING and GetPlayerController(killerOwner) == MAP_CONTROL_USER then
set Kill[killerOwnerId]=Kill[killerOwnerId]+1
call BoardUpdateKill(killerOwner)
set SubKill[killerOwnerId] = SubKill[killerOwnerId] + 1
if SubKill[killerOwnerId] >= HeroCoeff[killerOwnerId] then
set SubKill[killerOwnerId] = 0
if XpAvailable == true then
set Xp[killerOwnerId] = Xp[killerOwnerId] + 1
set CurrentGameXp[killerOwnerId] = CurrentGameXp[killerOwnerId] + 1
endif
endif
call CheckRank(killerOwnerId)
endif
set killerOwner = null
return false
endfunction
private function init takes nothing returns nothing
local integer i = 1
local trigger t1 = CreateTrigger()
local trigger t2 = CreateTrigger()
local trigger t3 = CreateTrigger()
local trigger t4 = CreateTrigger()
local trigger t5 = CreateTrigger()
set CreepsPop = 0
set NormalPop = 0
set RushPop = 0
set HeroPop = 0
call SetSpawnVariables()
call AbilityPreload(UP_HP)
call AbilityPreload(UP_DMG)
set CaveToDestroy = 0
set SpawnRushX = GetRectCenterX(gg_rct_SpawnRush)
set SpawnRushY = GetRectCenterY(gg_rct_SpawnRush)
loop
exitwhen i > SpawnMax
set SpawnTrue[i] = false
set SpawnX[i]=GetRectCenterX(SpawnRect[i])
set SpawnY[i]=GetRectCenterY(SpawnRect[i])
set SpawnCaveDestroyed[i]=false
if SpawnIsCave[i]==true then
set CaveToDestroy = CaveToDestroy + 1
endif
set i = i + 1
endloop
set i = 0
loop
exitwhen i > BaseRectMax
set BaseXMin[i] = GetRectMinX(BaseRect[i])
set BaseYMin[i] = GetRectMinY(BaseRect[i])
set BaseXMax[i] = GetRectMaxX(BaseRect[i])
set BaseYMax[i] = GetRectMaxY(BaseRect[i])
set i = i + 1
endloop
call TriggerRegisterPlayerUnitEvent(t1, Player(OWNER_NORMAL), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(t1, Player(OWNER_RUSH), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerRegisterPlayerUnitEvent(t1, Player(OWNER_HERO), EVENT_PLAYER_UNIT_DEATH, null)
call TriggerAddCondition(t1, Condition(function CreepsDeath))
call TriggerRegisterTimerEvent(t2, WAIT,false)
call TriggerAddCondition(t2, Condition(function CreepsInitializeSpawns))
call TriggerRegisterTimerEvent(t3, TIMEOUT_UPDATE,true)
call TriggerAddCondition(t3, Condition(function PeriodicHeroUpdate))
call TriggerRegisterTimerEvent(t4, TIMEOUT_UPDATE+0.1,true)
call TriggerAddCondition(t4, Condition(function PeriodicNormalUpdate))
call TriggerRegisterTimerEvent(t5, TIMEOUT_UPDATE+0.2,true)
call TriggerAddCondition(t5, Condition(function PeriodicRushUpdate))
endfunction
endlibrary
Vous ne pouvez pas poster de nouveaux sujets dans ce forum Vous ne pouvez pas répondre aux sujets dans ce forum Vous ne pouvez pas éditer vos messages dans ce forum Vous ne pouvez pas supprimer vos messages dans ce forum Vous ne pouvez pas voter dans les sondages de ce forum