1
0
mirror of https://github.com/ComfyFactory/ComfyFactorio.git synced 2025-11-25 22:32:18 +02:00

new rpg spells

This commit is contained in:
Gerkiz
2021-05-23 21:13:21 +02:00
parent 9089872f7e
commit a576aaa2c3
7 changed files with 234 additions and 21 deletions

View File

@@ -8,6 +8,9 @@ low_level=You lack the level to cast this spell.
not_inside_pos=You wave your wand but realize that it´s out of reach. not_inside_pos=You wave your wand but realize that it´s out of reach.
no_mana=You don´t have enough mana to cast this spell. no_mana=You don´t have enough mana to cast this spell.
suicidal_comfylatron=You wave your wand and __1__ is on the run! suicidal_comfylatron=You wave your wand and __1__ is on the run!
detonate_chest=You wave your wand and chesty makes big BOOM!
detonate_chest_failed=You wave your wand but no not enough explosives were found inside the chest!
repair_aoe=You wave your wand and repaired __1__ entities!
warped_ok=Warped home with minor bruises. warped_ok=Warped home with minor bruises.
object_spawned=You wave your wand and __1__ appears. object_spawned=You wave your wand and __1__ appears.
out_of_reach=Can´t create entity at given location. out_of_reach=Can´t create entity at given location.
@@ -118,6 +121,8 @@ raw_fish=Conjure Raw-fish
comfylatron=Suicidal Comfylatron comfylatron=Suicidal Comfylatron
distractor=Distractor Capsule distractor=Distractor Capsule
warp=Warp Gate warp=Warp Gate
pointy_explosives=Detonate Chest
repair_aoe=Repair AOE
[allocations] [allocations]

View File

@@ -1,5 +1,6 @@
local Token = require 'utils.token' local Token = require 'utils.token'
local Task = require 'utils.task' local Task = require 'utils.task'
local Color = require 'utils.color_presets'
local ICW = require 'maps.mountain_fortress_v3.icw.main' local ICW = require 'maps.mountain_fortress_v3.icw.main'
local Event = require 'utils.event' local Event = require 'utils.event'
local Global = require 'utils.global' local Global = require 'utils.global'
@@ -772,6 +773,56 @@ local function calc_players()
return total return total
end end
local retry_final_boost_movement_speed_on_respawn =
Token.register(
function(data)
local player = data.player
local old_speed = data.old_speed
if not player or not player.valid then
return
end
if not player.character or not player.character.valid then
return
end
player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info)
end
)
local retry_boost_movement_speed_on_respawn =
Token.register(
function(data)
local player = data.player
local old_speed = data.old_speed
if not player or not player.valid then
return
end
if not player.character or not player.character.valid then
Task.set_timeout_in_ticks(10, retry_final_boost_movement_speed_on_respawn, {player = player, old_speed = old_speed})
return
end
player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info)
end
)
local boost_movement_speed_on_respawn =
Token.register(
function(data)
local player = data.player
local old_speed = data.old_speed
if not player or not player.valid then
return
end
if not player.character or not player.character.valid then
Task.set_timeout_in_ticks(10, retry_boost_movement_speed_on_respawn, {player = player, old_speed = old_speed})
return
end
player.character.character_running_speed_modifier = old_speed
player.print('Movement speed bonus removed!', Color.info)
end
)
function Public.set_difficulty() function Public.set_difficulty()
local game_lost = WPT.get('game_lost') local game_lost = WPT.get('game_lost')
if game_lost then if game_lost then
@@ -1205,6 +1256,20 @@ function Public.on_pre_player_left_game(event)
end end
end end
function Public.on_player_respawned(event)
local player = game.get_player(event.player_index)
if not player or not player.valid then
return
end
local old_speed = player.character_running_speed_modifier
local new_speed = player.character_running_speed_modifier + 1
if player.character and player.character.valid then
player.character.character_running_speed_modifier = new_speed
Task.set_timeout_in_ticks(800, boost_movement_speed_on_respawn, {player = player, old_speed = old_speed})
player.print('Movement speed bonus applied! Be quick and fetch your corpse!', Color.info)
end
end
function Public.on_player_changed_position(event) function Public.on_player_changed_position(event)
local active_surface_index = WPT.get('active_surface_index') local active_surface_index = WPT.get('active_surface_index')
if not active_surface_index then if not active_surface_index then
@@ -1338,12 +1403,14 @@ local on_player_left_game = Public.on_player_left_game
local on_research_finished = Public.on_research_finished local on_research_finished = Public.on_research_finished
local on_player_changed_position = Public.on_player_changed_position local on_player_changed_position = Public.on_player_changed_position
local on_pre_player_left_game = Public.on_pre_player_left_game local on_pre_player_left_game = Public.on_pre_player_left_game
local on_player_respawned = Public.on_player_respawned
Event.add(defines.events.on_player_joined_game, on_player_joined_game) Event.add(defines.events.on_player_joined_game, on_player_joined_game)
Event.add(defines.events.on_player_left_game, on_player_left_game) Event.add(defines.events.on_player_left_game, on_player_left_game)
Event.add(defines.events.on_research_finished, on_research_finished) Event.add(defines.events.on_research_finished, on_research_finished)
Event.add(defines.events.on_player_changed_position, on_player_changed_position) Event.add(defines.events.on_player_changed_position, on_player_changed_position)
Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game) Event.add(defines.events.on_pre_player_left_game, on_pre_player_left_game)
Event.add(defines.events.on_player_respawned, on_player_respawned)
Event.on_nth_tick(10, tick) Event.on_nth_tick(10, tick)
-- Event.on_nth_tick(5, do_turret_energy) -- Event.on_nth_tick(5, do_turret_energy)

View File

@@ -383,8 +383,6 @@ local function wall(data)
spawn_turret(entities, p, 4) spawn_turret(entities, p, 4)
elseif random(1, 2) == 1 then elseif random(1, 2) == 1 then
spawn_turret(entities, p, 5) spawn_turret(entities, p, 5)
elseif random(1, 12) == 1 then
spawn_turret(entities, p, enable_arties)
end end
end end
elseif abs(p.y) > Public.level_depth * 5.5 then elseif abs(p.y) > Public.level_depth * 5.5 then

View File

@@ -243,6 +243,43 @@ local function on_entity_died(event)
) )
end end
function Public.detonate_chest(entity)
if not entity.valid then
return false
end
if not valid_container_types[entity.type] then
return false
end
if explosives.surface_whitelist then
if not explosives.surface_whitelist[entity.surface.name] then
return false
end
end
local inventory = defines.inventory.chest
if entity.type == 'car' then
inventory = defines.inventory.car_trunk
end
local i = entity.get_inventory(inventory)
local amount = i.get_item_count('explosives')
if not amount then
return false
end
if amount < 599 then
return false
end
cell_birth(
entity.surface.index,
{x = entity.position.x, y = entity.position.y},
game.tick,
{x = entity.position.x, y = entity.position.y},
amount * explosives.damage_per_explosive
)
return true
end
function Public.reset() function Public.reset()
explosives.cells = {} explosives.cells = {}
explosives.tiles = {} explosives.tiles = {}

View File

@@ -154,6 +154,36 @@ local function add_to_global_pool(amount, personal_tax)
return amount - fee return amount - fee
end end
local repair_buildings =
Token.register(
function(data)
local entity = data.entity
if entity and entity.valid then
local rng = 0.1
if math.random(1, 5) == 1 then
rng = 0.2
elseif math.random(1, 8) == 1 then
rng = 0.4
end
local to_heal = entity.prototype.max_health * rng
entity.health = entity.health + to_heal
end
end
)
function Public.repair_aoe(player, position)
local entities = player.surface.find_entities_filtered {force = player.force, area = {{position.x - 5, position.y - 5}, {position.x + 5, position.y + 5}}}
local count = 0
for i = 1, #entities do
local e = entities[i]
if e.prototype.max_health ~= e.health then
count = count + 1
Task.set_timeout_in_ticks(10, repair_buildings, {entity = e})
end
end
return count
end
function Public.suicidal_comfylatron(pos, surface) function Public.suicidal_comfylatron(pos, surface)
local str = travelings[math.random(1, #travelings)] local str = travelings[math.random(1, #travelings)]
local symbols = {'', '!', '!', '!!', '..'} local symbols = {'', '!', '!', '!!', '..'}

View File

@@ -4,6 +4,7 @@ local AntiGrief = require 'antigrief'
local Color = require 'utils.color_presets' local Color = require 'utils.color_presets'
local SpamProtection = require 'utils.spam_protection' local SpamProtection = require 'utils.spam_protection'
local BiterHealthBooster = require 'modules.biter_health_booster_v2' local BiterHealthBooster = require 'modules.biter_health_booster_v2'
local Explosives = require 'modules.explosives'
local WD = require 'modules.wave_defense.table' local WD = require 'modules.wave_defense.table'
local Math2D = require 'math2d' local Math2D = require 'math2d'
@@ -1038,16 +1039,6 @@ local function on_player_used_capsule(event)
return return
end end
if rpg_t.level < object.level then
return p(({'rpg_main.low_level'}), Color.fail)
end
if not object.enabled then
return
end
local obj_name = object.obj_to_create
local position = event.position local position = event.position
if not position then if not position then
return return
@@ -1059,6 +1050,16 @@ local function on_player_used_capsule(event)
right_bottom = {x = position.x + radius, y = position.y + radius} right_bottom = {x = position.x + radius, y = position.y + radius}
} }
if rpg_t.level < object.level then
return p(({'rpg_main.low_level'}), Color.fail)
end
if not object.enabled then
return
end
local obj_name = object.obj_to_create
if not Math2D.bounding_box.contains_point(area, player.position) then if not Math2D.bounding_box.contains_point(area, player.position) then
player.print(({'rpg_main.not_inside_pos'}), Color.fail) player.print(({'rpg_main.not_inside_pos'}), Color.fail)
return return
@@ -1090,17 +1091,41 @@ local function on_player_used_capsule(event)
else else
force = 'player' force = 'player'
end end
if object.obj_to_create == 'suicidal_comfylatron' then if obj_name == 'suicidal_comfylatron' then
Functions.suicidal_comfylatron(position, surface) Functions.suicidal_comfylatron(position, surface)
p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success) p(({'rpg_main.suicidal_comfylatron', 'Suicidal Comfylatron'}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost rpg_t.mana = rpg_t.mana - object.mana_cost
elseif object.obj_to_create == 'warp-gate' then elseif obj_name == 'repair_aoe' then
local ents = Functions.repair_aoe(player, position)
p(({'rpg_main.repair_aoe', ents}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost
elseif obj_name == 'pointy_explosives' then
local entities =
player.surface.find_entities_filtered {force = player.force, type = 'container', area = {{position.x - 5, position.y - 5}, {position.x + 5, position.y + 5}}}
local detonate_chest
for i = 1, #entities do
local e = entities[i]
detonate_chest = e
end
local success = Explosives.detonate_chest(detonate_chest)
if success then
player.print(({'rpg_main.detonate_chest'}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost
else
player.print(({'rpg_main.detonate_chest_failed'}), Color.fail)
end
elseif obj_name == 'warp-gate' then
player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface) player.teleport(surface.find_non_colliding_position('character', game.forces.player.get_spawn_position(surface), 3, 0, 5), surface)
rpg_t.mana = 0 rpg_t.mana = 0
Functions.damage_player_over_time(player, math.random(8, 16)) Functions.damage_player_over_time(player, math.random(8, 16))
player.play_sound {path = 'utility/armor_insert', volume_modifier = 1} player.play_sound {path = 'utility/armor_insert', volume_modifier = 1}
p(({'rpg_main.warped_ok'}), Color.info) p(({'rpg_main.warped_ok'}), Color.info)
rpg_t.mana = rpg_t.mana - object.mana_cost rpg_t.mana = rpg_t.mana - object.mana_cost
elseif obj_name == 'fish' then -- spawn in some fish
player.insert({name = 'raw-fish', count = object.amount})
p(({'rpg_main.object_spawned', 'raw-fish'}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost
elseif projectile_types[obj_name] then -- projectiles elseif projectile_types[obj_name] then -- projectiles
for i = 1, object.amount do for i = 1, object.amount do
local damage_area = { local damage_area = {
@@ -1121,16 +1146,27 @@ local function on_player_used_capsule(event)
surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1}) surface.create_entity({name = obj_name, position = position, force = force, target = target_pos, speed = 1})
p(({'rpg_main.object_spawned', obj_name}), Color.success) p(({'rpg_main.object_spawned', obj_name}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost rpg_t.mana = rpg_t.mana - object.mana_cost
elseif object.obj_to_create == 'fish' then -- spawn in some fish
player.insert({name = 'raw-fish', count = object.amount})
p(({'rpg_main.object_spawned', 'raw-fish'}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost
elseif surface.can_place_entity {name = obj_name, position = position} then elseif surface.can_place_entity {name = obj_name, position = position} then
if object.biter then if object.biter then
local e = surface.create_entity({name = obj_name, position = position, force = force}) local e = surface.create_entity({name = obj_name, position = position, force = force})
tame_unit_effects(player, e) tame_unit_effects(player, e)
elseif object.aoe then
for x = 1, -1, -1 do
for y = 1, -1, -1 do
local pos = {x = position.x + x, y = position.y + y}
if surface.can_place_entity {name = obj_name, position = pos} then
if object.mana_cost > rpg_t.mana then
break
end
local e = surface.create_entity({name = obj_name, position = pos, force = force})
e.direction = player.character.direction
rpg_t.mana = rpg_t.mana - object.mana_cost
end
end
end
else else
surface.create_entity({name = obj_name, position = position, force = force}) local e = surface.create_entity({name = obj_name, position = position, force = force})
e.direction = player.character.direction
end end
p(({'rpg_main.object_spawned', obj_name}), Color.success) p(({'rpg_main.object_spawned', obj_name}), Color.success)
rpg_t.mana = rpg_t.mana - object.mana_cost rpg_t.mana = rpg_t.mana - object.mana_cost
@@ -1140,7 +1176,7 @@ local function on_player_used_capsule(event)
end end
end end
local msg = player.name .. ' casted ' .. object.obj_to_create .. '. ' local msg = player.name .. ' casted ' .. obj_name .. '. '
rpg_t.last_spawned = game.tick + object.tick rpg_t.last_spawned = game.tick + object.tick
Functions.update_mana(player) Functions.update_mana(player)

View File

@@ -10,10 +10,10 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 60, mana_cost = 60,
tick = 100, tick = 100,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/stone-wall' sprite = 'recipe/stone-wall'
} }
spells[#spells + 1] = { spells[#spells + 1] = {
name = {'entity-name.wooden-chest'}, name = {'entity-name.wooden-chest'},
obj_to_create = 'wooden-chest', obj_to_create = 'wooden-chest',
@@ -21,6 +21,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 50, mana_cost = 50,
tick = 100, tick = 100,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/wooden-chest' sprite = 'recipe/wooden-chest'
} }
@@ -31,6 +32,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 110, mana_cost = 110,
tick = 200, tick = 200,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/iron-chest' sprite = 'recipe/iron-chest'
} }
@@ -41,6 +43,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 150, mana_cost = 150,
tick = 300, tick = 300,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/steel-chest' sprite = 'recipe/steel-chest'
} }
@@ -51,6 +54,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 80, mana_cost = 80,
tick = 100, tick = 100,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/transport-belt' sprite = 'recipe/transport-belt'
} }
@@ -61,6 +65,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 110, mana_cost = 110,
tick = 200, tick = 200,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/fast-transport-belt' sprite = 'recipe/fast-transport-belt'
} }
@@ -71,6 +76,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 150, mana_cost = 150,
tick = 300, tick = 300,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/express-transport-belt' sprite = 'recipe/express-transport-belt'
} }
@@ -81,6 +87,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 80, mana_cost = 80,
tick = 100, tick = 100,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/underground-belt' sprite = 'recipe/underground-belt'
} }
@@ -91,6 +98,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 110, mana_cost = 110,
tick = 200, tick = 200,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/fast-underground-belt' sprite = 'recipe/fast-underground-belt'
} }
@@ -101,6 +109,7 @@ function Public.conjure_items()
type = 'item', type = 'item',
mana_cost = 150, mana_cost = 150,
tick = 300, tick = 300,
aoe = true,
enabled = true, enabled = true,
sprite = 'recipe/express-underground-belt' sprite = 'recipe/express-underground-belt'
} }
@@ -111,6 +120,7 @@ function Public.conjure_items()
type = 'entity', type = 'entity',
mana_cost = 80, mana_cost = 80,
tick = 350, tick = 350,
aoe = true,
enabled = true, enabled = true,
sprite = 'entity/sand-rock-big' sprite = 'entity/sand-rock-big'
} }
@@ -222,6 +232,36 @@ function Public.conjure_items()
enabled = true, enabled = true,
sprite = 'recipe/rocket' sprite = 'recipe/rocket'
} }
spells[#spells + 1] = {
name = {'spells.pointy_explosives'},
obj_to_create = 'pointy_explosives',
target = true,
amount = 1,
range = 0,
damage = true,
force = 'player',
level = 70,
type = 'special',
mana_cost = 100,
tick = 100,
enabled = true,
sprite = 'recipe/explosives'
}
spells[#spells + 1] = {
name = {'spells.repair_aoe'},
obj_to_create = 'repair_aoe',
target = true,
amount = 1,
range = 50,
damage = false,
force = 'player',
level = 50,
type = 'special',
mana_cost = 200,
tick = 100,
enabled = true,
sprite = 'recipe/repair_pack'
}
spells[#spells + 1] = { spells[#spells + 1] = {
name = {'spells.acid_stream'}, name = {'spells.acid_stream'},
obj_to_create = 'acid-stream-spitter-big', obj_to_create = 'acid-stream-spitter-big',