star_wars/mods/mobs_npc/r2.lua

84 lines
1.8 KiB
Lua
Raw Normal View History

2020-11-20 21:00:38 +01:00
mobs:register_mob("mobs_npc:r2", {
type = "npc",
passive = false,
damage = 3,
attack_type = "dogfight",
2020-11-21 20:44:43 +01:00
attacks_monsters = false,
2020-11-20 21:00:38 +01:00
attack_npcs = false,
owner_loyal = true,
pathfinding = true,
2020-11-21 20:44:43 +01:00
hp_min = 22,
hp_max = 32,
armor = 80,
2020-11-21 22:05:34 +01:00
collisionbox = {-0.3, -0.4, -0.3, 0.3, 0.7, 0.3},
2020-11-20 21:00:38 +01:00
visual = "mesh",
2020-11-21 21:48:32 +01:00
visual_size = {x=1.3, y=1.3},
2020-11-20 21:00:38 +01:00
mesh = "r2.b3d",
drawtype = "front",
2020-11-21 20:44:43 +01:00
rotate = 180,
2020-11-20 21:00:38 +01:00
textures = {
{"r2-blue.png"},
},
makes_footstep_sound = false,
sounds = {},
2020-11-21 20:44:43 +01:00
walk_velocity = 0.5,
run_velocity = 1,
jump = false,
2020-11-20 21:00:38 +01:00
drops = {
{name = "default:axe_stone", chance = 5, min = 1, max = 1},
},
water_damage = 0,
lava_damage = 2,
light_damage = 0,
follow = {"farming:bread", "mobs:meat", "default:diamond"},
view_range = 15,
owner = "",
order = "follow",
fear_height = 3,
animation = {
speed_normal = 2,
speed_run = 3,
walk_start = 30,
walk_end = 31,
stand_start = 1,
stand_end = 20,
run_start = 30,
run_end = 31,
},
on_rightclick = function(self, clicker)
-- feed to heal npc
if mobs:feed_tame(self, clicker, 8, true, true) then return end
-- capture npc with net or lasso
if mobs:capture_mob(self, clicker, nil, 5, 80, false, nil) then return end
-- protect npc with mobs:protector
if mobs:protect(self, clicker) then return end
local name = clicker:get_player_name()
-- by right-clicking owner can switch npc between follow and stand
if self.owner and self.owner == name then
if self.order == "follow" then
self.attack = nil
self.order = "stand"
self.state = "stand"
self:set_animation("stand")
self:set_velocity(0)
2020-11-21 21:32:51 +01:00
minetest.chat_send_player(name, "R2 Unit stands still.")
2020-11-20 21:00:38 +01:00
else
self.order = "follow"
2020-11-21 21:32:51 +01:00
minetest.chat_send_player(name, "R2 Unit will follow you.")
2020-11-20 21:00:38 +01:00
end
end
end,
})
2020-11-20 21:15:44 +01:00
mobs:register_egg("mobs_npc:r2", "R2 Astromech", "default_brick.png", 1)