mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-25 02:00:21 +01:00
Added 'punch2' 'shoot' animations, 'double_melee_attack' flag and tweaks to api
This commit is contained in:
parent
f362ced4da
commit
050dd1dbb0
54
api.lua
54
api.lua
@ -85,13 +85,12 @@ set_animation = function(self, type)
|
|||||||
and self.animation.current ~= "stand" then
|
and self.animation.current ~= "stand" then
|
||||||
|
|
||||||
if self.animation.stand_start
|
if self.animation.stand_start
|
||||||
and self.animation.stand_end
|
and self.animation.stand_end then
|
||||||
and self.animation.speed_normal then
|
|
||||||
|
|
||||||
self.object:set_animation({
|
self.object:set_animation({
|
||||||
x = self.animation.stand_start,
|
x = self.animation.stand_start,
|
||||||
y = self.animation.stand_end},
|
y = self.animation.stand_end},
|
||||||
self.animation.speed_normal, 0)
|
(self.animation.speed_stand or self.animation.speed_normal), 0)
|
||||||
|
|
||||||
self.animation.current = "stand"
|
self.animation.current = "stand"
|
||||||
end
|
end
|
||||||
@ -100,13 +99,12 @@ set_animation = function(self, type)
|
|||||||
and self.animation.current ~= "walk" then
|
and self.animation.current ~= "walk" then
|
||||||
|
|
||||||
if self.animation.walk_start
|
if self.animation.walk_start
|
||||||
and self.animation.walk_end
|
and self.animation.walk_end then
|
||||||
and self.animation.speed_normal then
|
|
||||||
|
|
||||||
self.object:set_animation({
|
self.object:set_animation({
|
||||||
x = self.animation.walk_start,
|
x = self.animation.walk_start,
|
||||||
y = self.animation.walk_end},
|
y = self.animation.walk_end},
|
||||||
self.animation.speed_normal, 0)
|
(self.animation.speed_walk or self.animation.speed_normal), 0)
|
||||||
|
|
||||||
self.animation.current = "walk"
|
self.animation.current = "walk"
|
||||||
end
|
end
|
||||||
@ -115,8 +113,7 @@ set_animation = function(self, type)
|
|||||||
and self.animation.current ~= "run" then
|
and self.animation.current ~= "run" then
|
||||||
|
|
||||||
if self.animation.run_start
|
if self.animation.run_start
|
||||||
and self.animation.run_end
|
and self.animation.run_end then
|
||||||
and self.animation.speed_run then
|
|
||||||
|
|
||||||
self.object:set_animation({
|
self.object:set_animation({
|
||||||
x = self.animation.run_start,
|
x = self.animation.run_start,
|
||||||
@ -130,8 +127,7 @@ set_animation = function(self, type)
|
|||||||
and self.animation.current ~= "punch" then
|
and self.animation.current ~= "punch" then
|
||||||
|
|
||||||
if self.animation.punch_start
|
if self.animation.punch_start
|
||||||
and self.animation.punch_end
|
and self.animation.punch_end then
|
||||||
and self.animation.speed_normal then
|
|
||||||
|
|
||||||
self.object:set_animation({
|
self.object:set_animation({
|
||||||
x = self.animation.punch_start,
|
x = self.animation.punch_start,
|
||||||
@ -140,6 +136,32 @@ set_animation = function(self, type)
|
|||||||
|
|
||||||
self.animation.current = "punch"
|
self.animation.current = "punch"
|
||||||
end
|
end
|
||||||
|
elseif type == "punch2"
|
||||||
|
and self.animation.current ~= "punch2" then
|
||||||
|
|
||||||
|
if self.animation.punch2_start
|
||||||
|
and self.animation.punch2_end then
|
||||||
|
|
||||||
|
self.object:set_animation({
|
||||||
|
x = self.animation.punch2_start,
|
||||||
|
y = self.animation.punch2_end},
|
||||||
|
(self.animation.speed_punch2 or self.animation.speed_normal), 0)
|
||||||
|
|
||||||
|
self.animation.current = "punch2"
|
||||||
|
end
|
||||||
|
elseif type == "shoot"
|
||||||
|
and self.animation.current ~= "shoot" then
|
||||||
|
|
||||||
|
if self.animation.shoot_start
|
||||||
|
and self.animation.shoot_end then
|
||||||
|
|
||||||
|
self.object:set_animation({
|
||||||
|
x = self.animation.shoot_start,
|
||||||
|
y = self.animation.shoot_end},
|
||||||
|
(self.animation.speed_shoot or self.animation.speed_normal), 0)
|
||||||
|
|
||||||
|
self.animation.current = "shoot"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1333,6 +1355,8 @@ local do_states = function(self, dtime)
|
|||||||
set_animation(self, "run")
|
set_animation(self, "run")
|
||||||
else
|
else
|
||||||
set_velocity(self, 0)
|
set_velocity(self, 0)
|
||||||
|
set_animation(self, "punch")
|
||||||
|
|
||||||
self.timer = self.timer + dtime
|
self.timer = self.timer + dtime
|
||||||
self.blinktimer = (self.blinktimer or 0) + dtime
|
self.blinktimer = (self.blinktimer or 0) + dtime
|
||||||
|
|
||||||
@ -1535,6 +1559,13 @@ local do_states = function(self, dtime)
|
|||||||
|
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
|
|
||||||
|
if self.double_melee_attack
|
||||||
|
and math.random(1, 2) == 1 then
|
||||||
|
set_animation(self, "punch")
|
||||||
|
else
|
||||||
|
set_animation(self, "punch2")
|
||||||
|
end
|
||||||
|
|
||||||
local p2 = p
|
local p2 = p
|
||||||
local s2 = s
|
local s2 = s
|
||||||
|
|
||||||
@ -1603,7 +1634,7 @@ local do_states = function(self, dtime)
|
|||||||
and math.random(1, 100) <= 60 then
|
and math.random(1, 100) <= 60 then
|
||||||
|
|
||||||
self.timer = 0
|
self.timer = 0
|
||||||
set_animation(self, "punch")
|
set_animation(self, "shoot")
|
||||||
|
|
||||||
-- play shoot attack sound
|
-- play shoot attack sound
|
||||||
if self.sounds.shoot_attack then
|
if self.sounds.shoot_attack then
|
||||||
@ -2189,6 +2220,7 @@ minetest.register_entity(name, {
|
|||||||
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,
|
custom_attack = def.custom_attack,
|
||||||
|
double_melee_attack = def.double_melee_attack,
|
||||||
|
|
||||||
on_blast = def.on_blast or do_tnt,
|
on_blast = def.on_blast or do_tnt,
|
||||||
|
|
||||||
|
29
api.txt
29
api.txt
@ -80,6 +80,7 @@ This functions registers a new mob as a Minetest entity.
|
|||||||
'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)
|
'custom_attack' is a function that is called when mob is in range to attack player, parameters are (self, to_attack)
|
||||||
|
'double_melee_attack' if false then api will choose randomly between 'punch' and 'punch2' attack animations
|
||||||
'on_blast' is called when TNT explodes near mob, function uses (object, damage) and returns (do_damage, do_knockback, drops)
|
'on_blast' is called when TNT explodes near mob, function uses (object, damage) and returns (do_damage, do_knockback, drops)
|
||||||
'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
|
||||||
@ -97,17 +98,23 @@ This functions registers a new mob as a Minetest entity.
|
|||||||
'explode' sound when exploding
|
'explode' sound when exploding
|
||||||
'distance' maximum distance sounds are heard from (default is 10)
|
'distance' maximum distance sounds are heard from (default is 10)
|
||||||
'animation' a table with the animation ranges and speed of the model
|
'animation' a table with the animation ranges and speed of the model
|
||||||
'stand_start'
|
'stand_start' start frame of stand animation
|
||||||
'stand_end'
|
'stand_end' end frame of stand animation
|
||||||
'walk_start'
|
'walk_start' start frame of walk animation
|
||||||
'walk_end'
|
'walk_end' end frame of walk animation
|
||||||
'run_start'
|
'run_start' start frame of run animation
|
||||||
'run_end'
|
'run_end' end frame of run animation
|
||||||
'punch_start'
|
'punch_start' start frame of punch animation
|
||||||
'punch_end'
|
'punch_end' end frame of punch animation
|
||||||
'speed_normal'
|
'punch2_start' start frame of alt.punch animation
|
||||||
'speed_run' used when mob runs behind player to make animation faster
|
'punch2_end' end frame of alt.punch animation
|
||||||
'speed_punch' used when mob punches player to make animation faster
|
'shoot_start' start frame of shoot animation
|
||||||
|
'shoot_end' end frame of shoot animation
|
||||||
|
'speed_normal' normal animation speed
|
||||||
|
'speed_run' running animation speed
|
||||||
|
'speed_punch' punching animation speed
|
||||||
|
'speed_punch2' alternative punching animation speed
|
||||||
|
'speed_shoot' shooting animation speed
|
||||||
'replace_what' group if items to replace e.g. {"farming:wheat_8", "farming:carrot_8"}
|
'replace_what' group if items to replace e.g. {"farming:wheat_8", "farming:carrot_8"}
|
||||||
'replace_with' replace with what e.g. "air" or in chickens case "mobs:egg"
|
'replace_with' replace with what e.g. "air" or in chickens case "mobs:egg"
|
||||||
'replace_rate' how random should the replace rate be (typically 10)
|
'replace_rate' how random should the replace rate be (typically 10)
|
||||||
|
Loading…
Reference in New Issue
Block a user