Added new custom_attack function
This commit is contained in:
parent
0b52953903
commit
f3bc7191f2
@ -13,8 +13,7 @@ nssm:register_mob("nssm:ant_queen", {
|
|||||||
walk_velocity = 1.5,
|
walk_velocity = 1.5,
|
||||||
run_velocity = 2,
|
run_velocity = 2,
|
||||||
lifetimer = 300,
|
lifetimer = 300,
|
||||||
mamma = true,
|
rotate = 270,
|
||||||
rotate = 270,
|
|
||||||
sounds = {
|
sounds = {
|
||||||
random = "ant",
|
random = "ant",
|
||||||
attack = "ant",
|
attack = "ant",
|
||||||
@ -39,7 +38,7 @@ nssm:register_mob("nssm:ant_queen", {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 2,},
|
max = 2,},
|
||||||
},
|
},
|
||||||
reach = 4,
|
reach = 8,
|
||||||
armor = 70,
|
armor = 70,
|
||||||
drawtype = "front",
|
drawtype = "front",
|
||||||
water_damage = 2,
|
water_damage = 2,
|
||||||
@ -58,6 +57,33 @@ nssm:register_mob("nssm:ant_queen", {
|
|||||||
run_end = 160,
|
run_end = 160,
|
||||||
punch_start = 170,
|
punch_start = 170,
|
||||||
punch_end = 190,
|
punch_end = 190,
|
||||||
}
|
},
|
||||||
|
|
||||||
|
custom_attack = function(self)
|
||||||
|
if self.timer >4 then
|
||||||
|
self.timer = 0
|
||||||
|
|
||||||
|
local s = self.object:getpos()
|
||||||
|
local p = self.attack:getpos()
|
||||||
|
|
||||||
|
p.y = p.y + 1.5
|
||||||
|
s.y = s.y + 1.5
|
||||||
|
if line_of_sight_water(self, p, s) == true then
|
||||||
|
-- play attack sound
|
||||||
|
if self.sounds.attack then
|
||||||
|
minetest.sound_play(self.sounds.attack, {
|
||||||
|
object = self.object,
|
||||||
|
max_hear_distance = self.sounds.distance
|
||||||
|
})
|
||||||
|
end
|
||||||
|
local pos1 = {x=s.x+math.random(-3,3), y=s.y-1, z=s.z+math.random(-3,3)}
|
||||||
|
|
||||||
|
if pos1.x~=s.x and pos1.z~=s.z then
|
||||||
|
nssm:explosion_particles(pos1, 1)
|
||||||
|
minetest.add_entity(pos1, "nssm:ant_soldier")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
})
|
})
|
||||||
|
154
api.lua
154
api.lua
@ -10,8 +10,6 @@ local creative = minetest.setting_getbool("creative_mode")
|
|||||||
local spawn_protected = tonumber(minetest.setting_get("nssm_spawn_protected")) or 1
|
local spawn_protected = tonumber(minetest.setting_get("nssm_spawn_protected")) or 1
|
||||||
local remove_far = minetest.setting_getbool("remove_far_nssm")
|
local remove_far = minetest.setting_getbool("remove_far_nssm")
|
||||||
|
|
||||||
local mese_rip=0 --NSSM addition
|
|
||||||
|
|
||||||
-- pathfinding settings
|
-- pathfinding settings
|
||||||
local enable_pathfinding = true
|
local enable_pathfinding = true
|
||||||
local enable_pathfind_digging = false
|
local enable_pathfind_digging = false
|
||||||
@ -165,20 +163,6 @@ set_animation = function(self, type)
|
|||||||
self.animation.speed_normal, 0)
|
self.animation.speed_normal, 0)
|
||||||
self.animation.current = "dattack"
|
self.animation.current = "dattack"
|
||||||
end
|
end
|
||||||
elseif type == "die"
|
|
||||||
and self.animation.current ~= "die" then
|
|
||||||
if self.animation.die_start
|
|
||||||
and self.animation.die_end
|
|
||||||
and self.animation.speed_normal then
|
|
||||||
self.object:set_animation({
|
|
||||||
x = self.animation.die_start,
|
|
||||||
y = self.animation.die_end},
|
|
||||||
self.animation.speed_normal, 0)
|
|
||||||
self.animation.current = "die"
|
|
||||||
end
|
|
||||||
|
|
||||||
--end of NSSM additions
|
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1020,13 +1004,8 @@ minetest.register_entity(name, {
|
|||||||
on_dist_attack = def.on_dist_attack,
|
on_dist_attack = def.on_dist_attack,
|
||||||
metamorphosis = def.metamorphosis or false,
|
metamorphosis = def.metamorphosis or false,
|
||||||
metatimer = 30,
|
metatimer = 30,
|
||||||
pump_putter = def.pump_putter or false,
|
|
||||||
mamma = def.mamma or false,
|
|
||||||
dogshoot_stop = def.dogshoot_stop or false,
|
dogshoot_stop = def.dogshoot_stop or false,
|
||||||
duckking_father = def.duckking_father or false,
|
duckking_father = def.duckking_father or false,
|
||||||
maxus = def.maxus or false,
|
|
||||||
inker = def.inker or false,
|
|
||||||
die_anim = def.die_anim or false,
|
|
||||||
hydra = def.hydra or false,
|
hydra = def.hydra or false,
|
||||||
mele_number = def.mele_number or 1,
|
mele_number = def.mele_number or 1,
|
||||||
true_dist_attack = def.true_dist_attack or false,
|
true_dist_attack = def.true_dist_attack or false,
|
||||||
@ -1034,6 +1013,8 @@ minetest.register_entity(name, {
|
|||||||
direct_hit = false,
|
direct_hit = false,
|
||||||
num_sons = 0,
|
num_sons = 0,
|
||||||
num_mele_attacks = 0,
|
num_mele_attacks = 0,
|
||||||
|
custom_attack = def.custom_attack or false,
|
||||||
|
attack_rip = 0,
|
||||||
|
|
||||||
--End of NSSM parameters
|
--End of NSSM parameters
|
||||||
|
|
||||||
@ -1843,19 +1824,20 @@ minetest.register_entity(name, {
|
|||||||
|
|
||||||
--NSSM modifications:
|
--NSSM modifications:
|
||||||
--modifications to add multiple melee attack animations
|
--modifications to add multiple melee attack animations
|
||||||
|
--ATTACK ANIMATIONS:
|
||||||
if self.mele_number>1 then
|
if self.mele_number>1 then
|
||||||
if randattack==1 then
|
if randattack==1 then
|
||||||
set_animation(self, "punch")
|
set_animation(self, "punch")
|
||||||
else
|
else
|
||||||
local attack = "punch"..(randattack-1)
|
local attack = "punch"..(randattack-1)
|
||||||
set_animation(self, attack)
|
set_animation(self, attack)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
set_animation(self, "punch")
|
set_animation(self, "punch")
|
||||||
end
|
end
|
||||||
|
|
||||||
--modifications to add special attacks to some monster:
|
--modifications to add special attacks to some monster:
|
||||||
if not self.mamma and not self.maxus and not self.pump_putter then
|
if not def.custom_attack then
|
||||||
|
|
||||||
if self.timer > 1 then
|
if self.timer > 1 then
|
||||||
|
|
||||||
@ -1900,109 +1882,8 @@ minetest.register_entity(name, {
|
|||||||
|
|
||||||
--some additions: special melee attacks
|
--some additions: special melee attacks
|
||||||
else
|
else
|
||||||
--Ant Queen: spawn other ants
|
if def.custom_attack then
|
||||||
if self.mamma then
|
def.custom_attack(self)
|
||||||
if self.timer >4 then
|
|
||||||
self.timer = 0
|
|
||||||
local p2 = p
|
|
||||||
local s2 = s
|
|
||||||
p2.y = p2.y + 1.5
|
|
||||||
s2.y = s2.y + 1.5
|
|
||||||
--if minetest.line_of_sight(p2, s2) == true then
|
|
||||||
if line_of_sight_water(self, p2, s2) == true then
|
|
||||||
-- play attack sound
|
|
||||||
if self.sounds.attack then
|
|
||||||
minetest.sound_play(self.sounds.attack, {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = self.sounds.distance
|
|
||||||
})
|
|
||||||
end
|
|
||||||
local posme = self.object:getpos()
|
|
||||||
local pos1 = {x=posme.x+math.random(-3,3), y=posme.y+0.5, z=posme.z+math.random(-3,3)}
|
|
||||||
--local pos2 = {x=posme.x+math.random(-1,1), y=posme.y+0.5, z=posme.z+math.random(-1,1)}
|
|
||||||
minetest.add_particlespawner(
|
|
||||||
100, --amount
|
|
||||||
0.1, --time
|
|
||||||
{x=pos1.x-1, y=pos1.y-1, z=pos1.z-1}, --minpos
|
|
||||||
{x=pos1.x+1, y=pos1.y+1, z=pos1.z+1}, --maxpos
|
|
||||||
{x=-0, y=-0, z=-0}, --minvel
|
|
||||||
{x=1, y=1, z=1}, --maxvel
|
|
||||||
{x=-0.5,y=5,z=-0.5}, --minacc
|
|
||||||
{x=0.5,y=5,z=0.5}, --maxacc
|
|
||||||
0.1, --minexptime
|
|
||||||
1, --maxexptime
|
|
||||||
3, --minsize
|
|
||||||
3, --maxsize
|
|
||||||
false, --collisiondetection
|
|
||||||
"tnt_smoke.png" --texture
|
|
||||||
)
|
|
||||||
minetest.add_entity(pos1, "nssm:ant_soldier")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--Pumpking: puts around some bombs
|
|
||||||
if self.pump_putter then
|
|
||||||
if self.timer >3 then
|
|
||||||
self.timer = 0
|
|
||||||
local p2 = p
|
|
||||||
local s2 = s
|
|
||||||
p2.y = p2.y + 1.5
|
|
||||||
s2.y = s2.y + 1.5
|
|
||||||
if minetest.line_of_sight(p2, s2) == true then
|
|
||||||
-- play attack sound
|
|
||||||
if self.sounds.attack then
|
|
||||||
minetest.sound_play(self.sounds.attack, {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = self.sounds.distance
|
|
||||||
})
|
|
||||||
end
|
|
||||||
local posme = self.object:getpos()
|
|
||||||
local pos1 = {x=posme.x+math.random(-1,1), y=posme.y+0.5, z=posme.z+math.random(-1,1)}
|
|
||||||
minetest.set_node(pos1, {name="nssm:pumpbomb"})
|
|
||||||
minetest.get_node_timer(pos1):start(2)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
--maxus (mese_dragon)
|
|
||||||
if self.maxus then
|
|
||||||
if self.timer > 1 then
|
|
||||||
self.timer = 0
|
|
||||||
mese_rip = mese_rip+1
|
|
||||||
local p2 = p
|
|
||||||
local s2 = s
|
|
||||||
p2.y = p2.y + 1.5
|
|
||||||
s2.y = s2.y + 1.5
|
|
||||||
if minetest.line_of_sight(p2, s2) == true then
|
|
||||||
-- play attack sound
|
|
||||||
if self.sounds.attack then
|
|
||||||
minetest.sound_play(self.sounds.attack, {
|
|
||||||
object = self.object,
|
|
||||||
max_hear_distance = self.sounds.distance
|
|
||||||
})
|
|
||||||
end
|
|
||||||
-- punch player
|
|
||||||
self.attack:punch(self.object, 1.0, {
|
|
||||||
full_punch_interval=1.0,
|
|
||||||
damage_groups = {fleshy=self.damage}
|
|
||||||
}, nil)
|
|
||||||
end
|
|
||||||
if mese_rip>=8 then
|
|
||||||
mese_rip =0
|
|
||||||
set_animation("punch1")
|
|
||||||
local posme = self.object:getpos()
|
|
||||||
for dx = -17,17 do
|
|
||||||
for dz= -17,17 do
|
|
||||||
local k = {x = posme.x+dx, y=posme.y+20, z=posme.z+dz}
|
|
||||||
local n = minetest.env:get_node(k).name
|
|
||||||
if n=="air" and math.random(1,23)==1 then
|
|
||||||
minetest.env:set_node(k, {name="nssm:mese_meteor"})
|
|
||||||
nodeupdate(k)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -2109,22 +1990,6 @@ minetest.register_entity(name, {
|
|||||||
|
|
||||||
--NSSM additions:
|
--NSSM additions:
|
||||||
|
|
||||||
--kraken
|
|
||||||
if self.inker and self.state == "attack" then
|
|
||||||
local pos = self.object:getpos()
|
|
||||||
for dx=-4,4 do
|
|
||||||
for dy=-4,4 do
|
|
||||||
for dz=-4,4 do
|
|
||||||
local p = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
|
||||||
local n = minetest.env:get_node(p).name
|
|
||||||
if (n=="default:water_source" or n=="default:water_flowing"and math.random(1,5)==1) then
|
|
||||||
minetest.env:set_node(p, {name="nssm:ink"})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--larva and mantis
|
--larva and mantis
|
||||||
if self.metamorphosis == true then
|
if self.metamorphosis == true then
|
||||||
self.metatimer = self.metatimer - dtime
|
self.metatimer = self.metatimer - dtime
|
||||||
@ -2621,7 +2486,6 @@ local c_obsidian = minetest.get_content_id("default:obsidian")
|
|||||||
local c_brick = minetest.get_content_id("default:obsidianbrick")
|
local c_brick = minetest.get_content_id("default:obsidianbrick")
|
||||||
local c_chest = minetest.get_content_id("default:chest_locked")
|
local c_chest = minetest.get_content_id("default:chest_locked")
|
||||||
|
|
||||||
|
|
||||||
-- explosion (cannot break protected or unbreakable nodes)
|
-- explosion (cannot break protected or unbreakable nodes)
|
||||||
function nssm:explosion(pos, radius, fire, smoke, sound)
|
function nssm:explosion(pos, radius, fire, smoke, sound)
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ nssm:register_mob("nssm:mese_dragon", {
|
|||||||
textures = {{"mese_dragon.png"}},
|
textures = {{"mese_dragon.png"}},
|
||||||
visual_size = {x=12, y=12},
|
visual_size = {x=12, y=12},
|
||||||
makes_footstep_sound = true,
|
makes_footstep_sound = true,
|
||||||
maxus = true,
|
|
||||||
view_range = 45,
|
view_range = 45,
|
||||||
rotate = 270,
|
rotate = 270,
|
||||||
fear_height = 5,
|
fear_height = 5,
|
||||||
@ -72,10 +71,52 @@ nssm:register_mob("nssm:mese_dragon", {
|
|||||||
local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
local t = {x=pos.x+dx, y=pos.y+dy, z=pos.z+dz}
|
||||||
local n = minetest.env:get_node(p).name
|
local n = minetest.env:get_node(p).name
|
||||||
if (n~="air" and n~="nssm:mese_meteor" and n~="fire:basic_flame") then
|
if (n~="air" and n~="nssm:mese_meteor" and n~="fire:basic_flame") then
|
||||||
minetest.env:set_node(t, {name="default:mese_block"})
|
minetest.env:set_node(t, {name="default:mese_block"})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
|
custom_attack = function(self)
|
||||||
|
if self.timer > 1 then
|
||||||
|
self.timer = 0
|
||||||
|
self.attack_rip = self.attack_rip+1
|
||||||
|
|
||||||
|
local s = self.object:getpos()
|
||||||
|
local p = self.attack:getpos()
|
||||||
|
|
||||||
|
p.y = p.y + 1.5
|
||||||
|
s.y = s.y + 1.5
|
||||||
|
|
||||||
|
if minetest.line_of_sight(p, s) == true then
|
||||||
|
-- play attack sound
|
||||||
|
if self.sounds.attack then
|
||||||
|
minetest.sound_play(self.sounds.attack, {
|
||||||
|
object = self.object,
|
||||||
|
max_hear_distance = self.sounds.distance
|
||||||
|
})
|
||||||
|
end
|
||||||
|
-- punch player
|
||||||
|
self.attack:punch(self.object, 1.0, {
|
||||||
|
full_punch_interval=1.0,
|
||||||
|
damage_groups = {fleshy=self.damage}
|
||||||
|
}, nil)
|
||||||
|
end
|
||||||
|
if self.attack_rip>=8 then
|
||||||
|
self.attack_rip =0
|
||||||
|
set_animation("punch1")
|
||||||
|
for dx = -17,17 do
|
||||||
|
for dz= -17,17 do
|
||||||
|
local k = {x = s.x+dx, y=s.y+20, z=s.z+dz}
|
||||||
|
local n = minetest.env:get_node(k).name
|
||||||
|
if n=="air" and math.random(1,23)==1 then
|
||||||
|
minetest.env:set_node(k, {name="nssm:mese_meteor"})
|
||||||
|
nodeupdate(k)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
})
|
})
|
||||||
|
22
pumpking.lua
22
pumpking.lua
@ -31,7 +31,6 @@ nssm:register_mob("nssm:pumpking", {
|
|||||||
water_damage = 2,
|
water_damage = 2,
|
||||||
lava_damage = 5,
|
lava_damage = 5,
|
||||||
light_damage = 0,
|
light_damage = 0,
|
||||||
pump_putter = true,
|
|
||||||
on_rightclick = nil,
|
on_rightclick = nil,
|
||||||
attack_type = "dogfight",
|
attack_type = "dogfight",
|
||||||
animation = {
|
animation = {
|
||||||
@ -44,5 +43,26 @@ nssm:register_mob("nssm:pumpking", {
|
|||||||
},
|
},
|
||||||
on_die=function(self,pos)
|
on_die=function(self,pos)
|
||||||
nssm:explosion(pos, 3, 0, 1, self.sounds.explode)
|
nssm:explosion(pos, 3, 0, 1, self.sounds.explode)
|
||||||
|
end,
|
||||||
|
custom_attack = function(self)
|
||||||
|
if self.timer >3 then
|
||||||
|
self.timer = 0
|
||||||
|
local s = self.object:getpos()
|
||||||
|
local p = self.attack:getpos()
|
||||||
|
p.y = p.y + 1.5
|
||||||
|
s.y = s.y + 1.5
|
||||||
|
if minetest.line_of_sight(p, s) == true then
|
||||||
|
-- play attack sound
|
||||||
|
if self.sounds.attack then
|
||||||
|
minetest.sound_play(self.sounds.attack, {
|
||||||
|
object = self.object,
|
||||||
|
max_hear_distance = self.sounds.distance
|
||||||
|
})
|
||||||
|
end
|
||||||
|
local pos1 = {x=s.x+math.random(-1,1), y=s.y-1.5, z=s.z+math.random(-1,1)}
|
||||||
|
minetest.set_node(pos1, {name="nssm:pumpbomb"})
|
||||||
|
minetest.get_node_timer(pos1):start(2)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user