mirror of
https://github.com/Refactorio/RedMew.git
synced 2024-12-12 10:04:40 +02:00
Fixed part of artillery pickup exploit
- Current behaviour is that when destroyers/defenders are created their target position is set to the entity that killed them. - If a player picks up the artillery after the capsules spawn then they lose their cause.target and stop, not reaching the cause of the turret death. - I've changed this behaviour so that if the target.cause is artillery then it spawns a defender/destroyer projectile NOT an entity. The projectile target can therefore be a position not an entity. So the capsules won't stop if the artillery is picked up. - If the cause is not artillery turret or wagon then a destroyer/defender capsule entity is spawned instead of a projectile because a projectile cannot track the player. - If the player picks up the artillery turret before the projectile that kills a turret arrives then the event cause.name will be missing and no bots spawn at all. I have changed the behaviour so that "if not cause" then we assume they're doing something fucky. We won't have the entity cause name or position, so let's just spawn double the normal amount of destroyers and just send them at 0, 0 since we know nothing else to do with them.
This commit is contained in:
parent
33e378ccda
commit
ecff8f86eb
@ -295,48 +295,78 @@ local bot_cause_whitelist = {
|
||||
}
|
||||
|
||||
local function do_bot_spawn(entity_name, entity, event)
|
||||
if not bot_spawn_whitelist[entity_name] then
|
||||
return
|
||||
end
|
||||
|
||||
local cause = event.cause
|
||||
if not cause or not bot_cause_whitelist[cause.name] then
|
||||
return
|
||||
end
|
||||
|
||||
local entity_force = entity.force
|
||||
local ef = entity_force.evolution_factor
|
||||
local create_entity = entity.surface.create_entity
|
||||
|
||||
if ef <= 0.2 then
|
||||
return
|
||||
end
|
||||
|
||||
local create_entity = entity.surface.create_entity
|
||||
local repeat_cycle = 1 -- The number of times a squad of robots are spawned default must be 1
|
||||
if ef > .95 then
|
||||
repeat_cycle = 2
|
||||
end
|
||||
|
||||
|
||||
local spawn_entity = {
|
||||
position = entity.position,
|
||||
target = cause,
|
||||
force = entity_force
|
||||
}
|
||||
|
||||
if not cause then
|
||||
-- If we reach here then the player might have picked up the artillery turret before the projectile hit the entity and killed it.
|
||||
-- We therefore won't know the location of the artillery turret/wagon that killed the turret, so let's punish them and send even more bots, straight at spawn?
|
||||
for i = 1, 60 do
|
||||
spawn_entity.name = 'destroyer-capsule'
|
||||
spawn_entity.speed = 0.2
|
||||
spawn_entity.target = {0,0}
|
||||
create_entity(spawn_entity)
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
if not bot_spawn_whitelist[entity_name] then
|
||||
return
|
||||
end
|
||||
|
||||
if not bot_cause_whitelist[cause.name] then
|
||||
return
|
||||
end
|
||||
|
||||
local repeat_cycle = 1 -- The number of times a squad of robots are spawned default must be 1
|
||||
if ef > .95 then
|
||||
repeat_cycle = 2
|
||||
end
|
||||
|
||||
|
||||
|
||||
if cause.name ~= 'character' then
|
||||
if entity_name == 'artillery-turret' then
|
||||
if (entity_name == 'artillery-turret') or (entity_name == 'artillery-wagon') then
|
||||
repeat_cycle = 15
|
||||
else
|
||||
repeat_cycle = 4
|
||||
end
|
||||
for i = 1, repeat_cycle do
|
||||
spawn_entity.name = 'defender'
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
if (cause.name == 'artillery-turret') or (cause.name == 'artillery-wagon') then
|
||||
spawn_entity.target = cause.position -- Overwrite target. Artillery turrets/wagons don't move so send them to entity position. Stops players from picking up the arty and the bots stopping dead.
|
||||
spawn_entity.speed = 0.2
|
||||
|
||||
spawn_entity.name = 'defender-capsule' -- use 'defender-capsule' (projectile) not 'defender' (entity) since a projectile can target a position but a capsule entity must have another entity as target
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
|
||||
spawn_entity.name = 'destroyer'
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
spawn_entity.name = 'destroyer-capsule'
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
else
|
||||
-- projectiles don't have AI so won't track/follow a player
|
||||
-- if the cause wasn't artillery turret/wagon then spawn a capsule entity not projectile
|
||||
spawn_entity.name = 'defender' -- use defender-capsule (projectile) not defender (entity) since a projectile can target a position but a capsule entity must have another entity as target
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
|
||||
spawn_entity.name = 'destroyer'
|
||||
create_entity(spawn_entity)
|
||||
create_entity(spawn_entity)
|
||||
end
|
||||
end
|
||||
elseif entity_name == 'gun-turret' then
|
||||
for i = 1, repeat_cycle do
|
||||
|
Loading…
Reference in New Issue
Block a user