Add the intro cutscene, a start to the map, and various other things.
This commit is contained in:
parent
d0c0a3ebb6
commit
1b2199705b
46 changed files with 1401 additions and 91 deletions
|
|
@ -36,27 +36,68 @@ Player = setmetatable({
|
|||
shaded = false
|
||||
}
|
||||
|
||||
p:hud_set_flags {
|
||||
healthbar = false,
|
||||
breathbar = false,
|
||||
hotbar = artifact.debug,
|
||||
minimap = false,
|
||||
basic_debug = artifact.debug,
|
||||
crosshair = false, -- It gets set to true once we can play.
|
||||
wielditem = false, -- Ditto.
|
||||
chat = false, -- We provide our own implementation of the chat HUD.
|
||||
}
|
||||
|
||||
-- The following exists to make sure that whatever physics
|
||||
-- settings the server may have set are transparently ignored.
|
||||
local defaults = {
|
||||
speed_walk = 4,
|
||||
speed_crouch = 1.35,
|
||||
speed_fast = 20,
|
||||
speed_climb = 3,
|
||||
speed_jump = 6.5,
|
||||
gravity = 9.81,
|
||||
liquid_fluidity = 1,
|
||||
liquid_fluidity_smooth = 0.5,
|
||||
liquid_sink = 10,
|
||||
acceleration_default = 3,
|
||||
acceleration_air = 2,
|
||||
acceleration_fast = 10,
|
||||
}
|
||||
|
||||
local override = {
|
||||
speed = 1,
|
||||
sneak = true,
|
||||
sneak_glitch = false,
|
||||
new_move = true,
|
||||
}
|
||||
|
||||
for key, def_value in pairs(defaults) do
|
||||
local setting_name = "movement_"..key
|
||||
local current = tonumber(minetest.settings:get(setting_name)) or def_value
|
||||
override[key] = def_value /current
|
||||
end
|
||||
|
||||
p:set_physics_override(override)
|
||||
|
||||
-- No unreasonable FOV settings here.
|
||||
p:set_fov(72)
|
||||
|
||||
m.hud = {}
|
||||
m.poi = {}
|
||||
m.chat = {}
|
||||
|
||||
if not artifact.debug then
|
||||
p:set_inventory_formspec ""
|
||||
end
|
||||
|
||||
if m.character == "vix" then
|
||||
artifact.apply_vix(m)
|
||||
else
|
||||
artifact.apply_key(m)
|
||||
end
|
||||
|
||||
p:hud_set_flags {
|
||||
healthbar = false,
|
||||
breathbar = false,
|
||||
hotbar = artifact.debug,
|
||||
minimap = false,
|
||||
basic_debug = false,
|
||||
chat = false, -- We provide our own implementation of the chat HUD.
|
||||
}
|
||||
|
||||
m.hud = {}
|
||||
m.poi = {}
|
||||
m.chat = {}
|
||||
m:create_hud()
|
||||
|
||||
m:set_hotbar_size(8)
|
||||
-- Let us build in debug mode, but ensure we always wield the hand item otherwise.
|
||||
m:set_hotbar_size(artifact.debug and 8 or 1)
|
||||
|
||||
m.ctl = p:get_player_control()
|
||||
|
||||
|
|
@ -74,6 +115,11 @@ Player = setmetatable({
|
|||
m.pos = pos
|
||||
m.pos.y = m.pos.y +m.eye_height
|
||||
|
||||
local state = artifact.story.get_state()
|
||||
|
||||
-- Sleep if we are not yet ready for the player to do things.
|
||||
if not artifact.debug and state <= artifact.story.states.init then return end
|
||||
|
||||
-- MARK: Pointing callbacks
|
||||
|
||||
local pointed_found = nil
|
||||
|
|
@ -221,7 +267,8 @@ Player = setmetatable({
|
|||
|
||||
-- MARK: Radial menu handling
|
||||
|
||||
if ctl.place and not m.ctl.place and wi:get_name():find "artifact:input" and (not m.pointed_obj or m.pointed_obj._no_interact) then
|
||||
-- This should only work once we have Vix, since we can't use it without her.
|
||||
if state >= artifact.story.states.main and ctl.place and not m.ctl.place and wi:get_name():find "artifact:input" and (not m.pointed_obj or m.pointed_obj._no_interact) then
|
||||
artifact.show_radial_menu(m, {
|
||||
name = "construct",
|
||||
"test",
|
||||
|
|
@ -288,26 +335,33 @@ Player = setmetatable({
|
|||
end
|
||||
end
|
||||
|
||||
-- MARK: Health regen
|
||||
|
||||
if m.next_regen and time -m.next_regen >= 0 then
|
||||
m.object:set_hp(m.object:get_hp() +1)
|
||||
end
|
||||
|
||||
m.ctl = ctl
|
||||
m.yaw = yaw
|
||||
m.pitch = pitch
|
||||
m.dir = dir
|
||||
end,
|
||||
set_character = function(m, to)
|
||||
m.character = to
|
||||
m.meta:set_string("character", to)
|
||||
end,
|
||||
-- Initialize the player's primary HUD display based on saved state.
|
||||
create_hud = function(m)
|
||||
add_health_bar = function(m)
|
||||
m.healthbar = m.object:hud_add {
|
||||
type = "statbar",
|
||||
position = {x=0.5,y=1},
|
||||
offset = {x=-27 *5,y=artifact.debug and -96 or -30},
|
||||
offset = {x=-27 *5,y=artifact.debug and -96 or -40},
|
||||
scale = {x=4,y=4},
|
||||
alignment = {x=-1, y=-1},
|
||||
size = {x=27,y=27},
|
||||
text = "artifact_heart_vix.png",
|
||||
text = m.character == "vix" and "artifact_heart_vix.png" or "artifact_heart.png",
|
||||
text2 = "artifact_heart_bg.png",
|
||||
number = 20
|
||||
number = 20,
|
||||
item = 20,
|
||||
}
|
||||
end,
|
||||
set_hotbar_size = function(m, slots)
|
||||
|
|
@ -326,6 +380,21 @@ Player = setmetatable({
|
|||
end
|
||||
})
|
||||
|
||||
-- Mirror the player's HP in our custom HUD.
|
||||
-- (We need a custom HUD so that we can change its appearance dynamically.)
|
||||
minetest.register_on_player_hpchange(function(p, delta)
|
||||
local m = artifact.players[p:get_player_name()]
|
||||
local hp = p:get_hp() +delta
|
||||
if m.healthbar then
|
||||
p:hud_change(m.healthbar, "number", hp)
|
||||
end
|
||||
if hp < 20 then
|
||||
m.next_regen = minetest.get_us_time() +5000000
|
||||
else
|
||||
m.next_regen = nil
|
||||
end
|
||||
end)
|
||||
|
||||
local _hand = minetest.registered_items[""]
|
||||
|
||||
function artifact.register_input(name)
|
||||
|
|
@ -347,10 +416,18 @@ function artifact.register_input(name)
|
|||
range = 0,
|
||||
on_drop = function(s, p, pos)
|
||||
local m = artifact.players[p:get_player_name()]
|
||||
if artifact.debug or artifat.story.state > artifact.story.states.pre_vix then
|
||||
if artifact.debug or artifact.story.get_state() > artifact.story.states.pre_vix then
|
||||
artifact.swap_character(m)
|
||||
end
|
||||
return s
|
||||
end,
|
||||
on_use = function(s, p)
|
||||
local m = artifact.players[p:get_player_name()]
|
||||
if m.character == "vix" then
|
||||
artifact.do_shoot(m)
|
||||
else
|
||||
artifact.do_whack(m)
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue