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
|
||||
|
||||
|
||||
--the sword wear mechanic
|
||||
pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
if puncher:is_player() then
|
||||
@ -15,21 +16,8 @@ pig.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabili
|
||||
end
|
||||
end
|
||||
|
||||
--this controls what happens when the mob gets punched
|
||||
pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local hp = self.hp
|
||||
local vel = self.object:get_velocity()
|
||||
local hurt = tool_capabilities.damage_groups.damage
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
|
||||
--criticals
|
||||
local pos = self.object:get_pos()
|
||||
if puncher:is_player() then
|
||||
local puncher_vel = puncher:get_player_velocity().y
|
||||
if puncher_vel < 0 then
|
||||
hurt = hurt * 1.5
|
||||
--critical effect particles
|
||||
pig.do_critical_particles = function(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 40,
|
||||
time = 0.001,
|
||||
@ -47,8 +35,30 @@ pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities,
|
||||
vertical = false,
|
||||
texture = "critical.png",
|
||||
})
|
||||
end
|
||||
|
||||
--this controls what happens when the mob gets punched
|
||||
pig.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local hp = self.hp
|
||||
local vel = self.object:get_velocity()
|
||||
local hurt = tool_capabilities.damage_groups.damage
|
||||
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
|
||||
local critical = false
|
||||
|
||||
--criticals
|
||||
local pos = self.object:get_pos()
|
||||
if puncher:is_player() then
|
||||
local puncher_vel = puncher:get_player_velocity().y
|
||||
if puncher_vel < 0 then
|
||||
hurt = hurt * 1.5
|
||||
critical = true
|
||||
end
|
||||
end
|
||||
|
||||
local hp = hp-hurt
|
||||
|
||||
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
|
||||
dir.y = 0
|
||||
end
|
||||
|
||||
--critical effect
|
||||
if critical == true then
|
||||
self.do_critical_particles(pos)
|
||||
end
|
||||
|
||||
self.object:add_velocity(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
|
||||
--critical effect
|
||||
if critical == true then
|
||||
self.do_critical_particles(pos)
|
||||
end
|
||||
self.death_animation_timer = 1
|
||||
self.dead = true
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
@ -110,6 +110,10 @@ pig.on_step = function(self, dtime)
|
||||
self.manage_punch_timer(self,dtime)
|
||||
--self.debug_nametag(self,dtime)
|
||||
end
|
||||
--fix zombie state again
|
||||
if self.dead == true and self.death_animation_timer <= 0 then
|
||||
self.on_death(self)
|
||||
end
|
||||
end
|
||||
|
||||
minetest.register_entity("mob:pig", pig)
|
||||
|
@ -16,22 +16,8 @@ slime.add_sword_wear = function(self, puncher, time_from_last_punch, tool_capabi
|
||||
end
|
||||
end
|
||||
|
||||
--this controls what happens when the mob gets punched
|
||||
slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local hp = self.hp
|
||||
local vel = self.object:get_velocity()
|
||||
local hurt = tool_capabilities.damage_groups.damage
|
||||
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
|
||||
--criticals
|
||||
local pos = self.object:get_pos()
|
||||
if puncher:is_player() then
|
||||
local puncher_vel = puncher:get_player_velocity().y
|
||||
if puncher_vel < 0 then
|
||||
hurt = hurt * 1.5
|
||||
--critical effect particles
|
||||
slime.do_critical_particles = function(pos)
|
||||
minetest.add_particlespawner({
|
||||
amount = 40,
|
||||
time = 0.001,
|
||||
@ -49,6 +35,27 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities
|
||||
vertical = false,
|
||||
texture = "critical.png",
|
||||
})
|
||||
end
|
||||
|
||||
--this controls what happens when the mob gets punched
|
||||
slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
local hp = self.hp
|
||||
local vel = self.object:get_velocity()
|
||||
local hurt = tool_capabilities.damage_groups.damage
|
||||
|
||||
if not hurt then
|
||||
hurt = 1
|
||||
end
|
||||
|
||||
local critical = false
|
||||
|
||||
--criticals
|
||||
local pos = self.object:get_pos()
|
||||
if puncher:is_player() then
|
||||
local puncher_vel = puncher:get_player_velocity().y
|
||||
if puncher_vel < 0 then
|
||||
hurt = hurt * 1.5
|
||||
critical = true
|
||||
end
|
||||
end
|
||||
|
||||
@ -72,13 +79,23 @@ slime.on_punch = function(self, puncher, time_from_last_punch, tool_capabilities
|
||||
else
|
||||
dir.y = 0
|
||||
end
|
||||
|
||||
--critical effect
|
||||
if critical == true then
|
||||
self.do_critical_particles(pos)
|
||||
end
|
||||
|
||||
self.object:add_velocity(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
|
||||
--critical effect
|
||||
if critical == true then
|
||||
self.do_critical_particles(pos)
|
||||
end
|
||||
self.death_animation_timer = 1
|
||||
self.dead = true
|
||||
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.add_sword_wear(self, puncher, time_from_last_punch, tool_capabilities, dir)
|
||||
end
|
||||
|
@ -99,6 +99,10 @@ slime.on_step = function(self, dtime)
|
||||
self.manage_punch_timer(self,dtime)
|
||||
--self.debug_nametag(self,dtime)
|
||||
end
|
||||
--fix zombie state again
|
||||
if self.dead == true and self.death_animation_timer <= 0 then
|
||||
self.on_death(self)
|
||||
end
|
||||
end
|
||||
|
||||
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