1
0
Fork 0

Merge pull request 'Massive overhaul to projectile mobs with custom projectile function, make llamas spit' (#1617) from jordan4ibanez/MineClone2:mineclone5 into mineclone5

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/1617
mineclone5
jordan4ibanez 2021-04-23 18:10:52 +00:00
commit d231edbb43
11 changed files with 92 additions and 7 deletions

View File

@ -145,7 +145,7 @@ local piglin = {
if mod_bows then
-- 2-4 damage per arrow
local dmg = math.max(4, math.random(2, 8))
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end
end,
shoot_interval = 1.2,

View File

@ -161,6 +161,7 @@ dofile(api_path .. "attack_type_instructions.lua")
dofile(api_path .. "sound_handling.lua")
dofile(api_path .. "death_logic.lua")
dofile(api_path .. "mob_effects.lua")
dofile(api_path .. "projectile_handling.lua")
mobs.spawning_mobs = {}

View File

@ -670,7 +670,6 @@ mobs.mob_step = function(self, dtime)
--do custom mob instructions
if self.do_custom then
print("doing custom instructions")
-- when false skip going any further
if self.do_custom(self, dtime) == false then
--this overrides internal lua collision detection

View File

@ -0,0 +1,41 @@
local GRAVITY = minetest.settings:get("movement_gravity")-- + 9.81
mobs.shoot_projectile_handling = function(arrow_item, pos, dir, yaw, shooter, power, damage, is_critical, bow_stack, collectable)
local obj = minetest.add_entity({x=pos.x,y=pos.y,z=pos.z}, arrow_item.."_entity")
if power == nil then
power = 19
end
if damage == nil then
damage = 3
end
local knockback
if bow_stack then
local enchantments = mcl_enchanting.get_enchantments(bow_stack)
if enchantments.power then
damage = damage + (enchantments.power + 1) / 4
end
if enchantments.punch then
knockback = enchantments.punch * 3
end
if enchantments.flame then
mcl_burning.set_on_fire(obj, math.huge)
end
end
obj:set_velocity({x=dir.x*power, y=dir.y*power, z=dir.z*power})
obj:set_acceleration({x=0, y=-GRAVITY, z=0})
obj:set_yaw(yaw-math.pi/2)
local le = obj:get_luaentity()
le._shooter = shooter
le._damage = damage
le._is_critical = is_critical
le._startpos = pos
le._knockback = knockback
le._collectable = collectable
--play custom shoot sound
if shooter ~= nil and shooter.shoot_sound then
minetest.sound_play(shooter.shoot_sound, {pos=pos, max_hear_distance=16}, true)
end
return obj
end

View File

@ -82,7 +82,7 @@ mobs:register_mob("mobs_mc:blaze", {
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mobs_mc:blaze_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mobs_mc:blaze_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
do_custom = function(self)

View File

@ -15,7 +15,7 @@ mobs:register_mob("mobs_mc:enderdragon", {
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mobs_mc:dragon_fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
hp_max = 200,
hp_min = 200,

View File

@ -64,7 +64,7 @@ mobs:register_mob("mobs_mc:ghast", {
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mobs_mc:fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mobs_mc:fireball", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
--[[
do_custom = function(self)

View File

@ -27,6 +27,15 @@ local carpets = {
mobs:register_mob("mobs_mc:llama", {
type = "animal",
spawn_class = "passive",
rotate = 270,
neutral = true,
group_attack = true,
attack_type = "projectile",
shoot_arrow = function(self, pos, dir)
-- 2-4 damage per arrow
local dmg = 1
mobs.shoot_projectile_handling("mobs_mc:spit", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end,
hp_min = 15,
hp_max = 30,
xp_min = 1,
@ -50,6 +59,7 @@ mobs:register_mob("mobs_mc:llama", {
run_velocity = 4.4,
follow_velocity = 4.4,
floats = 1,
reach = 6,
drops = {
{name = mobs_mc.items.leather,
chance = 1,
@ -235,3 +245,37 @@ mobs_mc.spawn_height.overworld_max)
-- spawn eggs
mobs:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)
-- llama spit
mobs:register_arrow("mobs_mc:spit", {
visual = "sprite",
visual_size = {x = 0.3, y = 0.3},
textures = {"mobs_mc_spit.png"},
velocity = 1,
speed = 1,
tail = 1,
tail_texture = "mobs_mc_spit.png",
tail_size = 2,
hit_player = function(self, player)
if rawget(_G, "armor") and armor.last_damage_types then
armor.last_damage_types[player:get_player_name()] = "spit"
end
player:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = self._damage},
}, nil)
end,
hit_mob = function(self, mob)
mob:punch(self.object, 1.0, {
full_punch_interval = 1.0,
damage_groups = {fleshy = _damage},
}, nil)
end,
hit_node = function(self, pos, node)
--does nothing
end
})

View File

@ -97,7 +97,7 @@ local skeleton = {
if mod_bows then
-- 2-4 damage per arrow
local dmg = math.random(2,4)
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end
end,
shoot_interval = 2,

Binary file not shown.

After

Width:  |  Height:  |  Size: 677 B

View File

@ -17,7 +17,7 @@ mobs:register_mob("mobs_mc:illusioner", {
if mod_bows then
-- 1-4 damage per arrow
local dmg = math.random(1, 4)
mcl_bows.shoot_arrow("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
mobs.shoot_projectile_handling("mcl_bows:arrow", pos, dir, self.object:get_yaw(), self.object, nil, dmg)
end
end,
hp_min = 32,