Code: Select all
if not bobmods then bobmods = {} end
if not bobmods.classes then bobmods.classes = {} end
bobmods.classes.players = {}
bobmods.classes.players["bob-player-miner"] = util.table.deepcopy(data.raw.player.player)
bobmods.lib.table_merge(bobmods.classes.players["bob-player-miner"],
{
name = "bob-player-miner",
max_health = 80,
healing_per_tick = 0.008,
crafting_categories = {"crafting", "smelting"},
inventory_size = 60,
build_distance = 5,
reach_distance = 5,
reach_resource_distance = 3.5,
running_speed = 0.12,
mining_speed = 0.1,
}
)
bobmods.classes.players["bob-player-scout"] = util.table.deepcopy(data.raw.player.player)
bobmods.lib.table_merge(bobmods.classes.players["bob-player-scout"],
{
name = "bob-player-scout",
max_health = 125,
healing_per_tick = 0.0125,
inventory_size = 45,
build_distance = 5,
reach_distance = 5,
running_speed = 0.2,
}
)
bobmods.classes.players["bob-player-builder"] = util.table.deepcopy(data.raw.player.player)
bobmods.lib.table_merge(bobmods.classes.players["bob-player-builder"],
{
name = "bob-player-builder",
max_health = 80,
healing_per_tick = 0.008,
inventory_size = 80,
build_distance = 8,
reach_distance = 8,
running_speed = 0.12,
}
)
for index, player in pairs(players) do
data:extend({
bobmods.classes.players[index]
})
end
--[[
for index, player in pairs(players) do
data.raw.player[player.name].inventory_size = data.raw.player[player.name].inventory_size + data.raw.player.player.inventory_size - 60
end
{
name = "player",
max_health = 100,
healing_per_tick = 0.01,
crafting_categories = {"crafting"},
mining_categories = {"basic-solid"},
inventory_size = 60,
build_distance = 6,
reach_distance = 6,
reach_resource_distance = 2.7,
drop_item_distance = 6,
item_pickup_distance = 1,
loot_pickup_distance = 2,
running_speed = 0.15,
mining_speed = 0.01,
},
]]--
But as you can see, I outlined 3 classes, Builder, Miner and Scout.
I don't think there's a crafting speed modifier in the data stage, else I would have modified that value on the builder, but I think you can give a player crafting speed bonus via scripting.
Anyway. This is from my multiple avatars mod, the idea being you can build additional robot bodies and switch between them, like a fast way of getting to a remote outpost, except you can't take anything with you. During the progress of that mod I actually changed to just using multiple versions of the same player body, but was having issues with the load/save and logging off a multiplayer stuff. This is a problem that was able to be solved in 0.13, and someone else made a mod for that before I could finish mine, so I shelved it.
Back in 0.12, whatever body you were in was classed as your body, so when you logged off a multiplayer game, that body disappeared with you, and your original body was left in the game idle, what should happen is that you switch back to your main body and that disappears. Also when you died, that body died and it presented a game over message, what should happen is it switches back to your main body. 0.13 added other scripts to the mix, such as on_pre_player_death etc so you can intercept this and return control back to your main body before it fires the actual death event, same with logging off.
In any case, now that when you die in single player, you can respawn the same as you do when you die in multiplayer, I was considering adding a "please select a class" dialogue on spawn and game start, to let you select between an option of bodies. The main issue with it is that it isn't easy to switch between them(Delete and create new) and copy an inventory across, especially if such inventories include items that contain items (Like blueprint books, or modular armor or vehicles with grids), so I would go for an on spawn system, or multiple bodies only, meaning if you want to change class of your primary body, you have to die. I might think of other options later.
Anyway, I was wondering what you guys think of the idea, and if I should pursue this any further.