animalia/mobs/pig.lua

150 lines
3 KiB
Lua
Raw Normal View History

2020-11-11 23:16:50 -08:00
---------
-- Pig --
---------
2022-02-10 18:00:06 -08:00
creatura.register_mob("animalia:pig", {
2023-03-15 14:27:40 -07:00
-- Engine Props
2022-02-10 18:00:06 -08:00
visual_size = {x = 10, y = 10},
2023-03-15 14:27:40 -07:00
mesh = "animalia_pig.b3d",
female_textures = {
"animalia_pig_1.png",
"animalia_pig_2.png",
"animalia_pig_3.png"
},
male_textures = {
"animalia_pig_1.png^animalia_pig_tusks.png",
"animalia_pig_2.png^animalia_pig_tusks.png",
"animalia_pig_3.png^animalia_pig_tusks.png"
},
child_textures = {
"animalia_pig_1.png",
"animalia_pig_2.png",
"animalia_pig_3.png"
2020-11-11 23:16:50 -08:00
},
makes_footstep_sound = true,
2023-03-15 14:27:40 -07:00
-- Creatura Props
max_health = 20,
damage = 2,
speed = 3,
tracking_range = 12,
despawn_after = 500,
stepheight = 1.1,
2022-02-10 18:00:06 -08:00
sounds = {
random = {
2023-03-15 14:27:40 -07:00
name = "animalia_pig",
gain = 1.0,
distance = 8
},
hurt = {
name = "animalia_pig_hurt",
2020-11-11 23:16:50 -08:00
gain = 1.0,
distance = 8
},
death = {
name = "animalia_pig_death",
2022-02-10 18:00:06 -08:00
gain = 1.0,
distance = 8
}
},
2023-03-15 14:27:40 -07:00
hitbox = {
width = 0.35,
height = 0.7
},
animations = {
stand = {range = {x = 1, y = 60}, speed = 20, frame_blend = 0.3, loop = true},
walk = {range = {x = 70, y = 89}, speed = 30, frame_blend = 0.3, loop = true},
run = {range = {x = 100, y = 119}, speed = 40, frame_blend = 0.3, loop = true},
},
follow = animalia.food_crops,
drops = {
{name = "animalia:porkchop_raw", min = 1, max = 3, chance = 1}
},
2023-03-15 14:27:40 -07:00
-- Animalia Props
flee_puncher = true,
catch_with_net = true,
catch_with_lasso = true,
birth_count = 2,
head_data = {
offset = {x = 0, y = 0.7, z = 0},
pitch_correction = 0,
pivot_h = 0.5,
pivot_v = 0.3
},
-- Functions
2022-02-10 18:00:06 -08:00
utility_stack = {
2022-10-17 17:23:26 -07:00
{
2022-02-10 18:00:06 -08:00
utility = "animalia:wander",
2022-08-12 22:17:42 -07:00
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
return 0.1, {self, true}
end
},
2022-10-17 17:23:26 -07:00
{
2023-03-15 14:27:40 -07:00
utility = "animalia:walk_to_pos_and_interact",
2022-02-10 18:00:06 -08:00
get_score = function(self)
2023-03-15 14:27:40 -07:00
if math.random(6) < 2
or self:get_utility() == "animalia:walk_to_pos_and_interact" then
return 0.2, {self, animalia.find_crop, animalia.eat_crop}
2022-02-10 18:00:06 -08:00
end
return 0
end
},
2022-10-17 17:23:26 -07:00
{
2022-02-10 18:00:06 -08:00
utility = "animalia:swim_to_land",
2022-08-12 22:17:42 -07:00
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
if self.in_liquid then
2022-08-12 22:17:42 -07:00
return 0.3, {self}
2022-02-10 18:00:06 -08:00
end
return 0
end
},
2022-10-17 17:23:26 -07:00
animalia.global_utils.basic_follow,
{
2022-08-12 22:17:42 -07:00
utility = "animalia:breed",
step_delay = 0.25,
2022-02-10 18:00:06 -08:00
get_score = function(self)
2022-02-22 20:27:38 -08:00
if self.breeding
and animalia.get_nearby_mate(self, self.name) then
2022-08-12 22:17:42 -07:00
return 0.5, {self}
2022-02-10 18:00:06 -08:00
end
return 0
end
2022-10-17 17:23:26 -07:00
},
animalia.global_utils.basic_flee
2020-11-11 23:16:50 -08:00
},
2023-03-15 14:27:40 -07:00
activate_func = function(self)
2022-02-10 18:00:06 -08:00
animalia.initialize_api(self)
animalia.initialize_lasso(self)
end,
2023-03-15 14:27:40 -07:00
step_func = function(self)
2022-02-10 18:00:06 -08:00
animalia.step_timers(self)
animalia.do_growth(self, 60)
2023-03-15 14:27:40 -07:00
animalia.head_tracking(self)
2022-02-10 18:00:06 -08:00
animalia.update_lasso_effects(self)
animalia.random_sound(self)
end,
2023-03-15 14:27:40 -07:00
death_func = animalia.death_func,
2020-11-11 23:16:50 -08:00
on_rightclick = function(self, clicker)
2022-02-10 18:00:06 -08:00
if animalia.feed(self, clicker, false, true) then
return
end
if animalia.set_nametag(self, clicker) then
return
end
2020-11-11 23:16:50 -08:00
end,
2023-03-15 14:27:40 -07:00
2022-10-17 17:23:26 -07:00
on_punch = animalia.punch
2020-11-11 23:16:50 -08:00
})
2023-03-15 14:27:40 -07:00
creatura.register_spawn_item("animalia:pig", {
col1 = "e0b1a7",
col2 = "cc9485"
})