mirror of
https://github.com/ComfyFactory/ComfyFactorio.git
synced 2025-01-06 00:23:49 +02:00
2 new classes: Soldier and Veteran
Changes: - New class Soldier: When eating fish, they have 20% chance to summon defender to protect them. - New class Veteran: When eating fish, they have 20% chance to summon destroyer to protect them. In addition, they have 10% chance to slow the enemy that hits them. - When combat robots defeat enemies, the loot now goes straight to combat robot owner's inventory
This commit is contained in:
parent
1db1b982b0
commit
42bcb51c4a
@ -275,6 +275,10 @@ class_chief=Chief
|
||||
class_chief_explanation_advanced=They cook meat of defeated enemies and turn it into something tasty.
|
||||
class_roc_eater=Roc Eater
|
||||
class_roc_eater_explanation_advanced=When eating fish, if they have stone furnaces in their inventory, they will eat those instead.\nIn addition, they receive __1__% less damage.
|
||||
class_soldier=Soldier
|
||||
class_soldier_explanation_advanced=When eating fish, they have __1__% chance to summon defender to protect them.
|
||||
class_veteran=Veteran
|
||||
class_veteran_explanation_advanced=When eating fish, they have __1__% chance to summon destroyer to protect them.\nIn addition, they have __2__% chance to slow the enemy that hits them.
|
||||
|
||||
|
||||
class_explanation=__1__: __2__
|
||||
|
@ -305,6 +305,11 @@ local function damage_to_players_changes(event)
|
||||
|
||||
local player_index = event.entity.player.index
|
||||
local class = memory.classes_table and memory.classes_table[player_index]
|
||||
local player = game.players[player_index]
|
||||
|
||||
if not (player and player.valid and player.character and player.character.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local damage_multiplier = 1
|
||||
|
||||
@ -313,22 +318,46 @@ local function damage_to_players_changes(event)
|
||||
if event.damage_type.name == 'poison' then --make all poison damage stronger against players
|
||||
damage_multiplier = damage_multiplier * Balance.poison_damage_multiplier
|
||||
else
|
||||
if class and class == Classes.enum.SCOUT then
|
||||
damage_multiplier = damage_multiplier * Balance.scout_damage_taken_multiplier
|
||||
-- elseif class and class == Classes.enum.MERCHANT then
|
||||
-- damage_multiplier = damage_multiplier * 1.10
|
||||
elseif class and class == Classes.enum.SAMURAI then
|
||||
damage_multiplier = damage_multiplier * Balance.samurai_damage_taken_multiplier
|
||||
elseif class and class == Classes.enum.HATAMOTO then
|
||||
damage_multiplier = damage_multiplier * Balance.hatamoto_damage_taken_multiplier
|
||||
elseif class and class == Classes.enum.ROC_EATER then
|
||||
damage_multiplier = damage_multiplier * Balance.roc_eater_damage_taken_multiplier
|
||||
elseif class and class == Classes.enum.IRON_LEG then
|
||||
if memory.class_auxiliary_data[player_index] and memory.class_auxiliary_data[player_index].iron_leg_active then
|
||||
damage_multiplier = damage_multiplier * Balance.iron_leg_damage_taken_multiplier
|
||||
if class then
|
||||
if class == Classes.enum.SCOUT then
|
||||
damage_multiplier = damage_multiplier * Balance.scout_damage_taken_multiplier
|
||||
-- elseif class == Classes.enum.MERCHANT then
|
||||
-- damage_multiplier = damage_multiplier * 1.10
|
||||
elseif class == Classes.enum.SAMURAI then
|
||||
damage_multiplier = damage_multiplier * Balance.samurai_damage_taken_multiplier
|
||||
elseif class == Classes.enum.HATAMOTO then
|
||||
damage_multiplier = damage_multiplier * Balance.hatamoto_damage_taken_multiplier
|
||||
elseif class == Classes.enum.ROC_EATER then
|
||||
damage_multiplier = damage_multiplier * Balance.roc_eater_damage_taken_multiplier
|
||||
elseif class == Classes.enum.IRON_LEG then
|
||||
if memory.class_auxiliary_data[player_index] and memory.class_auxiliary_data[player_index].iron_leg_active then
|
||||
damage_multiplier = damage_multiplier * Balance.iron_leg_damage_taken_multiplier
|
||||
end
|
||||
elseif class == Classes.enum.VETERAN then
|
||||
local chance = Balance.veteran_on_hit_slow_chance
|
||||
if Math.random() < chance then
|
||||
-- only certain targets accept stickers
|
||||
if event.cause.name == 'small-biter' or
|
||||
event.cause.name == 'small-spitter' or
|
||||
event.cause.name == 'medium-biter' or
|
||||
event.cause.name == 'medium-spitter' or
|
||||
event.cause.name == 'big-biter' or
|
||||
event.cause.name == 'big-spitter' or
|
||||
event.cause.name == 'behemoth-biter' or
|
||||
event.cause.name == 'behemoth-spitter'
|
||||
then
|
||||
player.surface.create_entity{
|
||||
name = 'slowdown-sticker',
|
||||
position = player.character.position,
|
||||
speed = 1.5,
|
||||
force = player.force,
|
||||
target = event.cause
|
||||
}
|
||||
end
|
||||
end
|
||||
-- else
|
||||
-- damage_multiplier = damage_multiplier * (1 + Balance.bonus_damage_to_humans())
|
||||
end
|
||||
-- else
|
||||
-- damage_multiplier = damage_multiplier * (1 + Balance.bonus_damage_to_humans())
|
||||
end
|
||||
end
|
||||
|
||||
@ -348,11 +377,6 @@ local function damage_to_players_changes(event)
|
||||
|
||||
-- deal with damage reduction on lethal damage for players
|
||||
-- Piratux wrote this code — it tracks player health (except passive regen), and intervenes on a lethal damage event, so it should work most of the time.
|
||||
local player = game.players[player_index]
|
||||
if not (player and player.valid and player.character and player.character.valid) then
|
||||
return
|
||||
end
|
||||
|
||||
local global_memory = Memory.get_global_memory()
|
||||
|
||||
if damage_multiplier < 1 and event.final_health <= 0 then
|
||||
@ -937,6 +961,13 @@ local function base_kill_rewards(event)
|
||||
revenge_target = event.cause
|
||||
end
|
||||
|
||||
-- This gives enemy loot straight to combat robot owner's inventory instead of dropping it on the ground
|
||||
if event.cause.name == 'defender' or event.cause.name == 'distractor' or event.cause.name == 'destroyer' then
|
||||
if event.cause.combat_robot_owner and event.cause.combat_robot_owner.valid then
|
||||
revenge_target = event.cause.combat_robot_owner
|
||||
end
|
||||
end
|
||||
|
||||
local class
|
||||
if revenge_target and
|
||||
revenge_target.valid and
|
||||
|
@ -60,6 +60,7 @@ Public.rocket_launch_coin_reward = 5000
|
||||
Public.scout_damage_taken_multiplier = 1.25
|
||||
Public.scout_damage_dealt_multiplier = 0.6
|
||||
Public.fisherman_reach_bonus = 10
|
||||
Public.lumberjack_coins_from_tree = 12
|
||||
Public.master_angler_reach_bonus = 16
|
||||
Public.master_angler_fish_bonus = 2
|
||||
Public.master_angler_coin_bonus = 20
|
||||
@ -70,6 +71,9 @@ Public.rocket_launch_coin_reward = 5000
|
||||
Public.chief_fish_received_for_worm_kill = 3
|
||||
Public.roc_eater_damage_taken_multiplier = 0.8
|
||||
Public.roc_eater_required_stone_furnace_to_heal_count = 1
|
||||
Public.soldier_defender_summon_chance = 0.2
|
||||
Public.veteran_destroyer_summon_chance = 0.2
|
||||
Public.veteran_on_hit_slow_chance = 0.1
|
||||
|
||||
|
||||
function Public.starting_boatEEIpower_production_MW()
|
||||
|
@ -95,11 +95,21 @@ function Public.vector_dir(pos_from, pos_target)
|
||||
return {x = pos_target.x - pos_from.x, y = pos_target.y - pos_from.y}
|
||||
end
|
||||
|
||||
|
||||
function Public.random_float_in_range(from, to)
|
||||
return Public.random() * (to - from) + from
|
||||
end
|
||||
|
||||
-- Returns vector in random direction.
|
||||
-- scalar: sets returned vector length. If null, 1 will be chosen
|
||||
function Public.random_vec(scalar)
|
||||
scalar = scalar or 1
|
||||
local random_angle = Public.random_float_in_range(0, 2 * Public.pi)
|
||||
return {
|
||||
x = Public.sin(random_angle) * scalar,
|
||||
y = Public.cos(random_angle) * scalar
|
||||
}
|
||||
end
|
||||
|
||||
function Public.snap_to_grid(point)
|
||||
return {x = Public.ceil(point.x), y = Public.ceil(point.x)}
|
||||
end
|
||||
|
@ -33,6 +33,8 @@ local enum = {
|
||||
GOURMET = 'gourmet',
|
||||
CHIEF = 'chief',
|
||||
ROC_EATER = 'roc_eater',
|
||||
SOLDIER = 'soldier',
|
||||
VETERAN = 'veteran',
|
||||
}
|
||||
Public.enum = enum
|
||||
|
||||
@ -64,6 +66,8 @@ Public.eng_form = {
|
||||
[enum.GOURMET] = 'Gourmet',
|
||||
[enum.CHIEF] = 'Chief',
|
||||
[enum.ROC_EATER] = 'Roc Eater',
|
||||
[enum.SOLDIER] = 'Soldier',
|
||||
[enum.VETERAN] = 'Veteran',
|
||||
}
|
||||
|
||||
function Public.display_form(class)
|
||||
@ -127,6 +131,13 @@ function Public.explanation(class, add_is_class_obtainable)
|
||||
elseif class == enum.ROC_EATER then
|
||||
local received_damage = Public.percentage_points_difference_from_100_percent(Balance.roc_eater_damage_taken_multiplier)
|
||||
full_explanation = {'', {explanation, received_damage}}
|
||||
elseif class == enum.SOLDIER then
|
||||
local chance = Balance.soldier_defender_summon_chance * 100
|
||||
full_explanation = {'', {explanation, chance}}
|
||||
elseif class == enum.VETERAN then
|
||||
local chance = Balance.veteran_destroyer_summon_chance * 100
|
||||
local chance2 = Balance.veteran_on_hit_slow_chance * 100
|
||||
full_explanation = {'', {explanation, chance, chance2}}
|
||||
else
|
||||
full_explanation = {'', {explanation}}
|
||||
end
|
||||
@ -165,6 +176,7 @@ Public.class_unlocks = {
|
||||
-- [enum.PROSPECTOR] = {enum.CHIEF_EXCAVATOR}, --breaks the resource pressure in the game too strongly I think
|
||||
[enum.SAMURAI] = {enum.HATAMOTO},
|
||||
[enum.MASTER_ANGLER] = {enum.DREDGER},
|
||||
[enum.SOLDIER] = {enum.VETERAN},
|
||||
}
|
||||
|
||||
Public.class_purchase_requirement = {
|
||||
@ -173,6 +185,7 @@ Public.class_purchase_requirement = {
|
||||
[enum.CHIEF_EXCAVATOR] = enum.PROSPECTOR,
|
||||
[enum.HATAMOTO] = enum.SAMURAI,
|
||||
[enum.DREDGER] = enum.MASTER_ANGLER,
|
||||
[enum.VETERAN] = enum.SOLDIER,
|
||||
}
|
||||
|
||||
function Public.initial_class_pool()
|
||||
@ -194,6 +207,7 @@ function Public.initial_class_pool()
|
||||
enum.GOURMET,
|
||||
enum.CHIEF,
|
||||
enum.ROC_EATER,
|
||||
enum.SOLDIER,
|
||||
}
|
||||
end
|
||||
|
||||
@ -379,6 +393,34 @@ local function class_on_player_used_capsule(event)
|
||||
player.remove_item({name='stone-furnace', count=required_count})
|
||||
player.insert({name='raw-fish', count=1})
|
||||
end
|
||||
elseif class == Public.enum.SOLDIER then
|
||||
local chance = Balance.soldier_defender_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'defender',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
end
|
||||
elseif class == Public.enum.VETERAN then
|
||||
local chance = Balance.veteran_destroyer_summon_chance
|
||||
if Math.random() < chance then
|
||||
local random_vec = Math.random_vec(3)
|
||||
local e = player.surface.create_entity{
|
||||
name = 'destroyer',
|
||||
position = Utils.psum{player.character.position, random_vec},
|
||||
speed = 1.5,
|
||||
force = player.force
|
||||
}
|
||||
if e and e.valid then
|
||||
e.combat_robot_owner = player.character
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -388,7 +430,7 @@ function Public.lumberjack_bonus_items(give_table)
|
||||
local memory = Memory.get_crew_memory()
|
||||
|
||||
if Math.random(Balance.every_nth_tree_gives_coins) == 1 then
|
||||
local a = 12
|
||||
local a = Balance.lumberjack_coins_from_tree
|
||||
give_table[#give_table + 1] = {name = 'coin', count = a}
|
||||
memory.playtesting_stats.coins_gained_by_trees_and_rocks = memory.playtesting_stats.coins_gained_by_trees_and_rocks + a
|
||||
elseif Math.random(2) == 1 then
|
||||
@ -446,8 +488,16 @@ function Public.try_unlock_class(class_for_sale, player, force_unlock)
|
||||
if force_unlock then
|
||||
memory.spare_classes[#memory.spare_classes + 1] = class_for_sale
|
||||
|
||||
-- update GUI data
|
||||
memory.unlocked_classes[#memory.unlocked_classes + 1] = {class = class_for_sale}
|
||||
-- if player who unlocked class doesn't have one equipped, equip it for him
|
||||
if not memory.classes_table[player.index] then
|
||||
memory.classes_table[player.index] = class_for_sale
|
||||
|
||||
-- update GUI data
|
||||
memory.unlocked_classes[#memory.unlocked_classes + 1] = {class = class_for_sale, taken_by = player.index}
|
||||
else
|
||||
-- update GUI data
|
||||
memory.unlocked_classes[#memory.unlocked_classes + 1] = {class = class_for_sale}
|
||||
end
|
||||
end
|
||||
else -- there is no required class
|
||||
-- if player who unlocked class doesn't have one equipped, equip it for him
|
||||
|
Loading…
Reference in New Issue
Block a user