Added Poison Box / Updated Version
parent
f23f67b63c
commit
a49b3bb7e8
|
@ -2,6 +2,8 @@
|
|||
|
||||
This mod uses mobkit and includes a number of simple looking box mobs with varying attacks. I created this to have a satisfying spread of mobs to fight against in survival. Graphics are probably placeholder for now, but mobs probably won't look to much more advanced than cubes. This will be part of a game I'm working on, but wanted to go ahead and release for feedback / other people to mess around with - let me know what you think!
|
||||
|
||||
![Cube Mods Screenshot](/screenshot.png?raw=true)
|
||||
|
||||
**Current Mobs:**
|
||||
* Box: Standard jump attack
|
||||
* Small Box: Quicker, lower hp
|
||||
|
@ -9,6 +11,7 @@ This mod uses mobkit and includes a number of simple looking box mobs with varyi
|
|||
* Shooter Box: Shoots projectiles at player from afar.
|
||||
* Fire Box: Spawns fire on the ground on a path to the player
|
||||
* Spike Box: Spawns spikes on the ground on a path to the player
|
||||
* Poison Box: Spawns poison gas when it hits Player. Spawns poison on death.
|
||||
|
||||
**Todo List:**
|
||||
* Create more hostile mobs, and give all mobs slightly better names
|
||||
|
@ -19,4 +22,5 @@ This mod uses mobkit and includes a number of simple looking box mobs with varyi
|
|||
* Include more item drops (Default items, or creating a couple more)
|
||||
|
||||
**Release History:**
|
||||
* v0.2 - 12/17/20 (Poison Mob Box)
|
||||
* v0.1 - 5/24/20
|
||||
|
|
48
api.lua
48
api.lua
|
@ -277,6 +277,54 @@ function cube_mobkit.box_brain(self)
|
|||
end
|
||||
end
|
||||
|
||||
function cube_mobkit.box_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
|
||||
if self.on_death then self.on_death(self) end
|
||||
if self.drops then
|
||||
for _,v in pairs(self.drops) do
|
||||
local rnd = math.random(1,255)
|
||||
if v.prob>=rnd then
|
||||
local qty = math.random(v.min,v.max)
|
||||
local item = minetest.add_item(self.object:get_pos(), ItemStack(v.name.." "..qty))
|
||||
item:set_velocity({x=math.random(-2,2),y=5,z=math.random(-2,2)})
|
||||
end
|
||||
end
|
||||
end
|
||||
mobkit.clear_queue_high(self) -- cease all activity
|
||||
mobkit.hq_die(self) -- kick the bucket
|
||||
return
|
||||
end
|
||||
|
||||
local prty = mobkit.get_queue_priority(self)
|
||||
if mobkit.timer(self,1) then -- decision making needn't happen every engine step
|
||||
if prty < 20 and self.isinliquid then
|
||||
mobkit.hq_liquid_recovery(self,20)
|
||||
return
|
||||
end
|
||||
|
||||
local pos=self.object:get_pos()
|
||||
|
||||
if prty < 9 then
|
||||
local plyr = mobkit.get_nearby_player(self)
|
||||
if plyr and vector.distance(pos,plyr:get_pos()) < 20 then -- if player close
|
||||
cube_mobkit.hq_hunt(self,10,plyr)
|
||||
end
|
||||
end
|
||||
|
||||
-- fool around
|
||||
if mobkit.is_queue_empty_high(self) then
|
||||
mobkit.hq_roam(self,0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
cube_mobkit.shoot = function(self, target, shot_name,cooldown)
|
||||
local func = function(self)
|
||||
|
|
2
init.lua
2
init.lua
|
@ -1,5 +1,4 @@
|
|||
-- Created by Xanthus using mobkit
|
||||
-- V 0.1
|
||||
|
||||
cube_mobkit = {} -- includes altered functions similar to those found in mobkit (cube_mobkit.lq_jumpattack)
|
||||
cube_mobkit.mob_names = {} -- list of names used for spawning. add mob names to the list after registering
|
||||
|
@ -12,6 +11,7 @@ dofile(path .. "/api.lua")
|
|||
dofile(path .. "/spawns.lua")
|
||||
dofile(path .. "/items.lua")
|
||||
dofile(path .. "/nodes.lua")
|
||||
dofile(path .. "/mobs/dummy.lua")
|
||||
dofile(path .. "/mobs/box.lua")
|
||||
dofile(path .. "/mobs/box_small.lua")
|
||||
dofile(path .. "/mobs/box_shoot.lua")
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
minetest.register_entity("cube_mobs:box_friend",{
|
||||
-- common props
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1},
|
||||
textures = {"cube_mobs_box_friend_side.png","cube_mobs_box_friend_side.png","cube_mobs_box_friend_side.png","cube_mobs_box_friend_side.png","cube_mobs_box_friend_front.png","cube_mobs_box_friend_side.png"},
|
||||
spritediv = {x = 1, y = 1},
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
|
||||
static_save = true,
|
||||
makes_footstep_sound = true,
|
||||
|
||||
on_step = mobkit.stepfunc, -- required
|
||||
on_activate = cube_mobkit.actfunc, -- required
|
||||
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 = 10,
|
||||
timeout=600,
|
||||
attack={melee_range=1.5,speed=8, damage_groups={fleshy=4}},
|
||||
sounds = {
|
||||
attack='player_damage',
|
||||
},
|
||||
brainfunc = cube_mobkit.friend_brain,
|
||||
|
||||
on_punch= function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
cube_mobkit.on_punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
end,
|
||||
|
||||
drops = { {name="cube_mobs:bits", min=1, max=2,prob=255/3} }
|
||||
})
|
||||
|
||||
-- todo: unused atm. Add some sort of benefit to player (trading, drop item on box_friend and get healing or item in return?)
|
||||
--cube_mobkit.mob_names[#cube_mobkit.mob_names+1] = "cube_mobs:box"
|
|
@ -2,7 +2,7 @@ minetest.register_entity("cube_mobs:box_poison",{
|
|||
-- common props
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1},
|
||||
textures = {"cube_mobs_box_poison_side.png","cube_mobs_box_poison_side.png","cube_mobs_box_poison_side.png","cube_mobs_box_poison_side.png","cube_mobs_box_poison_front.png","cube_mobs_box_poison_side.png"},
|
||||
|
@ -38,10 +38,14 @@ minetest.register_entity("cube_mobs:box_poison",{
|
|||
local pos = self.object:get_pos()
|
||||
for i=-2,2 do
|
||||
for j =-2,2 do
|
||||
local npos = {x=pos.x+i,y=pos.y+1,z=pos.z+j}
|
||||
minetest.set_node( npos ,{name="cube_mobs:poison"})
|
||||
local timer = minetest.get_node_timer(npos)
|
||||
timer:start(10) -- poison dissappear after 10 seconds
|
||||
for k = -1,1 do
|
||||
local npos = {x=pos.x+i,y=pos.y+k,z=pos.z+j}
|
||||
if(minetest.get_node(npos).name=="air") then
|
||||
minetest.set_node( npos ,{name="cube_mobs:poison"})
|
||||
local timer = minetest.get_node_timer(npos)
|
||||
timer:start(10) -- poison dissappear after 10 seconds
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
minetest.register_entity("cube_mobs:dummy",{
|
||||
-- common props
|
||||
physical = true,
|
||||
collide_with_objects = false,
|
||||
collisionbox = {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5},
|
||||
visual = "cube",
|
||||
visual_size = {x = 1, y = 1},
|
||||
textures = {"cube_mobs_box_side.png","cube_mobs_box_side.png","cube_mobs_box_side.png","cube_mobs_box_side.png","cube_mobs_box_front.png","cube_mobs_box_side.png"},
|
||||
spritediv = {x = 1, y = 1},
|
||||
initial_sprite_basepos = {x = 0, y = 0},
|
||||
|
||||
static_save = true,
|
||||
makes_footstep_sound = true,
|
||||
|
||||
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 = 10,
|
||||
timeout=600,
|
||||
attack={melee_range=1.5,speed=8, damage_groups={fleshy=4}},
|
||||
sounds = {
|
||||
attack='player_damage',
|
||||
},
|
||||
automatic_rotate = 1,
|
||||
last_move=0,
|
||||
my_step = function(self)
|
||||
|
||||
--minetest.chat_send_all(" dtime: "..dtime)
|
||||
minetest.after(.1,self.my_step,self)
|
||||
end,
|
||||
on_activate = function(self, staticdata, dtime_s)
|
||||
self.object:set_velocity({x=0,y=1,z=0})
|
||||
minetest.after(.1,self.my_step,self)
|
||||
end,
|
||||
|
||||
|
||||
drops = { {name="cube_mobs:bits", min=1, max=2,prob=255/3} }
|
||||
})
|
20
spawns.lua
20
spawns.lua
|
@ -3,8 +3,8 @@ local num_spawns = 0
|
|||
|
||||
local abr = minetest.get_mapgen_setting('active_block_range')
|
||||
|
||||
local spawn_rate = 1 - math.max(math.min(minetest.settings:get('cube_mobs_spawn_chance') or 0.1,1),0)
|
||||
local spawn_reduction = minetest.settings:get('cube_mobs_spawn_reduction') or 0.1
|
||||
local spawn_rate = math.min(math.max(minetest.settings:get('cube_mobs_spawn_chance') or 2,.5),4)
|
||||
local spawn_reduction = minetest.settings:get('cube_mobs_spawn_reduction') or 0.5
|
||||
local spawn_timer = 5 -- try to spawn every 5 seconds
|
||||
|
||||
local function spawnstep(dtime)
|
||||
|
@ -13,7 +13,7 @@ local function spawnstep(dtime)
|
|||
for _,plyr in ipairs(minetest.get_connected_players()) do
|
||||
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 chance = spawn_rate -- chance is quadrupled for speed=4
|
||||
|
||||
local player_name = plyr:get_player_name()
|
||||
|
||||
|
@ -28,10 +28,11 @@ local function spawnstep(dtime)
|
|||
local pos = plyr:get_pos()
|
||||
|
||||
local cave_modifier = 1
|
||||
if pos.y<-8 then
|
||||
if pos.y<-8 then -- don't spawn as far in caves
|
||||
cave_modifier = .5
|
||||
end
|
||||
local dir = vector.multiply(minetest.yaw_to_dir(yaw),abr*16*cave_modifier)
|
||||
local dist = abr*16*cave_modifier * (math.random()*.5+.75) -- vary distance between 75% and 125%
|
||||
local dir = vector.multiply(minetest.yaw_to_dir(yaw),dist)
|
||||
|
||||
|
||||
local pos2 = vector.add(pos,dir)
|
||||
|
@ -64,12 +65,12 @@ local function spawnstep(dtime)
|
|||
if not obj:is_player() then
|
||||
local luaent = obj:get_luaentity()
|
||||
if luaent and luaent.name:find('cube_mobs:') then
|
||||
chance=chance + (1-chance)*spawn_reduction -- chance reduced for every mob in range
|
||||
chance=chance-spawn_reduction -- chance reduced for every mob in range
|
||||
local mob_pos = obj:get_pos()
|
||||
end
|
||||
end
|
||||
end
|
||||
if chance < math.random() then
|
||||
if chance > math.random() then
|
||||
local mobname = cube_mobkit.mob_names[math.random(#cube_mobkit.mob_names)]
|
||||
|
||||
objs = minetest.get_objects_inside_radius(pos_spawn,abr*16*cave_modifier-2)
|
||||
|
@ -79,7 +80,10 @@ local function spawnstep(dtime)
|
|||
end
|
||||
end
|
||||
|
||||
-- minetest.chat_send_all("Spawned at:"..floor(pos_spawn.x).." "..floor(pos_spawn.y).." "..floor(pos_spawn.z))
|
||||
-- chat for debugging and testing spawns
|
||||
--minetest.chat_send_all("Spawned at:"..math.floor(pos_spawn.x).." "..math.floor(pos_spawn.y).." "..math.floor(pos_spawn.z))
|
||||
--minetest.chat_send_all("Chance: "..chance)
|
||||
|
||||
minetest.add_entity(pos_spawn,mobname) -- spawn
|
||||
num_spawns = num_spawns + 1
|
||||
end
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 614 B |
Binary file not shown.
After Width: | Height: | Size: 585 B |
Loading…
Reference in New Issue