mirror of
https://github.com/Refactorio/RedMew.git
synced 2025-01-18 03:21:47 +02:00
WIP - airstrike command
- Type `/strike [gps=x,y,surface] to send a large cloud of poison into the enemy - Searches a chest near spawn for poison capsules. Current cost for command is 100 capsules but could be balanced. - Needs market items adding for technology research, bought with coins. - Variables strikeCount and strikeRadius start low. As the market upgrades are made (start at 5k each?) the size of teh strike and amount of capsules increases. - Should be balanced to allow use from mid-game onwards. Don't allow early game use as manual throwing is fine for early outposts. This should be to speed up the boring end-game clearing of worms.
This commit is contained in:
parent
e7295d9579
commit
fdb0cf3469
@ -8,6 +8,7 @@ local Global = require 'utils.global'
|
||||
local Ranks = require 'resources.ranks'
|
||||
local Core = require 'utils.core'
|
||||
local Color = require 'resources.color_presets'
|
||||
local set_timeout_in_ticks = Task.set_timeout_in_ticks
|
||||
|
||||
local Public = {}
|
||||
|
||||
@ -177,6 +178,64 @@ local function spy(args, player)
|
||||
end
|
||||
end
|
||||
|
||||
local spawn_poison_callback = Token.register(function(data)
|
||||
local r = data.r
|
||||
data.s.create_entity{name = "poison-capsule", position={0,0}, target={data.xpos + math.random(-r,r), data.ypos + math.random(-r,r)}, speed=10}
|
||||
end)
|
||||
|
||||
local function strike(args, player)
|
||||
local player_name = player.name
|
||||
local s = player.surface
|
||||
local location_string = args.location
|
||||
local coords = {}
|
||||
local strikeCost = 100
|
||||
|
||||
|
||||
for m in string.gmatch( location_string, "%-?%d+" ) do
|
||||
table.insert(coords, tonumber(m))
|
||||
end
|
||||
-- Do some checks then reveal the pinged map and remove 1000 coins
|
||||
if #coords < 2 then
|
||||
player.print({'command_description.crash_site_strike_invalid'}, Color.fail)
|
||||
return
|
||||
end
|
||||
|
||||
local entities = s.find_entities_filtered {position = {-0.5, -3.5}, type 'container', limit=1}
|
||||
dropbox = entities[1]
|
||||
if dropbox == nil then
|
||||
player.print("Someone removed the chest. Replace it here: [gps=-0.5,-3.5,redmew] ")
|
||||
return
|
||||
end
|
||||
|
||||
local inv = dropbox.get_inventory(defines.inventory.chest)
|
||||
capCount = inv.get_item_count("poison-capsule")
|
||||
|
||||
if capCount < strikeCost then
|
||||
player.print("To send an air strike, load " .. strikeCost - capCount .. " more poison capsules into the payment chest [gps=-0.5,-3.5,redmew]")
|
||||
return
|
||||
end
|
||||
|
||||
local xpos=coords[1]
|
||||
local ypos=coords[2]
|
||||
local r = 20
|
||||
inv.remove({name = "poison-capsule", count = 100})
|
||||
game.print(player.name .. " called an air strike [gps=" .. xpos .. "," .. ypos ..",redmew]")
|
||||
player.force.chart(s, {{xpos-32, ypos-32}, {xpos+32, ypos+32}})
|
||||
for j=1,15 do
|
||||
-- s.create_entity{name = "poison-capsule", position={0,0}, target={xpos + math.random(-r,r), ypos + math.random(-r,r)}, speed=10}
|
||||
set_timeout_in_ticks(
|
||||
30*j,
|
||||
spawn_poison_callback,
|
||||
{s = s, xpos = xpos, ypos=ypos, count = count, r=r}
|
||||
)
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
Command.add(
|
||||
'crash-site-restart-abort',
|
||||
{
|
||||
@ -234,6 +293,18 @@ Command.add(
|
||||
},
|
||||
spy
|
||||
)
|
||||
|
||||
Command.add(
|
||||
'strike',
|
||||
{
|
||||
description = {'command_description.strike'},
|
||||
arguments = {'location'},
|
||||
capture_excess_arguments = true,
|
||||
required_rank = Ranks.guest,
|
||||
allowed_by_server = false
|
||||
},
|
||||
strike
|
||||
)
|
||||
end
|
||||
|
||||
return Public
|
||||
|
@ -771,6 +771,31 @@ local function init(config)
|
||||
upgrade_rate = 0.5,
|
||||
upgrade_base_cost = 500,
|
||||
upgrade_cost_base = 2,
|
||||
{
|
||||
price = 10000,
|
||||
name = 'poison-capsule',
|
||||
name_label = 'Airstrike Radius',
|
||||
description = 'Upgrade the airstrike radius. Use /strike'
|
||||
},
|
||||
{
|
||||
price = 10000,
|
||||
name = 'artillery-targeting-remote',
|
||||
name_label = 'Airstrike Damage',
|
||||
description = 'Upgrade the airstrike damage. Use /strike'
|
||||
},
|
||||
--https://github.com/Refactorio/RedMew/blob/38a5948cb463d6fa10553d403868c76f216ca33a/features/market.lua
|
||||
--[[local function market_item_purchased(event)
|
||||
local item_name = event.item.name
|
||||
if item_name == 'temporary-running-speed-bonus' then
|
||||
boost_player_running_speed(event.player)
|
||||
return
|
||||
end
|
||||
|
||||
if item_name == 'temporary-mining-speed-bonus' then
|
||||
boost_player_mining_speed(event.player)
|
||||
return
|
||||
end
|
||||
end]]--
|
||||
{name = 'wood', price = 1},
|
||||
{name = 'iron-plate', price = 2},
|
||||
{name = 'stone', price = 2},
|
||||
@ -812,7 +837,7 @@ local function init(config)
|
||||
[1] = {
|
||||
market = market,
|
||||
[15] = {entity = {name = 'market', force = 'neutral', callback = 'market'}},
|
||||
[18] = {entity = {name = 'wooden-chest', force = 'player'}}
|
||||
[18] = {entity = {name = 'wooden-chest', force = 'player', destructible=false, minable=false}}
|
||||
},
|
||||
[2] = {
|
||||
force = 'player',
|
||||
|
Loading…
Reference in New Issue
Block a user