Added the new "charge" attack
This commit is contained in:
parent
4a23172d35
commit
35b14a5943
@ -12,7 +12,7 @@ mobs:register_mob("nssm:river_lord", {
|
||||
walk_velocity = 0.6,
|
||||
rotate = 270,
|
||||
fear_height = 4,
|
||||
run_velocity = 4,
|
||||
run_velocity = 5,
|
||||
--[[sounds = {
|
||||
random = "river_lord",
|
||||
},]]
|
||||
@ -48,11 +48,20 @@ mobs:register_mob("nssm:river_lord", {
|
||||
run_end = 180,
|
||||
punch_start = 260,
|
||||
punch_end = 280,
|
||||
punch2_start = 230, --charge_start
|
||||
punch2_end = 250, --charge_end
|
||||
die_start = 290,
|
||||
die_end = 310,
|
||||
speed_die = 10,
|
||||
--Arena di fango inizio: 190
|
||||
--Arena di fango fine: 220
|
||||
--Inizio carica 230
|
||||
--Fine carica 250
|
||||
},
|
||||
do_custom = function (self)
|
||||
if self.other_state and self.other_state == "charge" then
|
||||
do_charge(self)
|
||||
end
|
||||
end,
|
||||
custom_attack = function (self)
|
||||
charge_attack(self)
|
||||
end,
|
||||
})
|
||||
|
@ -13,7 +13,7 @@ mobs:register_mob("nssm:silver_sandonisc", {
|
||||
reach = 2,
|
||||
fear_height = 3,
|
||||
walk_velocity = 0.6,
|
||||
run_velocity = 3.5,
|
||||
run_velocity = 5,
|
||||
damage = 3,
|
||||
-- sounds = {
|
||||
-- random = "silver_sandonisc",
|
||||
@ -49,7 +49,18 @@ mobs:register_mob("nssm:silver_sandonisc", {
|
||||
run_end = 70,
|
||||
punch_start = 130,
|
||||
punch_end = 160,
|
||||
punch2_start = 40,
|
||||
punch2_end = 70,
|
||||
speed_punch2 = 40,
|
||||
die_start = 235,
|
||||
die_end = 255,
|
||||
},
|
||||
do_custom = function (self)
|
||||
if self.other_state and self.other_state == "charge" then
|
||||
do_charge(self)
|
||||
end
|
||||
end,
|
||||
custom_attack = function (self)
|
||||
charge_attack(self)
|
||||
end,
|
||||
})
|
||||
|
47
nssm_api.lua
47
nssm_api.lua
@ -890,3 +890,50 @@ function tnt_boom_nssm(pos, def, block, effects)
|
||||
add_effects(pos, radius, drops)
|
||||
end
|
||||
end
|
||||
|
||||
function charge_attack(self)
|
||||
local s = self.object:getpos()
|
||||
local p = self.attack:getpos()
|
||||
local vec = vector.multiply(vector.normalize(vector.subtract(p,s)),self.run_velocity)
|
||||
|
||||
if self.other_state and self.other_state == "charge" then --the mob was already charging
|
||||
do_charge(self)
|
||||
else
|
||||
self.other_state = "charge"
|
||||
vec.y = -5
|
||||
self.charge_vec = vec
|
||||
self.charge_dir = self.object:getyaw()
|
||||
do_charge(self)
|
||||
self.charge_timer = os.time()
|
||||
minetest.after(3, function(self)
|
||||
self.other_state = "stand"
|
||||
self.state = "stand"
|
||||
end,self)
|
||||
end
|
||||
end
|
||||
|
||||
function do_charge(self)
|
||||
self.state = ""
|
||||
if self.charge_vec and self.charge_dir then
|
||||
set_animation(self, "punch2")
|
||||
self.object:setvelocity(self.charge_vec)
|
||||
self.object:setyaw(self.charge_dir)
|
||||
local all_objects = minetest.get_objects_inside_radius(self.object:getpos(), 0.75)
|
||||
local _,obj
|
||||
for _,obj in ipairs(all_objects) do
|
||||
if obj:is_player() then
|
||||
obj:set_hp(obj:get_hp()-1)
|
||||
--[[obj.object:punch(self.object, 1.0, {
|
||||
full_punch_interval = 1.0,
|
||||
damage_groups = {fleshy = self.damage}
|
||||
}, nil)]]
|
||||
elseif obj:get_luaentity() and obj:get_luaentity().health and obj:get_luaentity().name ~= self.object:get_luaentity().name then
|
||||
obj:get_luaentity().health = obj:get_luaentity().health - self.damage
|
||||
end
|
||||
end
|
||||
end
|
||||
if os.time() - self.charge_timer > 5 then
|
||||
self.other_state = "stand"
|
||||
self.state = "stand"
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user