summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2017-10-13 14:57:55 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2017-10-13 14:57:55 +0100
commit8dd662285564b0082d3935404eb62068c0aec2a8 (patch)
tree95826e82820e1608ac64b17c3d20aa923e47d545
parent7c10fb7e27d2a3a7f324528eb0721d81216cbce6 (diff)
added explosion timer, explosion counts until out of view range
-rw-r--r--api.lua48
-rw-r--r--api.txt3
-rw-r--r--api_new.txt4
3 files changed, 30 insertions, 25 deletions
diff --git a/api.lua b/api.lua
index c3f0a21..b94bd3b 100644
--- a/api.lua
+++ b/api.lua
@@ -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
-
- 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
+ -- 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
- set_velocity(self, self.run_velocity)
- end
+ -- walk right up to player when timer active
+ if dist < 1.5 and self.v_start then
+ set_velocity(self, 0)
+ 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.animation and self.animation.run_start then
+ set_animation(self, "run")
else
- set_velocity(self, 0)
- set_animation(self, "punch")
+ 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,
diff --git a/api.txt b/api.txt
index cfbf50d..6a619a1 100644
--- a/api.txt
+++ b/api.txt
@@ -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
diff --git a/api_new.txt b/api_new.txt
index 9d76ade..41a4bc8 100644
--- a/api_new.txt
+++ b/api_new.txt
@@ -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