- Closes #11
This commit is contained in:
Leslie Krause 2020-05-05 20:15:00 -04:00
parent 8a5c914285
commit 9c12616e8a
4 changed files with 5 additions and 158 deletions

View File

@ -1,4 +1,4 @@
Mobs Lite Mod v1.1
Mobs Lite Mod v1.2
By Leslie E. Krause
Mobs Lite is a fully-working proof of concept for the Extended Motion Mechanics API for
@ -19,7 +19,7 @@ Here are some of the other highlights of the Mobs Lite engine:
buoyancy characteristics.
* Sophisticated sensory analysis with a custom view-cone and acuity curve dependant on
changing awareness level.
current alertness state.
* Sensitivity thresholds and certainty factors determine whether creatures "see" a player
within their view cone.
@ -27,20 +27,14 @@ Here are some of the other highlights of the Mobs Lite engine:
* Animals will attempt to flee to safety when a player that previously punched them
returns to the field of view.
* Monsters no longer randomly attack but rather exhibit varying degrees of aggression via
a Perlin noise function.
* Creatures avoid running into most obstacles by analyzing the surroundings and steadily
changing their course.
adjusting their course.
* Mobs can be randomly spawned in the vicinity of players, thus relieving the overhead of
costly ABM-based spawners.
* Timekeeper helper class ensures efficient dispatching of mob-related callbacks at the
appropriate server cycle.
* Animals can be programmed to follow players or to grab items that are wielded by or
dropped by nearby players.
appropriate server step.
* And of course, much much more!

View File

@ -1330,92 +1330,6 @@ mobs.register_spawner_node = function ( name, def )
minetest.register_node( name, def )
end
mobs.register_projectile = function ( name, def )
minetest.register_entity( name, {
physical = true,
visual = def.visual,
visual_size = def.visual_size,
textures = def.textures,
gravity = def.gravity,
trail_effect = def.trail_effect,
can_submerge = def.can_submerge,
on_launch = def.on_launch,
on_impact = def.on_impact,
on_impact_nodes = def.on_impact_nodes,
sounds = def.sounds,
timeout = def.timeout,
launch = function ( self, yaw, speed, incline, gravity )
self.object:set_yaw( yaw )
self.object:set_speed( speed )
self.object:set_velocity_vert( incline * speed )
self.object:set_acceleration_vert( gravity or self.gravity )
self.trail_effect.vel_x = -sin( yaw + self.trail_effect.angle ) * self.trail_effect.speed
self.trail_effect.vel_z = cos( yaw + self.trail_effect.angle ) * self.trail_effect.speed
minetest.sound_play( self.sounds.launch, { object = self.object, gain = 1 } )
end,
on_activate = function( self, staticdata, dtime_s )
self.timekeeper = Timekeeper( self )
if self.trail_effect then
self.timekeeper.start( self.trail_effect.period, "trail_effect" )
end
self.timekeeper.start( self.timeout, "timeout", function ( )
self.object:remove( ) -- remove expired projectile after timeout
end )
end,
on_step = function( self, dtime, pos, rot, new_vel, old_vel, move_result )
local timers = self.timekeeper.on_step( dtime )
if timers.trail_effect then
local fx = self.trail_effect
for i = 1, fx.amount do
minetest.add_particle( {
pos = vector.offset( pos,
random_range( -0.5, 0.5 ),
random_range( -0.5, 0.5 ),
random_range( -0.5, 0.5 )
),
velocity = vector.new( fx.vel_x, fx.vel_y, fx.vel_z ),
acceleration = vector.new( 0, fx.acc_y, 0 ),
expirationtime = def.trail_effect.expiry,
collisiondetection = false,
texture = fx.texture,
size = fx.size,
} )
end
end
if move_result.is_swimming and not self.is_swimming then
minetest.sound_play( self.sounds.submerge, { object = self.object, gain = 1 } )
if not self.can_submerge then
self.object:remove( )
end
end
self.is_swimming = move_result.is_swimming
if move_result.collides_xz or move_result.collides_y then
if #move_result.touched_objects > 0 and self.on_impact then
for i, v in ipairs( move_result.touched_objects ) do
self:on_impact( pos, old_vel, v )
end
end
if #move_result.collisions > 0 and self.on_impact_nodes then
self:on_impact_nodes( pos, old_vel, move_result.collisions )
end
minetest.sound_play( self.sounds.impact, { object = self.object, gain = 1 } )
self.object:remove( )
end
end
} )
end
--------------------
mobs.presets = {
@ -1468,7 +1382,6 @@ mobs.presets = {
dofile( minetest.get_modpath( "mobs" ) .. "/extras.lua" )
dofile( minetest.get_modpath( "mobs" ) .. "/monsters.lua" )
dofile( minetest.get_modpath( "mobs" ) .. "/animals.lua" )
dofile( minetest.get_modpath( "mobs" ) .. "/weapons.lua" )
-- compatibility for Minetest S3 engine

View File

@ -43,7 +43,7 @@ mobs.register_mob( "mobs:ghost", {
fear_factor = 8,
flee_factor = 10,
attack_type = "shoot",
attack_type = "melee",
standoff = 4.0,
attack_range = 6.0,
escape_range = 2.5,
@ -67,10 +67,6 @@ mobs.register_mob( "mobs:ghost", {
water_damage = 0,
lava_damage = 0,
shoot_period = 1.25,
shoot_chance = 1,
weapon_params = { bullet = "mobs:fireball", rounds = 30, speed = 3.0 },
sounds = {
random = "mobs_ghost",
attack = "mobs_ghost",

View File

@ -1,56 +0,0 @@
--------------------------------------------------------
-- Minetest :: Mobs Lite Mod (mobs)
--
-- See README.txt for licensing and release notes.
-- Copyright (c) 2016-2020, Leslie E. Krause
--
-- ./games/minetest_game/mods/mobs/weapons.lua
--------------------------------------------------------
mobs.register_projectile( "mobs:fireball", {
visual = "sprite",
visual_size = { x = 1.0, y = 1.0 },
textures = { "mobs_fireball.png" },
gravity = 0.0,
trail_effect = {
period = 0.2,
amount = 8,
expiry = 1.5,
speed = -2.0,
angle = 0.0,
vel_y = 0.0,
acc_y = 3.5,
texture = "tnt_smoke.png",
size = 2.0,
},
sounds = { launch = "tnt_ignite", impact = "tnt_explode", submerge = "" },
timeout = 12.0,
on_impact = function( self, pos, old_vel, obj )
obj:punch( self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = { fleshy = 8 },
}, nil )
end,
on_impact_nodes = function( self, pos )
minetest.add_particlespawner( {
amount = 200,
time = 0.1,
minpos = pos,
maxpos = pos,
minvel = { x = -4, y= 0, z = -4 },
maxvel = { x = 4, y = 4, z = 4 },
minacc = { x = 0, y = 0, z = 0 },
maxacc = { x = 0, y = 0, z = 0 },
minexptime = 0.6,
maxexptime = 0.6,
minsize = 1,
maxsize = 3,
collisiondetection = false,
vertical = false,
texture = "tnt_smoke.png",
} )
-- mobs:explosion( pos, 1, 1, 0 )
end
} )