Initial Commit

master
Jake Hooper 2020-04-08 00:00:09 -05:00
parent 1f1d0b10d0
commit b6f3d9fab0
32 changed files with 456 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.blend1

38
.luacheckrc Normal file
View File

@ -0,0 +1,38 @@
ignore = {"212"}
globals = {
"renowned_jam",
"mobkit",
"wieldview",
}
read_globals = {
"DIR_DELIM",
"minetest", "core",
"dump", "dump2",
"vector",
"VoxelManip", "VoxelArea",
"PseudoRandom", "PcgRandom",
"ItemStack",
"Settings",
"unpack",
table = {
fields = {
"copy",
"indexof",
"insert_all",
"key_value_swap",
}
},
string = {
fields = {
"split",
"trim",
}
},
math = {
fields = {
"hypot",
"sign",
"factorial"
}
},
}

0
command_formspec.lua Normal file
View File

135
command_tool.lua Normal file
View File

@ -0,0 +1,135 @@
local flag_obj = nil
local selections = {}
local function select_soldier(soldier, player)
local pos = soldier:get_pos()
local ent = soldier:get_luaentity()
local input = player:get_player_control()
if ent._selected then
-- local selection_obj = minetest.add_entity(pos,"renowned_jam:command_select")
-- selection_obj:set_attach(soldier, "head", {x=0,y=0,z=0}, {x=0,y=0,z=0})
-- ent._owner = player:get_player_name()
-- ent._selected = true
-- table.insert(selections, selection_obj)
if not input.sneak then
for _, sel_obj in ipairs(selections) do
local parent = sel_obj:get_attach():get_luaentity()
parent._selected = false
sel_obj:remove()
end
selections = {}
else
local toRemove = 1
for index, sel_obj in ipairs(selections) do
if sel_obj == soldier then
local parent = sel_obj:get_attach():get_luaentity()
parent._selected = false
sel_obj:remove()
toRemove = index
break
end
end
table.remove(selections, toRemove)
end
else
if not input.sneak then
for _, sel_obj in ipairs(selections) do
local parent = sel_obj:get_attach():get_luaentity()
parent._selected = false
sel_obj:remove()
end
selections = {}
end
local selection_obj = minetest.add_entity(pos,"renowned_jam:command_select")
selection_obj:set_attach(soldier, "Head", {x=0,y=6,z=0}, {x=0,y=0,z=0})
ent._owner = player:get_player_name()
ent._selected = true
table.insert(selections, selection_obj)
end
end
local function command_tool_on_use(itemstack, player, pointed_thing)
if pointed_thing.type == "object" then
local obj = pointed_thing.ref
--print(dump(pointed_thing.ref:get_entity_name()))
if obj:get_entity_name() == "renowned_jam:soldier" then
select_soldier(obj, player)
end
elseif pointed_thing.type == "node" then
local pos = {
x = pointed_thing.under.x, y = pointed_thing.under.y+0.5, z = pointed_thing.under.z
}
--print(dump(pos))
if flag_obj ~= nil then
flag_obj:remove()
end
flag_obj = minetest.add_entity(pos,"renowned_jam:command_flag")
for _, sel_obj in ipairs(selections) do
if sel_obj ~= nil and sel_obj:get_attach() ~= nil then
local parent = sel_obj:get_attach():get_luaentity()
parent._targetPos = pos
mobkit.clear_queue_high(parent)
end
end
end
end
local function command_tool_on_place(itemstack, player, pointed_thing)
if pointed_thing.type == "node" then
local pos = {
x = pointed_thing.under.x, y = pointed_thing.under.y+0.5, z = pointed_thing.under.z
}
minetest.add_entity(pos,"renowned_jam:soldier")
end
end
--minetest.register_globalstep(spawnstep)
minetest.register_entity("renowned_jam:command_flag", {
physical = false,
collide_with_objects = false,
visual = "mesh",
mesh = "renowned_jam_flag.b3d",
textures = {
"renowned_jam_command_arrow.png",
"renowned_jam_command_flag_red.png",
"default_wood.png"
},
visual_size = {x = 4, y = 4, z=4},
pointable = false,
static_save = false,
view_range = 24,
--timeout=600,
})
minetest.register_entity("renowned_jam:command_select", {
physical = false,
collide_with_objects = false,
visual = "mesh",
mesh = "renowned_jam_select_arrow.b3d",
textures = {
"renowned_jam_command_arrow.png",
},
visual_size = {x = 4, y = 4, z=4},
pointable = false,
static_save = false,
view_range = 24,
--timeout=600,
})
minetest.register_tool("renowned_jam:command_tool", {
description = "1st Unit Command Tool",
inventory_image = "renowned_jam_command_tool_red.png",
stack_max = 1,
range = 40,
liquids_pointable = true,
on_use = command_tool_on_use,
on_place = command_tool_on_place
})

4
depends.txt Normal file
View File

@ -0,0 +1,4 @@
default
mobkit
3d_armor
wieldview

0
formation.lua Normal file
View File

25
init.lua Normal file
View File

@ -0,0 +1,25 @@
renowned_jam = {}
local modname = minetest.get_current_modname()
local modpath = minetest.get_modpath(modname)
--local worldpath = minetest.get_worldpath()
local to_remove = {}
for name, _ in pairs(minetest.registered_biomes) do
if name:find("grassland") then
print(name)
else
table.insert(to_remove, name)
end
end
for _, name in ipairs(to_remove) do
minetest.unregister_biome(name)
end
dofile(modpath.."/player.lua")
dofile(modpath.."/structure.lua")
dofile(modpath.."/soldier.lua")
dofile(modpath.."/formation.lua")
dofile(modpath.."/command_formspec.lua")
dofile(modpath.."/command_tool.lua")
dofile(modpath.."/match.lua")

23
match.lua Normal file
View File

@ -0,0 +1,23 @@
local _matches = {}
local _lobby_players = {}
function renowned_jam.join_lobby(player)
end
function renowned_jam.player_leave(player)
end
function renowned_jam.new_match(players)
end
function renowned_jam.join_match(players)
end
function renowned_jam.start_match(players)
end

5
mod.conf Normal file
View File

@ -0,0 +1,5 @@
name = renowned_jam
description = renowned jam RTS
release = 1
title = Renowned Jam 2020
author = jSnake

BIN
models/arrow_layout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 590 B

BIN
models/base_layout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 346 B

BIN
models/flag_layout.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
player.lua Normal file
View File

@ -0,0 +1,9 @@
function renowned_jam.player_new(player)
end
function renowned_jam.player_join(player)
end

BIN
screenshot.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

216
soldier.lua Normal file
View File

@ -0,0 +1,216 @@
--local abr = minetest.get_mapgen_setting('active_block_range')
local node_lava = nil
--local min=math.min
--local max=math.max
--local spawn_rate = 1 - 0.2
--local spawn_reduction = 0.75
local function lava_dmg(self,dmg)
node_lava = node_lava or minetest.registered_nodes[minetest.registered_aliases.mapgen_lava_source]
if node_lava then
local pos=self.object:get_pos()
local box = self.object:get_properties().collisionbox
local pos1={x=pos.x+box[1],y=pos.y+box[2],z=pos.z+box[3]}
local pos2={x=pos.x+box[4],y=pos.y+box[5],z=pos.z+box[6]}
local nodes=mobkit.get_nodes_in_area(pos1,pos2)
if nodes[node_lava] then mobkit.hurt(self,dmg) end
end
end
local function hq_moveto(self,prty,tpos)
local func = function(theself)
if mobkit.is_queue_empty_low(theself) and theself.isonground then
local pos = mobkit.get_stand_pos(theself)
if vector.distance(pos,tpos) > 3 then
mobkit.goto_next_waypoint(theself,tpos)
else
mobkit.lq_idle(theself,1)
end
end
end
mobkit.queue_high(self,func,prty)
end
local function soldier_brain(self)
-- vitals should be checked every step
if mobkit.timer(self,1) then lava_dmg(self,6) end
mobkit.vitals(self)
-- if self.object:get_hp() <=100 then
if self.hp <= 0 then
mobkit.clear_queue_high(self) -- cease all activity
mobkit.hq_die(self) -- kick the bucket
return
end
if mobkit.timer(self,1) then -- decision making needn't happen every engine step
local prty = mobkit.get_queue_priority(self)
if prty < 20 and self.isinliquid then
mobkit.hq_liquid_recovery(self,20)
return
end
--local pos=self.object:get_pos()
-- -- hunt
-- if prty < 10 then -- if not busy with anything important
-- local prey = mobkit.get_closest_entity(self,'new_rpg:npc') -- look for prey
-- if prey then
-- mobkit.hq_hunt(self,10,prey) -- and chase it
-- end
-- end
if prty < 9 and self._targetPos ~= nil then
hq_moveto(self, 9, self._targetPos)
-- local plyr = mobkit.get_nearby_player(self)
-- if plyr and vector.distance(pos,plyr:get_pos()) < 10 then -- if player close
-- --mobkit.hq_warn(self,9,plyr) -- try to repel them
-- --mobkit.animate(self,"mine")
-- --mobkit.make_sound(self, "attack")
-- mobkit.hq_follow(self, 9, plyr)
-- --print(dump(plyr:get_properties()))
-- end -- hq_warn will trigger subsequent bhaviors if needed
end
-- fool around
--if mobkit.is_queue_empty_high(self) then
--mobkit.hq_roam(self,0)
--end
end
end
-- local function spawnstep(dtime)
-- for _,plyr in ipairs(minetest.get_connected_players()) do
-- if math.random()<dtime*0.2 then -- each player gets a spawn chance every 5s on average
-- local vel = plyr:get_player_velocity()
-- local spd = vector.length(vel)
-- local chance = spawn_rate * 1/(spd*0.75+1) -- chance is quadrupled for speed=4
-- local yaw
-- if spd > 1 then
-- -- spawn in the front arc
-- yaw = plyr:get_look_horizontal() + math.random()*0.35 - 0.75
-- else
-- -- random yaw
-- yaw = math.random()*math.pi*2 - math.pi
-- end
-- local pos = plyr:get_pos()
-- local dir = vector.multiply(minetest.yaw_to_dir(yaw),abr*16)
-- local pos2 = vector.add(pos,dir)
-- pos2.y=pos2.y-5
-- local height, liquidflag = mobkit.get_terrain_height(pos2,32)
-- if height and height >= 0 and not liquidflag -- and math.abs(height-pos2.y) <= 30 testin
-- and mobkit.nodeatpos({x=pos2.x,y=height-0.01,z=pos2.z}).is_ground_content then
-- local objs = minetest.get_objects_inside_radius(pos,abr*16+5)
-- local ccnt=0
-- for _,obj in ipairs(objs) do -- count mobs in abrange
-- if not obj:is_player() then
-- local luaent = obj:get_luaentity()
-- if luaent and luaent.name:find('renowned_jam:') then
-- chance=chance + (1-chance)*spawn_reduction -- chance reduced for every mob in range
-- if luaent.name == 'renowned_jam:soldier' then ccnt=ccnt+1 end
-- end
-- end
-- end
-- if chance < math.random() then
-- -- if no wolves and at least one deer spawn wolf, else deer
-- local mobname = "renowned_jam:soldier"
-- pos2.y = height+0.5
-- objs = minetest.get_objects_inside_radius(pos2,abr*16-2)
-- for _,obj in ipairs(objs) do -- do not spawn if another player around
-- if obj:is_player() then return end
-- end
-- minetest.add_entity(pos2,mobname) -- ok spawn it already damnit
-- end
-- end
-- end
-- end
-- end
local function soldier_actfunc(self, staticdata, dtime_s)
mobkit.actfunc(self, staticdata, dtime_s)
local props = {}
props.textures = self.textures[self.texture_no or 1]
self.object:set_properties(props)
end
minetest.register_entity("renowned_jam:soldier", {
-- common props
physical = true,
stepheight = 0.6,
collide_with_objects = true,
collisionbox = {-0.3, 0.0, -0.3, 0.3, 1.7, 0.3},
visual = "mesh",
mesh = "3d_armor_character.b3d",
textures = {
{
"character.png",
"3d_armor_trans.png^3d_armor_helmet_steel.png^3d_armor_chestplate_steel.png^" ..
"shields_shield_steel.png^3d_armor_leggings_steel.png^3d_armor_boots_steel.png",
wieldview:get_item_texture("default:sword_steel")
},
},
visual_size = {x = 1, y = 1},
static_save = true,
makes_footstep_sound = true,
on_step = mobkit.stepfunc,
on_activate = soldier_actfunc,
get_staticdata = mobkit.statfunc,
-- api props
springiness=0,
buoyancy = 0.75, -- portion of hitbox submerged
max_speed = 5,
jump_height = 1.26,
view_range = 24,
lung_capacity = 10, -- seconds
max_hp = 14,
timeout=600,
attack={ range=0.5, damage_groups={fleshy=7}},
sounds = {
attack='renowned_jam_man_fight',
warn = 'renowned_jam_man_yell',
mumble = 'renowned_jam_man_mumble',
},
animation = {
stand={range={x=0,y=79},speed=30,loop=true},
lay={range={x=162,y=166},speed=30,loop=true},
walk={range={x=168,y=187},speed=30,loop=true},
mine={range={x=189,y=198},speed=30,loop=true},
walk_mine={range={x=200,y=219},speed=30,loop=true},
sit={range={x=81,y=160},speed=30,loop=true},
},
brainfunc = soldier_brain,
on_punch=function(self, puncher, time_from_last_punch, tool_capabilities, dir)
if mobkit.is_alive(self) then
local hvel = vector.multiply(vector.normalize({x=dir.x,y=0,z=dir.z}),4)
self.object:set_velocity({x=hvel.x,y=2,z=hvel.z})
mobkit.hurt(self,tool_capabilities.damage_groups.fleshy or 1)
-- if type(puncher)=='userdata' and puncher:is_player() then -- if hit by a player
-- mobkit.clear_queue_high(self) -- abandon whatever they've been doing
-- mobkit.hq_hunt(self,10,puncher) -- get revenge
-- end
end
end,
on_rightclick = function(self, clicker)
print(dump(clicker:get_properties()))
end,
})

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
structure.lua Normal file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 139 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 137 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 230 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 B