Add: shield entity
parent
146bdb28fa
commit
03c703dcea
22
README.md
22
README.md
|
@ -390,6 +390,20 @@ Dip throw style gravity modifier.
|
|||
pvp_revamped.projectile_dip_gravity_mul = 1.2
|
||||
```
|
||||
|
||||
#### visual
|
||||
Shield entity position.
|
||||
``` lua
|
||||
pvp_revamped.shield_entity_pos = "0 6 0"
|
||||
```
|
||||
Shield entity rotate.
|
||||
``` lua
|
||||
pvp_revamped.shield_entity_rotate = "-90 180 180"
|
||||
```
|
||||
Shield entity scale.
|
||||
``` lua
|
||||
pvp_revamped.shield_entity_scale = "0.35 0.35"
|
||||
```
|
||||
|
||||
# api
|
||||
Tools can define their own values independent of the config.
|
||||
tool capabilities can work in registered armor as well, but not the other around.
|
||||
|
@ -507,7 +521,13 @@ armor:register_armor("test:shield_test", {
|
|||
-- See hasty_guard_duration in config.
|
||||
hasty_guard_duration = 50000,
|
||||
-- See hasty_shield_mul in config.
|
||||
hasty_shield_mul = 1000}
|
||||
hasty_shield_mul = 1000,
|
||||
-- See shield_entity_pos in config.
|
||||
shield_entity_pos = {x = 0, y = 6, z = 0},
|
||||
-- See shield_entity_rotate in config.
|
||||
shield_entity_rotate = {x = -90, y = 180, z = 180},
|
||||
-- See shield_entity_scale in config.
|
||||
shield_entity_scale = {x = 0.35, y = 0.35}}
|
||||
|
||||
})
|
||||
```
|
||||
|
|
35
config.lua
35
config.lua
|
@ -50,14 +50,6 @@ pvp_revamped.config.projectile_step = tonumber(minetest.settings:get("pvp_revamp
|
|||
pvp_revamped.config.projectile_dist = tonumber(minetest.settings:get("pvp_revamped.projectile_dist")) or 5
|
||||
pvp_revamped.config.projectile_spinning_gravity_mul = tonumber(minetest.settings:get("pvp_revamped.projectile_spinning_gravity_mul")) or 0.5
|
||||
pvp_revamped.config.projectile_dip_gravity_mul = tonumber(minetest.settings:get("pvp_revamped.projectile_dip_gravity_mul")) or 1.2
|
||||
|
||||
local xyz = minetest.settings:get("pvp_revamped.projectile_dip_velocity_dmg_mul") or {1, 2, 1}
|
||||
|
||||
if xyz and type(xyz) == "string" then
|
||||
xyz = minetest.settings:get("pvp_revamped.projectile_dip_velocity_dmg_mul"):split(" ")
|
||||
end
|
||||
|
||||
pvp_revamped.config.projectile_dip_velocity_dmg_mul = {x = tonumber(xyz[1]), y = tonumber(xyz[2]), z = tonumber(xyz[3])}
|
||||
pvp_revamped.config.parry_dmg_mul = tonumber(minetest.settings:get("pvp_revamped.parry_dmg_mul")) or 1.2
|
||||
pvp_revamped.config.counter_dmg_mul = tonumber(minetest.settings:get("pvp_revamped.counter_dmg_mul")) or 1.5
|
||||
pvp_revamped.config.clash_duration = tonumber(minetest.settings:get("pvp_revamped.clash_duration")) or 150000
|
||||
|
@ -65,3 +57,30 @@ pvp_revamped.config.counter_duration = tonumber(minetest.settings:get("pvp_revam
|
|||
pvp_revamped.config.hasty_guard_duration = tonumber(minetest.settings:get("pvp_revamped.hasty_guard_duration")) or 50000
|
||||
pvp_revamped.config.hasty_guard_mul = tonumber(minetest.settings:get("pvp_revamped.hasty_guard_mul")) or 1000
|
||||
pvp_revamped.config.hasty_shield_mul = tonumber(minetest.settings:get("pvp_revamped.hasty_shield_mul")) or 1000
|
||||
|
||||
local function split(string, def)
|
||||
local settings = minetest.settings:get(string)
|
||||
local xyz = settings or def
|
||||
|
||||
if xyz and type(xyz) == "string" then
|
||||
xyz = settings:split(" ")
|
||||
end
|
||||
|
||||
return xyz
|
||||
end
|
||||
|
||||
local xyz = split("pvp_revamped.projectile_dip_velocity_dmg_mul", {1, 2, 1})
|
||||
|
||||
pvp_revamped.config.projectile_dip_velocity_dmg_mul = {x = tonumber(xyz[1]), y = tonumber(xyz[2]), z = tonumber(xyz[3])}
|
||||
|
||||
xyz = split("pvp_revamped.shield_entity_pos", {0, 6, 0})
|
||||
|
||||
pvp_revamped.config.shield_entity_pos = {x = tonumber(xyz[1]), y = tonumber(xyz[2]), z = tonumber(xyz[3])}
|
||||
|
||||
xyz = split("pvp_revamped.shield_entity_rotate", {-90, 180, 180})
|
||||
|
||||
pvp_revamped.config.shield_entity_rotate = {x = tonumber(xyz[1]), y = tonumber(xyz[2]), z = tonumber(xyz[3])}
|
||||
|
||||
xyz = split("pvp_revamped.shield_entity_scale", {0.35, 0.35})
|
||||
|
||||
pvp_revamped.config.shield_entity_scale = {x = tonumber(xyz[1]), y = tonumber(xyz[2]), z = tonumber(xyz[3])}
|
||||
|
|
|
@ -278,6 +278,12 @@ minetest.register_globalstep(function(dtime)
|
|||
active = true
|
||||
end
|
||||
|
||||
if v.entity and not v.shield then
|
||||
v.entity:remove()
|
||||
v.entity = nil
|
||||
active = true
|
||||
end
|
||||
|
||||
if not active then
|
||||
player_data[k] = nil
|
||||
end
|
||||
|
|
29
helper.lua
29
helper.lua
|
@ -1,4 +1,9 @@
|
|||
local player_data = pvp_revamped.player_data
|
||||
local add_item = minetest.add_item
|
||||
local get_player_by_name = minetest.get_player_by_name
|
||||
local shield_entity_pos = pvp_revamped.config.shield_entity_pos
|
||||
local shield_entity_rotate = pvp_revamped.config.shield_entity_rotate
|
||||
local shield_entity_scale = pvp_revamped.config.shield_entity_scale
|
||||
|
||||
-- Helper function to drop an item.
|
||||
function pvp_revamped.drop(player, item, pos)
|
||||
|
@ -13,8 +18,6 @@ function pvp_revamped.drop(player, item, pos)
|
|||
end
|
||||
end
|
||||
|
||||
local player_data = pvp_revamped.player_data
|
||||
|
||||
function pvp_revamped.get_player_data(name)
|
||||
local data = player_data[name] or {}
|
||||
|
||||
|
@ -24,3 +27,25 @@ function pvp_revamped.get_player_data(name)
|
|||
|
||||
return data
|
||||
end
|
||||
|
||||
local get_player_data = pvp_revamped.get_player_data
|
||||
|
||||
function pvp_revamped.create_wield_shield(name, bone, itemname, groups)
|
||||
local data = get_player_data(name)
|
||||
local player = get_player_by_name(name)
|
||||
local object = minetest.add_entity(player:get_pos(), "pvp_revamped:shield", name)
|
||||
|
||||
if object then
|
||||
object:set_attach(player, bone, groups.shield_entity_pos or shield_entity_pos, groups.shield_entity_rotate or shield_entity_rotate)
|
||||
object:set_properties({
|
||||
textures = {itemname},
|
||||
visual_size = groups.shield_entity_scale or shield_entity_scale,
|
||||
})
|
||||
|
||||
if data.entity then
|
||||
data.entity:remove()
|
||||
end
|
||||
|
||||
data.entity = object
|
||||
end
|
||||
end
|
||||
|
|
3
init.lua
3
init.lua
|
@ -6,7 +6,8 @@ dofile(string.format("%s/config.lua", modpath))
|
|||
dofile(string.format("%s/constant.lua", modpath))
|
||||
dofile(string.format("%s/globaldata.lua", modpath))
|
||||
dofile(string.format("%s/helper.lua", modpath))
|
||||
dofile(string.format("%s/entites.lua", modpath))
|
||||
dofile(string.format("%s/projectile_entity.lua", modpath))
|
||||
dofile(string.format("%s/shield_entity.lua", modpath))
|
||||
dofile(string.format("%s/overrides.lua", modpath))
|
||||
dofile(string.format("%s/globalstep.lua", modpath))
|
||||
dofile(string.format("%s/sscsm.lua", modpath))
|
||||
|
|
|
@ -17,6 +17,7 @@ local parry_dmg_mul = pvp_revamped.config.parry_dmg_mul
|
|||
local counter_dmg_mul = pvp_revamped.config.counter_dmg_mul
|
||||
local armor_3d = pvp_revamped.armor_3d
|
||||
local get_player_data = pvp_revamped.get_player_data
|
||||
local create_wield_shield = pvp_revamped.create_wield_shield
|
||||
local player_data = pvp_revamped.player_data
|
||||
local player_persistent_data = pvp_revamped.player_persistent_data
|
||||
local registered_tools = minetest.registered_tools
|
||||
|
@ -121,6 +122,8 @@ minetest.register_on_mods_loaded(function()
|
|||
local data_shield = player_pdata.inventory_armor_shield
|
||||
local data = player_data[name]
|
||||
|
||||
create_wield_shield(name, "Arm_Left", data_shield.name, data_shield.groups)
|
||||
|
||||
data.shield = {pool = data_shield.block_pool, name = data_shield.name, index = data_shield.index, initial_time = time, time = time, duration = data_shield.duration, hasty_guard_duration = data_shield.hasty_guard_duration, armor_inv = true}
|
||||
data.block = nil
|
||||
player_data[name] = data
|
||||
|
@ -215,6 +218,8 @@ minetest.register_on_mods_loaded(function()
|
|||
local data_shield = player_pdata.inventory_armor_shield
|
||||
local data = player_data[name]
|
||||
|
||||
create_wield_shield(name, "Arm_Left", data_shield.name, data_shield.groups)
|
||||
|
||||
data.shield = {pool = data_shield.block_pool, name = data_shield.name, index = data_shield.index, initial_time = time, time = time, duration = data_shield.duration, hasty_guard_duration = data_shield.hasty_guard_duration, armor_inv = true}
|
||||
data.block = nil
|
||||
player_data[name] = data
|
||||
|
@ -226,6 +231,8 @@ minetest.register_on_mods_loaded(function()
|
|||
|
||||
local data = player_data[name]
|
||||
|
||||
create_wield_shield(name, "Arm_Right", k, groups)
|
||||
|
||||
data.shield = {pool = block_pool, name = k, initial_time = time, time = time, duration = duration, hasty_guard_duration = hasty_guard_duration}
|
||||
data.block = nil
|
||||
|
||||
|
@ -268,7 +275,7 @@ if minetest.global_exists("armor") then
|
|||
if armor_shield > 0 then
|
||||
local groups = stack:get_definition().groups
|
||||
|
||||
player_persistent_data[player:get_player_name()].inventory_armor_shield = {name = name, index = i, block_pool = groups.block_pool, duration = groups.duration, hasty_guard_duration = groups.hasty_guard_duration}
|
||||
player_persistent_data[player:get_player_name()].inventory_armor_shield = {name = name, index = i, block_pool = groups.block_pool, duration = groups.duration, hasty_guard_duration = groups.hasty_guard_duration, groups = groups}
|
||||
|
||||
return old_save_armor_inventory(self, player)
|
||||
end
|
||||
|
@ -295,7 +302,7 @@ if minetest.global_exists("armor") then
|
|||
if armor_shield > 0 then
|
||||
local groups = stack:get_definition().groups
|
||||
|
||||
player_persistent_data[player:get_player_name()].inventory_armor_shield = {name = name, index = i, block_pool = groups.block_pool, duration = groups.duration, hasty_guard_duration = groups.hasty_guard_duration}
|
||||
player_persistent_data[player:get_player_name()].inventory_armor_shield = {name = name, index = i, block_pool = groups.block_pool, duration = groups.duration, hasty_guard_duration = groups.hasty_guard_duration, groups = groups}
|
||||
|
||||
return results
|
||||
end
|
||||
|
|
|
@ -9,41 +9,62 @@ end)
|
|||
|
||||
-- Clear up memory if the player leaves.
|
||||
-- Drop any item the player is about to throw on leave.
|
||||
-- Remove the shield entity.
|
||||
minetest.register_on_leaveplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pdata = player_data[name]
|
||||
|
||||
if not player_data[name] then
|
||||
if not pdata then
|
||||
return
|
||||
end
|
||||
|
||||
local throw_data = player_data[name].throw
|
||||
local throw_data = pdata.throw
|
||||
|
||||
if throw_data then
|
||||
drop(player, throw_data.item)
|
||||
end
|
||||
|
||||
local entity = pdata.entity
|
||||
|
||||
if entity then
|
||||
entity:remove()
|
||||
end
|
||||
|
||||
player_data[name] = nil
|
||||
player_persistent_data[name] = nil
|
||||
end)
|
||||
|
||||
-- Drop any item the player is about to throw on death.
|
||||
-- Remove the shield entity.
|
||||
minetest.register_on_dieplayer(function(player)
|
||||
local name = player:get_player_name()
|
||||
local pdata = player_data[name]
|
||||
|
||||
if not player_data[name] then
|
||||
if not pdata then
|
||||
return
|
||||
end
|
||||
|
||||
local throw_data = player_data[name].throw
|
||||
local throw_data = pdata.throw
|
||||
|
||||
if throw_data then
|
||||
drop(player, throw_data.item)
|
||||
|
||||
player_data[name].throw = nil
|
||||
pdata.throw = nil
|
||||
end
|
||||
|
||||
local entity = pdata.entity
|
||||
|
||||
if entity then
|
||||
entity:remove()
|
||||
|
||||
pdata.entity = nil
|
||||
end
|
||||
|
||||
player_data[name] = pdata
|
||||
end)
|
||||
|
||||
-- Drop any item the player is about to throw on shutdown.
|
||||
-- Remove the shield entity.
|
||||
minetest.register_on_shutdown(function()
|
||||
for k, v in pairs(player_data) do
|
||||
local throw_data = v.throw
|
||||
|
@ -51,5 +72,11 @@ minetest.register_on_shutdown(function()
|
|||
if throw_data then
|
||||
drop(player, throw_data.item)
|
||||
end
|
||||
|
||||
local entity = v.entity
|
||||
|
||||
if entity then
|
||||
entity:remove()
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
|
|
@ -131,3 +131,11 @@ pvp_revamped.projectile_dist (Projectile collision range) float 5
|
|||
pvp_revamped.projectile_spinning_gravity_mul (Spinning gravity multiplier) float 0.5
|
||||
# Dip throw style gravity modifier.
|
||||
pvp_revamped.projectile_dip_gravity_mul (Dip gravity multiplier) float 1.2
|
||||
|
||||
[Visual]
|
||||
# Shield entity position.
|
||||
pvp_revamped.shield_entity_pos (Shield position) string "0 6 0"
|
||||
# Shield entity rotate.
|
||||
pvp_revamped.shield_entity_rotate (Shield rotate) string "-90 180 180"
|
||||
# Shield entity scale.
|
||||
pvp_revamped.shield_entity_scale (Shield scale) string "0.35 0.35"
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
-- Entity to display when ever a player blocks with a shield.
|
||||
minetest.register_entity("pvp_revamped:shield", {
|
||||
initial_properties = {
|
||||
physical = false,
|
||||
visual = "wielditem",
|
||||
["selectionbox"] = {0, 0, 0, 0, 0, 0},
|
||||
static_save = false
|
||||
},
|
||||
|
||||
on_activate = function(self, staticdata)
|
||||
self.object:set_armor_groups({immortal = 1})
|
||||
end
|
||||
})
|
|
@ -1,11 +1,12 @@
|
|||
if sscsm then
|
||||
local dash_speed = pvp_revamped.config.dash_speed
|
||||
local barrel_roll_speed = pvp_revamped.config.barrel_roll_speed
|
||||
local get_player_data = pvp_revamped.get_player_data
|
||||
local player_data = pvp_revamped.player_data
|
||||
local player_persistent_data = pvp_revamped.player_persistent_data
|
||||
local create_wield_shield = pvp_revamped.create_wield_shield
|
||||
local get_us_time = minetest.get_us_time
|
||||
local get_player_by_name = minetest.get_player_by_name
|
||||
local dash_speed = pvp_revamped.config.dash_speed
|
||||
local barrel_roll_speed = pvp_revamped.config.barrel_roll_speed
|
||||
local cos = math.cos
|
||||
local sin = math.sin
|
||||
|
||||
|
@ -175,6 +176,8 @@ if sscsm then
|
|||
local data = get_player_data(name)
|
||||
local time = get_us_time()
|
||||
|
||||
create_wield_shield(name, "Arm_Left", data_shield.name, data_shield.groups)
|
||||
|
||||
data.shield = {pool = data_shield.block_pool, name = data_shield.name, index = data_shield.index, initial_time = time, time = time, duration = data_shield.duration, hasty_guard_duration = data_shield.hasty_guard_duration, armor_inv = true}
|
||||
data.block = nil
|
||||
player_data[name] = data
|
||||
|
|
Loading…
Reference in New Issue