2020-12-18 07:08:55 +00:00
-- local value settings
local player_speed = 2 --when in the minigame
local player_jump = 1.3 --when in the minigame
local stick_knockback = 30 --multiplier for how hard the stick hits
local stick_vault_reach = 3 -- how close to the pointed node must the player be to vault
local stick_vault_timeout = 1 -- int timer for how long the vault cannot be used after it is used
2020-12-18 07:44:17 +00:00
local allow_swap_distance = 3 -- if an opponent is within this distance, then if the player uses the pushstick with the shift key pressed, the players switch positions.
2020-12-18 07:08:55 +00:00
2020-12-19 12:45:20 +01:00
if not minetest.get_modpath ( " lib_chatcmdbuilder " ) then
dofile ( minetest.get_modpath ( " sumo " ) .. " /chatcmdbuilder.lua " )
end
2020-12-18 07:08:55 +00:00
minetest.register_craftitem ( " sumo:pushstick " , {
description = " Push Stick " ,
inventory_image = " default_stick.png " ,
stack_max = 1 ,
2020-12-18 08:06:37 +00:00
wield_scale = { x = 2 , y = 2 , z = 2 } ,
2020-12-18 07:08:55 +00:00
on_use = function ( itemstack , user , pointed_thing )
local sound = ' swish ' .. math.random ( 1 , 4 )
minetest.sound_play ( sound , {
pos = user : get_pos ( ) ,
max_hear_distance = 5 ,
gain = 10.0 ,
} )
if pointed_thing == nil then return end
if pointed_thing.type == ' object ' then
if minetest.is_player ( pointed_thing.ref ) == true then
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
local dir = user : get_look_dir ( )
2020-12-18 07:44:17 +00:00
local keys = user : get_player_control ( )
local swap = false
local hitted_pos = pointed_thing.ref : get_pos ( )
local hitter_pos = user : get_pos ( )
2020-12-19 12:11:50 +01:00
if keys.sneak and vector.distance ( hitted_pos , hitter_pos ) < 3 then
2020-12-18 07:44:17 +00:00
swap = true
user : move_to ( hitted_pos , true )
pointed_thing.ref : move_to ( hitter_pos , true )
pointed_thing.ref : add_player_velocity ( vector.multiply ( { x = - dir.x , y = dir.y , z = - dir.z } , stick_knockback / 2 ) )
else
pointed_thing.ref : add_player_velocity ( vector.multiply ( dir , stick_knockback ) )
if not swap then
local sound = ' thwack ' .. math.random ( 1 , 3 )
minetest.sound_play ( sound , {
pos = user : get_pos ( ) ,
max_hear_distance = 10 ,
gain = 10.0 ,
} )
local sound = ' hurt ' .. math.random ( 1 , 2 )
minetest.sound_play ( sound , {
to_player = pointed_thing.ref : get_player_name ( ) ,
pos = user : get_pos ( ) ,
gain = 10.0 ,
} )
end
end
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
end
end
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
end ,
on_drop = function ( ) end ,
on_place = function ( itemstack , placer , pointed_thing )
if pointed_thing == nil then return end
if pointed_thing.type == ' node ' then
if vector.distance ( pointed_thing.under , placer : get_pos ( ) ) < stick_vault_reach then
local first_use = false
local imeta = itemstack : get_meta ( )
local old_time = imeta : get_int ( ' old_time ' )
local current_time = minetest.get_gametime ( )
if old_time == 0 or old_time == nil then
2020-12-19 12:11:50 +01:00
first_use = true
2020-12-18 07:08:55 +00:00
end
if first_use or current_time > old_time + stick_vault_timeout then
local lookvect = placer : get_look_dir ( )
local pushvect = vector.normalize ( { x = lookvect.x , z = lookvect.z , y = math.sqrt ( 1 - ( lookvect.y * lookvect.y ) ) } )
--gives a unit vector that is 90 deg offset in the vert direction
local force = 10 * vector.length ( vector.normalize ( { x = lookvect.x , z = lookvect.z , y = 0 } ) )
placer : add_player_velocity ( vector.multiply ( pushvect , force ) )
--update the staff time for next check
local sound = ' jump ' .. math.random ( 1 , 2 )
minetest.sound_play ( sound , {
pos = placer : get_pos ( ) ,
max_hear_distance = 10 ,
gain = 10.0 ,
} )
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
imeta : set_int ( ' old_time ' , current_time )
return itemstack
end
end
end
end ,
} )
minetest.register_node ( " sumo:player_killer_air " , {
description = " Sumo Arena Player Killer Air " ,
drawtype = " airlike " ,
paramtype = " light " ,
sunlight_propagates = true ,
2020-12-19 12:11:50 +01:00
walkable = false ,
pointable = true ,
diggable = true ,
buildable_to = false ,
2020-12-18 07:08:55 +00:00
drop = " " ,
damage_per_second = 40 ,
groups = { oddly_breakable_by_hand = 1 } ,
} )
minetest.register_node ( " sumo:player_killer_water_source " , {
description = " Sumo Arena Player Killer Water Source " ,
drawtype = " liquid " ,
waving = 3 ,
tiles = {
{
name = " default_water_source_animated.png " ,
backface_culling = false ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 2.0 ,
} ,
} ,
{
name = " default_water_source_animated.png " ,
backface_culling = true ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 2.0 ,
} ,
} ,
} ,
damage_per_second = 40 ,
alpha = 191 ,
paramtype = " light " ,
walkable = false ,
2020-12-19 11:49:00 +00:00
pointable = false ,
2020-12-18 07:08:55 +00:00
diggable = false ,
buildable_to = true ,
is_ground_content = false ,
drop = " " ,
drowning = 1 ,
liquidtype = " source " ,
liquid_alternative_flowing = " sumo:player_killer_water_flowing " ,
liquid_alternative_source = " sumo:player_killer_water_source " ,
liquid_viscosity = 1 ,
post_effect_color = { a = 103 , r = 30 , g = 60 , b = 90 } ,
groups = { water = 3 , liquid = 3 , cools_lava = 1 } ,
sounds = default.node_sound_water_defaults ( ) ,
} )
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
minetest.register_node ( " sumo:player_killer_water_flowing " , {
description = " Sumo Arena Player Killer Water Flowing " ,
drawtype = " flowingliquid " ,
waving = 3 ,
tiles = { " default_water.png " } ,
special_tiles = {
{
name = " default_water_flowing_animated.png " ,
backface_culling = false ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 0.5 ,
} ,
} ,
{
name = " default_water_flowing_animated.png " ,
backface_culling = true ,
animation = {
type = " vertical_frames " ,
aspect_w = 16 ,
aspect_h = 16 ,
length = 0.5 ,
} ,
} ,
} ,
damage_per_second = 200 ,
alpha = 191 ,
paramtype = " light " ,
walkable = false ,
2020-12-19 11:49:00 +00:00
pointable = false ,
2020-12-18 07:08:55 +00:00
diggable = false ,
buildable_to = true ,
is_ground_content = false ,
drop = " " ,
drowning = 1 ,
liquidtype = " flowing " ,
liquid_alternative_flowing = " sumo:player_killer_water_flowing " ,
liquid_alternative_source = " sumo:player_killer_water_source " ,
liquid_viscosity = 1 ,
post_effect_color = { a = 103 , r = 30 , g = 60 , b = 90 } ,
groups = { water = 3 , liquid = 3 , not_in_creative_inventory = 1 ,
cools_lava = 1 } ,
sounds = default.node_sound_water_defaults ( ) ,
} )
arena_lib.register_minigame ( " sumo " , {
prefix = " [Sumo] " ,
hub_spawn_point = { x = 0 , y = 20 , z = 0 } ,
show_minimap = false ,
time_mode = 2 ,
join_while_in_progress = false ,
keep_inventory = false ,
in_game_physics = {
speed = player_speed ,
jump = player_jump ,
sneak = false ,
} ,
2020-12-19 12:47:34 +01:00
hotbar = {
slots = 1 ,
background_image = " sumo_gui_hotbar.png "
} ,
2020-12-19 12:11:50 +01:00
disabled_damage_types = { " punch " } ,
2020-12-18 07:08:55 +00:00
2020-12-19 12:11:50 +01:00
player_properties = {
2020-12-18 07:08:55 +00:00
} ,
} )
arena_lib.on_load ( " sumo " , function ( arena )
local item = ItemStack ( " sumo:pushstick " )
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
for pl_name , stats in pairs ( arena.players ) do
local player = minetest.get_player_by_name ( pl_name )
player : get_inventory ( ) : set_stack ( " main " , 1 , item )
end
2020-12-15 21:38:45 +00:00
2020-12-19 12:11:50 +01:00
end )
2020-12-18 07:08:55 +00:00
arena_lib.on_time_tick ( ' sumo ' , function ( arena )
return
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
--if the game times out
arena_lib.on_timeout ( ' sumo ' , function ( arena )
local winner_names = { }
for p_name , p_stats in pairs ( arena.players ) do
table.insert ( winner_names , p_name )
end
2020-12-19 12:11:50 +01:00
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
arena_lib.load_celebration ( ' sumo ' , arena , winner_names )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
arena_lib.on_death ( ' sumo ' , function ( arena , p_name , reason )
arena_lib.remove_player_from_arena ( p_name , 1 )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
end )
2020-12-15 21:38:45 +00:00
2020-12-19 12:11:50 +01:00
minetest.register_privilege ( " sumo_admin " , {
2020-12-18 07:08:55 +00:00
description = " With this you can use /sumo create, edit "
} )
2020-12-19 12:11:50 +01:00
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
ChatCmdBuilder.new ( " sumo " , function ( cmd )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
-- create arena
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
-- create arena
cmd : sub ( " create :arena " , function ( name , arena_name )
arena_lib.create_arena ( name , " sumo " , arena_name )
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
cmd : sub ( " create :arena :minplayers:int :maxplayers:int " , function ( name , arena_name , min_players , max_players )
arena_lib.create_arena ( name , " sumo " , arena_name , min_players , max_players )
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
-- remove arena
cmd : sub ( " remove :arena " , function ( name , arena_name )
arena_lib.remove_arena ( name , " sumo " , arena_name )
end )
2020-12-15 21:38:45 +00:00
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
-- list of the arenas
cmd : sub ( " list " , function ( name )
arena_lib.print_arenas ( name , " sumo " )
end )
2020-12-15 21:38:45 +00:00
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
-- enter editor mode
cmd : sub ( " edit :arena " , function ( sender , arena )
arena_lib.enter_editor ( sender , " sumo " , arena )
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
-- enable and disable arenas
cmd : sub ( " enable :arena " , function ( name , arena )
arena_lib.enable_arena ( name , " sumo " , arena )
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
cmd : sub ( " disable :arena " , function ( name , arena )
arena_lib.disable_arena ( name , " sumo " , arena )
end )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
end , {
description = [ [
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
( / help sumo )
2020-12-15 21:38:45 +00:00
2020-12-18 07:08:55 +00:00
Use this to configure your arena :
- create < arena name > [ min players ] [ max players ]
2020-12-19 12:11:50 +01:00
- edit < arena name >
2020-12-18 07:08:55 +00:00
- enable < arena name >
2020-12-19 12:11:50 +01:00
2020-12-18 07:08:55 +00:00
Other commands :
- remove < arena name >
- disable < arena >
] ] ,
privs = { sumo_admin = true }
} )