mirror of
https://github.com/veden/Rampant.git
synced 2024-12-28 21:08:22 +02:00
free units and unit groups from vanilla get kamikaze roll
This commit is contained in:
parent
59b364398d
commit
9b6e13e0fa
@ -3,6 +3,8 @@ Version: 0.16.3
|
||||
Date: 1. 13. 2018
|
||||
Improvements:
|
||||
- Removed squad limit
|
||||
- Squads converted from vanilla control receive immediate kamikaze roll
|
||||
- Units not under a unit group, now get a kamikaze roll before being put into a retreating squad
|
||||
Optimizations:
|
||||
- Reworked squad regrouping to be surrounding chunks instead comparing against master list
|
||||
Framework:
|
||||
|
@ -129,7 +129,7 @@ function squadAttack.squadsBeginAttack(natives, players)
|
||||
local squad = squads[i]
|
||||
local group = squad.group
|
||||
if (squad.status == SQUAD_GUARDING) and group.valid then
|
||||
local kamikazeThreshold = calculateKamikazeThreshold(squad, natives)
|
||||
local kamikazeThreshold = calculateKamikazeThreshold(#squad.group.members, natives)
|
||||
|
||||
local groupPosition = group.position
|
||||
if playersWithinProximityToPosition(players, groupPosition, 100) then
|
||||
|
@ -23,8 +23,12 @@ local SENTINEL_IMPASSABLE_CHUNK = constants.SENTINEL_IMPASSABLE_CHUNK
|
||||
|
||||
-- imported functions
|
||||
|
||||
local mRandom = math.random
|
||||
|
||||
local addSquadToChunk = chunkUtils.addSquadToChunk
|
||||
|
||||
local calculateKamikazeThreshold = unitGroupUtils.calculateKamikazeThreshold
|
||||
|
||||
local positionFromDirectionAndChunk = mapUtils.positionFromDirectionAndChunk
|
||||
local getNeighborChunks = mapUtils.getNeighborChunks
|
||||
local findNearbySquadFiltered = unitGroupUtils.findNearbySquadFiltered
|
||||
@ -53,6 +57,10 @@ function aiDefense.retreatUnits(chunk, position, squad, map, surface, natives, t
|
||||
if not squad then
|
||||
enemiesToSquad = surface.find_enemy_units(position, radius)
|
||||
performRetreat = #enemiesToSquad > 0
|
||||
if (mRandom() < calculateKamikazeThreshold(#enemiesToSquad, natives)) then
|
||||
setRetreatTick(map, chunk, tick + (INTERVAL_LOGIC * 10))
|
||||
performRetreat = false
|
||||
end
|
||||
elseif squad.group.valid and (squad.status ~= SQUAD_RETREATING) and not squad.kamikaze then
|
||||
performRetreat = #squad.group.members > 1
|
||||
end
|
||||
|
@ -90,8 +90,8 @@ end
|
||||
-- end
|
||||
-- end
|
||||
|
||||
function unitGroupUtils.createSquad(position, surface, natives)
|
||||
local unitGroup = surface.create_unit_group({position=position})
|
||||
function unitGroupUtils.createSquad(position, surface, natives, group)
|
||||
local unitGroup = group or surface.create_unit_group({position=position})
|
||||
|
||||
local squad = {
|
||||
group = unitGroup,
|
||||
@ -131,11 +131,13 @@ function unitGroupUtils.convertUnitGroupToSquad(natives, unitGroup)
|
||||
return squad
|
||||
end
|
||||
end
|
||||
return nil
|
||||
local squad = unitGroupUtils.createSquad(nil,nil,natives,unitGroup)
|
||||
squad.kamikaze = mRandom() < unitGroupUtils.calculateKamikazeThreshold(#unitGroup.members, natives)
|
||||
return squad
|
||||
end
|
||||
|
||||
function unitGroupUtils.calculateKamikazeThreshold(squad, natives)
|
||||
local squadSizeBonus = mLog((#squad.group.members / natives.attackWaveMaxSize) + 0.1) + 1
|
||||
function unitGroupUtils.calculateKamikazeThreshold(memberCount, natives)
|
||||
local squadSizeBonus = mLog((memberCount / natives.attackWaveMaxSize) + 0.1) + 1
|
||||
return natives.kamikazeThreshold + (NO_RETREAT_SQUAD_SIZE_BONUS_MAX * squadSizeBonus)
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user