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

Added custom_attack function (thanks to NPXcoot)

This commit is contained in:
TenPlus1 2016-04-28 20:18:00 +01:00
parent b512f882e9
commit b51bafcf0e
3 changed files with 33 additions and 2856 deletions

14
api.lua
View File

@ -1,5 +1,5 @@
-- Mobs Api (25th April 2016) -- Mobs Api (28th April 2016)
mobs = {} mobs = {}
mobs.mod = "redo" mobs.mod = "redo"
@ -1529,6 +1529,8 @@ local do_states = function(self, dtime)
set_velocity(self, 0) set_velocity(self, 0)
set_animation(self, "punch") set_animation(self, "punch")
if not self.custom_attack then
if self.timer > 1 then if self.timer > 1 then
self.timer = 0 self.timer = 0
@ -1558,6 +1560,15 @@ local do_states = function(self, dtime)
}, nil) }, nil)
end end
end end
else -- call custom attack every second
if self.custom_attack
and self.timer > 1 then
self.timer = 0
self.custom_attack(self, p)
end
end
end end
elseif self.attack_type == "shoot" elseif self.attack_type == "shoot"
@ -2165,6 +2176,7 @@ minetest.register_entity(name, {
pathfinding = def.pathfinding, pathfinding = def.pathfinding,
immune_to = def.immune_to or {}, immune_to = def.immune_to or {},
explosion_radius = def.explosion_radius, explosion_radius = def.explosion_radius,
custom_attack = def.custom_attack,
on_step = mob_step, on_step = mob_step,

View File

@ -79,6 +79,7 @@ This functions registers a new mob as a Minetest entity.
'shoot' shoots defined arrows when player is within range 'shoot' shoots defined arrows when player is within range
'explode' follows player in range and will flash and explode when in reach 'explode' follows player in range and will flash and explode when in reach
'dogshoot' shoots arrows when in range and one on one attack when in reach 'dogshoot' shoots arrows when in range and one on one attack when in reach
'custom_attack' is a function that is called when mob is in range to attack player, parameters are (self, to_attack)
'explosion_radius' radius of explosion attack (defaults to 1) 'explosion_radius' radius of explosion attack (defaults to 1)
'arrow' if the attack_type is "shoot" or "dogshoot" then the entity name of the arrow is required 'arrow' if the attack_type is "shoot" or "dogshoot" then the entity name of the arrow is required
'shoot_interval' the minimum shoot interval 'shoot_interval' the minimum shoot interval

File diff suppressed because it is too large Load Diff