1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-01-24 03:47:58 +02:00

Merge pull request #58 from ComfyFactory/mtn_v3_changes

mor changes to mtn fortress
This commit is contained in:
Gerkiz 2021-05-16 14:58:12 +02:00 committed by GitHub
commit 6785aaa9ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 51 additions and 51 deletions

View File

@ -212,7 +212,7 @@ local function check_health_final_damage(final_damage_amount)
end
end
local function set_train_final_health(final_damage_amount)
local function set_train_final_health(final_damage_amount, repair)
if final_damage_amount == 0 then
return
end
@ -224,53 +224,56 @@ local function set_train_final_health(final_damage_amount)
local locomotive_health = WPT.get('locomotive_health')
local locomotive_max_health = WPT.get('locomotive_max_health')
local poison_deployed = WPT.get('poison_deployed')
local robotics_deployed = WPT.get('robotics_deployed')
local lower_high = locomotive_max_health * 0.4
local higher_high = locomotive_max_health * 0.5
local lower_low = locomotive_max_health * 0.2
local higher_low = locomotive_max_health * 0.3
if not repair then
local poison_deployed = WPT.get('poison_deployed')
local robotics_deployed = WPT.get('robotics_deployed')
if locomotive_health >= lower_high and locomotive_health <= higher_high then
if not poison_deployed then
local carriages = WPT.get('carriages')
local lower_high = locomotive_max_health * 0.4
local higher_high = locomotive_max_health * 0.5
local lower_low = locomotive_max_health * 0.2
local higher_low = locomotive_max_health * 0.3
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
Locomotive.enable_poison_defense(entity.position)
end
end
if locomotive_health >= lower_high and locomotive_health <= higher_high then
if not poison_deployed then
local carriages = WPT.get('carriages')
local p = {
position = locomotive.position
}
local msg = ({'entity.train_taking_damage'})
Alert.alert_all_players_location(p, msg)
WPT.set().poison_deployed = true
end
elseif locomotive_health >= lower_low and locomotive_health <= higher_low then
if not robotics_deployed then
local carriages = WPT.get('carriages')
if carriages then
for _ = 1, 10 do
if carriages then
for i = 1, #carriages do
local entity = carriages[i]
Locomotive.enable_robotic_defense(entity.position)
Locomotive.enable_poison_defense(entity.position)
end
end
local p = {
position = locomotive.position
}
local msg = ({'entity.train_taking_damage'})
Alert.alert_all_players_location(p, msg)
WPT.set().poison_deployed = true
end
local p = {
position = locomotive.position
}
local msg = ({'entity.train_taking_damage'})
Alert.alert_all_players_location(p, msg)
WPT.set().robotics_deployed = true
elseif locomotive_health >= lower_low and locomotive_health <= higher_low then
if not robotics_deployed then
local carriages = WPT.get('carriages')
if carriages then
for _ = 1, 10 do
for i = 1, #carriages do
local entity = carriages[i]
Locomotive.enable_robotic_defense(entity.position)
end
end
end
local p = {
position = locomotive.position
}
local msg = ({'entity.train_taking_damage'})
Alert.alert_all_players_location(p, msg)
WPT.set().robotics_deployed = true
end
elseif locomotive_health >= locomotive_max_health then
WPT.set().poison_deployed = false
end
elseif locomotive_health >= locomotive_max_health then
WPT.set().poison_deployed = false
end
if locomotive_health <= 0 then
@ -332,7 +335,7 @@ local function protect_entities(event)
if (event.cause and event.cause.valid) then
if event.cause.force.index == 2 then
if units and units[entity.unit_number] then
set_train_final_health(dmg)
set_train_final_health(dmg, false)
return
else
entity.health = entity.health - dmg
@ -342,7 +345,7 @@ local function protect_entities(event)
elseif not (event.cause and event.cause.valid) then
if event.force and event.force.index == 2 then
if units and units[entity.unit_number] then
set_train_final_health(dmg)
set_train_final_health(dmg, false)
return
else
entity.health = entity.health - dmg
@ -946,10 +949,10 @@ local function on_player_repaired_entity(event)
local player = game.players[event.player_index]
local repair_speed = Functions.get_magicka(player)
if repair_speed <= 0 then
set_train_final_health(-1)
set_train_final_health(-1, true)
return
else
set_train_final_health(-repair_speed)
set_train_final_health(-repair_speed, true)
return
end
end

View File

@ -3,7 +3,7 @@ local Color = require 'utils.color_presets'
local Task = require 'utils.task'
local Token = require 'utils.token'
local IC_Gui = require 'maps.mountain_fortress_v3.ic.gui'
local IC = require 'maps.mountain_fortress.ic.table'
local IC = require 'maps.mountain_fortress_v3.ic.table'
local WPT = require 'maps.mountain_fortress_v3.table'
local Public = {}

View File

@ -738,28 +738,25 @@ local damage_player_over_time_token =
Token.register(
function(data)
local player = data.player
local damage = data.damage
if not player.character or not player.character.valid then
return
end
player.character.health = player.character.health - damage
player.character.health = player.character.health - (player.character.health * 0.05)
player.character.surface.create_entity({name = 'water-splash', position = player.position})
end
)
--- Damages a player over time.
function Public.damage_player_over_time(player, amount, damage)
function Public.damage_player_over_time(player, amount)
if not player or not player.valid then
return
end
amount = amount or 5
damage = damage or 10
amount = amount or 10
local tick = 20
for _ = 1, amount, 1 do
Task.set_timeout_in_ticks(tick, damage_player_over_time_token, {player = player, damage = damage})
Task.set_timeout_in_ticks(tick, damage_player_over_time_token, {player = player})
tick = tick + 15
damage = damage + 10
end
end

View File

@ -1098,7 +1098,7 @@ local function on_player_used_capsule(event)
elseif object.obj_to_create == 'warp-gate' then
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
rpg_t[player.index].mana = 0
Functions.damage_player_over_time(player, 10)
Functions.damage_player_over_time(player, math.random(8, 16))
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
p(({'rpg_main.warped_ok'}), Color.info)
rpg_t[player.index].mana = rpg_t[player.index].mana - object.mana_cost