1
0
mirror of https://github.com/Refactorio/RedMew.git synced 2025-03-03 14:53:01 +02:00

Merge pull request #447 from SimonFlapse/Bot-mining-xp

[Diggy] Bot mining experience
This commit is contained in:
Lynn 2018-11-24 16:36:32 +01:00 committed by GitHub
commit 247d13e074
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,7 @@ end)
local Config = {}
local string_format = string.format
local alien_coin_modifiers = require 'map_gen.Diggy.Config'.features.ArtefactHunting.alien_coin_modifiers
local floor = math.floor
local level_up_formula = (function (level_reached)
local floor = math.floor
@ -211,19 +212,42 @@ end
---@param event LuaEvent
local function on_entity_died (event)
local entity = event.entity
local force = entity.force
if force.name ~= 'enemy' then
return
end
local force = event.force
local cause = event.cause
--For bot mining
if not cause or cause.type ~= 'player' or not cause.valid then
local exp
if force == 'player' then
if entity.name == 'sand-rock-big' then
exp = floor(sand_rock_xp/2)
elseif entity.name == 'rock-huge' then
exp = floor(rock_huge_xp/2)
else
return
end
elseif cause and (cause.name == 'artillery-turret' or cause.name == 'gun-turret' or cause.name == 'laser-turret' or cause.name == 'flamethrower-turret') then
exp = Config.XP['enemy_killed'] * alien_coin_modifiers[entity.name]
local text = string_format('+ %d XP', exp)
Game.print_floating_text(cause.surface, cause.position, text, {r = 144, g = 202, b = 249})
ForceControl.add_experience(force, exp)
return
else
return
end
local text = string_format('+ %d XP', exp)
Game.print_floating_text(entity.surface, entity.position, text, {r = 144, g = 202, b = 249})
ForceControl.add_experience(force, exp)
return
end
if entity.force.name ~= 'enemy' then
return
end
local exp = Config.XP['enemy_killed'] * alien_coin_modifiers[entity.name]
local text = string_format('Killed %s! + %d XP', entity.name, exp)
local text = string_format('+ %d XP', exp)
local player_index = cause.player.index
Game.print_player_floating_text_position(player_index, text, {r = 144, g = 202, b = 249},-1, -0.5)
ForceControl.add_experience(force, exp)