1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-24 17:50:21 +01:00

added explosion timer, explosion counts until out of view range

This commit is contained in:
TenPlus1 2017-10-13 14:57:55 +01:00
parent 7c10fb7e27
commit 8dd6622855
3 changed files with 31 additions and 26 deletions

50
api.lua
View File

@ -3,7 +3,7 @@
mobs = {}
mobs.mod = "redo"
mobs.version = "20171009"
mobs.version = "20171013"
-- Intllib
@ -1685,7 +1685,7 @@ local do_states = function(self, dtime)
or self.attack:get_hp() <= 0
or (self.attack:is_player() and mobs.invis[ self.attack:get_player_name() ]) then
--print(" ** stop attacking **", dist, self.view_range)
-- print(" ** stop attacking **", dist, self.view_range)
self.state = "stand"
set_velocity(self, 0)
set_animation(self, "stand")
@ -1710,29 +1710,28 @@ local do_states = function(self, dtime)
yaw = set_yaw(self.object, yaw)
if dist > self.reach then
-- start timer when inside reach
if dist < self.reach and not self.v_start then
self.v_start = true
self.timer = 0
self.blinktimer = 0
-- print ("=== explosion timer started", self.explosion_timer)
end
if not self.v_start then
self.v_start = true
set_velocity(self, self.run_velocity)
self.timer = 0
self.blinktimer = 0
else
self.timer = 0
self.blinktimer = 0
set_velocity(self, self.run_velocity)
end
if self.animation and self.animation.run_start then
set_animation(self, "run")
else
set_animation(self, "walk")
end
else
-- walk right up to player when timer active
if dist < 1.5 and self.v_start then
set_velocity(self, 0)
set_animation(self, "punch")
else
set_velocity(self, self.run_velocity)
end
if self.animation and self.animation.run_start then
set_animation(self, "run")
else
set_animation(self, "walk")
end
if self.v_start then
self.timer = self.timer + dtime
self.blinktimer = (self.blinktimer or 0) + dtime
@ -1750,7 +1749,9 @@ local do_states = function(self, dtime)
self.blinkstatus = not self.blinkstatus
end
if self.timer > 3 then
-- print ("=== explosion timer", self.timer)
if self.timer > self.explosion_timer then
local pos = self.object:get_pos()
local radius = self.explosion_radius or 1
@ -2734,6 +2735,7 @@ minetest.register_entity(name, {
pathfinding = def.pathfinding,
immune_to = def.immune_to or {},
explosion_radius = def.explosion_radius,
explosion_timer = def.explosion_timer or 3,
custom_attack = def.custom_attack,
double_melee_attack = def.double_melee_attack,
dogshoot_switch = def.dogshoot_switch,

View File

@ -1,5 +1,5 @@
MOB API (15th September 2017)
MOB API (13th October 2017)
The mob api is a function that can be called on by other mods to add new animals or monsters into minetest.
@ -88,6 +88,7 @@ This functions registers a new mob as a Minetest entity.
'custom_attack' when set this function is called instead of the normal mob melee attack, parameters are (self, to_attack)
'double_melee_attack' if false then api will choose randomly between 'punch' and 'punch2' attack animations
'explosion_radius' radius of explosion attack (defaults to 1)
'explosion_timer' number of seconds before mob explodes while still inside view range.
'arrow' if the attack_type is "shoot" or "dogshoot" then the entity name of a pre-defined arrow is required, see below for arrow definition.
'shoot_interval' the minimum shoot interval
'shoot_offset' +/- value to position arrow/fireball when fired

View File

@ -1,5 +1,5 @@
Mobs Redo API (last updated 25th Sep 2017)
Mobs Redo API (last updated 13th Oct 2017)
==========================================
Welcome to the world of mobs in minetest and hopefully an easy guide to defining
@ -87,6 +87,8 @@ functions needed for the mob to work properly which contains the following:
when inside view_range.
'explode' causes mob to explode when inside reach.
'explosion_radius' has the radius of the explosion which defaults to 1.
'explosion_timer' number of seconds before mob explodes while still
inside view range.
'arrow' holds the pre-defined arrow object to shoot when
attacking.
'dogshoot_switch' allows switching between attack types by using timers