Make criticals even better
This commit is contained in:
parent
11c7445c01
commit
8293781f54
@ -1,5 +1,6 @@
|
|||||||
--this is the file which houses the functions that control how mobs interact with the world
|
--this is the file which houses the functions that control how mobs interact with the world
|
||||||
|
|
||||||
|
|
||||||
--the sword wear mechanic
|
--the sword wear mechanic
|
||||||
pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
if puncher:is_player() then
|
if puncher:is_player() then
|
||||||
@ -15,40 +16,49 @@ pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabili
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--critical effect particles
|
||||||
|
pig.do_critical_particles = function(pos)
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 40,
|
||||||
|
time = 0.001,
|
||||||
|
minpos = pos,
|
||||||
|
maxpos = pos,
|
||||||
|
minvel = vector.new(-5,-5,-5),
|
||||||
|
maxvel = vector.new(5,5,5),
|
||||||
|
minacc = {x=0, y=0, z=0},
|
||||||
|
maxacc = {x=0, y=0, z=0},
|
||||||
|
minexptime = 1.1,
|
||||||
|
maxexptime = 1.5,
|
||||||
|
minsize = 1,
|
||||||
|
maxsize = 2,
|
||||||
|
collisiondetection = false,
|
||||||
|
vertical = false,
|
||||||
|
texture = "critical.png",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
--this controls what happens when the mob gets punched
|
--this controls what happens when the mob gets punched
|
||||||
pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
local hp = self.hp
|
local hp = self.hp
|
||||||
local vel = self.object:get_velocity()
|
local vel = self.object:get_velocity()
|
||||||
local hurt = tool_capabilities.damage_groups.damage
|
local hurt = tool_capabilities.damage_groups.damage
|
||||||
|
|
||||||
if not hurt then
|
if not hurt then
|
||||||
hurt = 1
|
hurt = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local critical = false
|
||||||
|
|
||||||
--criticals
|
--criticals
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
if puncher:is_player() then
|
if puncher:is_player() then
|
||||||
local puncher_vel = puncher:get_player_velocity().y
|
local puncher_vel = puncher:get_player_velocity().y
|
||||||
if puncher_vel < 0 then
|
if puncher_vel < 0 then
|
||||||
hurt = hurt * 1.5
|
hurt = hurt * 1.5
|
||||||
minetest.add_particlespawner({
|
critical = true
|
||||||
amount = 40,
|
|
||||||
time = 0.001,
|
|
||||||
minpos = pos,
|
|
||||||
maxpos = pos,
|
|
||||||
minvel = vector.new(-5,-5,-5),
|
|
||||||
maxvel = vector.new(5,5,5),
|
|
||||||
minacc = {x=0, y=0, z=0},
|
|
||||||
maxacc = {x=0, y=0, z=0},
|
|
||||||
minexptime = 1.1,
|
|
||||||
maxexptime = 1.5,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "critical.png",
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local hp = hp-hurt
|
local hp = hp-hurt
|
||||||
|
|
||||||
if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then
|
if (self.punched_timer <= 0 and hp > 1) or puncher == self.object then
|
||||||
@ -69,17 +79,27 @@ pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities,
|
|||||||
else
|
else
|
||||||
dir.y = 0
|
dir.y = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--critical effect
|
||||||
|
if critical == true then
|
||||||
|
self.do_critical_particles(pos)
|
||||||
|
end
|
||||||
|
|
||||||
self.object:add_velocity(dir)
|
self.object:add_velocity(dir)
|
||||||
|
|
||||||
|
|
||||||
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then
|
elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then
|
||||||
|
--critical effect
|
||||||
|
if critical == true then
|
||||||
|
self.do_critical_particles(pos)
|
||||||
|
end
|
||||||
self.death_animation_timer = 1
|
self.death_animation_timer = 1
|
||||||
self.dead = true
|
self.dead = true
|
||||||
minetest.sound_play("pig_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
minetest.sound_play("pig_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
||||||
--self.object:set_texture_mod("^[colorize:red:90")
|
|
||||||
--self.child:set_texture_mod("^[colorize:red:90")
|
|
||||||
|
|
||||||
|
self.object:set_texture_mod("^[colorize:red:130")
|
||||||
|
if self.child then
|
||||||
|
self.child:set_texture_mod("^[colorize:red:130")
|
||||||
|
end
|
||||||
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -110,6 +110,10 @@ pig.on_step = function(self, dtime)
|
|||||||
self.manage_punch_timer(self,dtime)
|
self.manage_punch_timer(self,dtime)
|
||||||
--self.debug_nametag(self,dtime)
|
--self.debug_nametag(self,dtime)
|
||||||
end
|
end
|
||||||
|
--fix zombie state again
|
||||||
|
if self.dead == true and self.death_animation_timer <= 0 then
|
||||||
|
self.on_death(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("mob:pig", pig)
|
minetest.register_entity("mob:pig", pig)
|
||||||
|
@ -16,6 +16,27 @@ slime.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabi
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--critical effect particles
|
||||||
|
slime.do_critical_particles = function(pos)
|
||||||
|
minetest.add_particlespawner({
|
||||||
|
amount = 40,
|
||||||
|
time = 0.001,
|
||||||
|
minpos = pos,
|
||||||
|
maxpos = pos,
|
||||||
|
minvel = vector.new(-5,-5,-5),
|
||||||
|
maxvel = vector.new(5,5,5),
|
||||||
|
minacc = {x=0, y=0, z=0},
|
||||||
|
maxacc = {x=0, y=0, z=0},
|
||||||
|
minexptime = 1.1,
|
||||||
|
maxexptime = 1.5,
|
||||||
|
minsize = 1,
|
||||||
|
maxsize = 2,
|
||||||
|
collisiondetection = false,
|
||||||
|
vertical = false,
|
||||||
|
texture = "critical.png",
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
--this controls what happens when the mob gets punched
|
--this controls what happens when the mob gets punched
|
||||||
slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
local hp = self.hp
|
local hp = self.hp
|
||||||
@ -26,29 +47,15 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities
|
|||||||
hurt = 1
|
hurt = 1
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local critical = false
|
||||||
|
|
||||||
--criticals
|
--criticals
|
||||||
local pos = self.object:get_pos()
|
local pos = self.object:get_pos()
|
||||||
if puncher:is_player() then
|
if puncher:is_player() then
|
||||||
local puncher_vel = puncher:get_player_velocity().y
|
local puncher_vel = puncher:get_player_velocity().y
|
||||||
if puncher_vel < 0 then
|
if puncher_vel < 0 then
|
||||||
hurt = hurt * 1.5
|
hurt = hurt * 1.5
|
||||||
minetest.add_particlespawner({
|
critical = true
|
||||||
amount = 40,
|
|
||||||
time = 0.001,
|
|
||||||
minpos = pos,
|
|
||||||
maxpos = pos,
|
|
||||||
minvel = vector.new(-5,-5,-5),
|
|
||||||
maxvel = vector.new(5,5,5),
|
|
||||||
minacc = {x=0, y=0, z=0},
|
|
||||||
maxacc = {x=0, y=0, z=0},
|
|
||||||
minexptime = 1.1,
|
|
||||||
maxexptime = 1.5,
|
|
||||||
minsize = 1,
|
|
||||||
maxsize = 2,
|
|
||||||
collisiondetection = false,
|
|
||||||
vertical = false,
|
|
||||||
texture = "critical.png",
|
|
||||||
})
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -72,13 +79,23 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities
|
|||||||
else
|
else
|
||||||
dir.y = 0
|
dir.y = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--critical effect
|
||||||
|
if critical == true then
|
||||||
|
self.do_critical_particles(pos)
|
||||||
|
end
|
||||||
|
|
||||||
self.object:add_velocity(dir)
|
self.object:add_velocity(dir)
|
||||||
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then
|
elseif self.punched_timer <= 0 and self.death_animation_timer == 0 then
|
||||||
|
--critical effect
|
||||||
|
if critical == true then
|
||||||
|
self.do_critical_particles(pos)
|
||||||
|
end
|
||||||
self.death_animation_timer = 1
|
self.death_animation_timer = 1
|
||||||
self.dead = true
|
self.dead = true
|
||||||
minetest.sound_play("slime_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
minetest.sound_play("slime_die", {object=self.object, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100})
|
||||||
--self.object:set_texture_mod("^[colorize:red:90")
|
self.object:set_texture_mod("^[colorize:red:130")
|
||||||
--self.child:set_texture_mod("^[colorize:red:90")
|
--self.child:set_texture_mod("^[colorize:red:90")
|
||||||
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
self.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||||
end
|
end
|
||||||
|
@ -99,6 +99,10 @@ slime.on_step = function(self, dtime)
|
|||||||
self.manage_punch_timer(self,dtime)
|
self.manage_punch_timer(self,dtime)
|
||||||
--self.debug_nametag(self,dtime)
|
--self.debug_nametag(self,dtime)
|
||||||
end
|
end
|
||||||
|
--fix zombie state again
|
||||||
|
if self.dead == true and self.death_animation_timer <= 0 then
|
||||||
|
self.on_death(self)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity("mob:slime", slime)
|
minetest.register_entity("mob:slime", slime)
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 575 B After Width: | Height: | Size: 575 B |
Loading…
x
Reference in New Issue
Block a user