Skip to content

Commit a2a5cf2

Browse files
authored
Merge pull request #8 from berengma/dev
knockback and dnmwM
2 parents 6e737a5 + 3433187 commit a2a5cf2

File tree

4 files changed

+47
-6
lines changed

4 files changed

+47
-6
lines changed

behaviors.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,22 @@ function wildcow.hq_overrun(self,prty,target)
7575
tpos = mobkit.pos_translate2d(mobkit.get_stand_pos(self),tyaw,10)
7676
local dir = vector.subtract(tpos,pos)
7777
mobkit.clear_queue_high(self)
78+
local hit = false
7879

7980
local func = function(self)
8081
if not mobkit.is_alive(target) then return true end
81-
if water_life.dist2tgt(self,target) > self.view_range then return true end
82+
local dist = water_life.dist2tgt(self,target)
83+
if dist > self.view_range then return true end
84+
dist = math.floor(dist + 0.5)
8285

83-
if water_life.dist2tgt(self,target) < 1 then
84-
target:punch(self.object,1,self.attack)
86+
87+
if dist == 1 and not hit then
88+
mobkit.animate(self,'attack')
89+
target:punch(self.object,1,self.attack)
90+
water_life.knockback_player(self,target,20)
91+
hit = true
8592
end
93+
8694
if mobkit.is_queue_empty_low(self) and self.isonground then
8795
local pos = mobkit.get_stand_pos(self)
8896
if vector.distance(pos,tpos) >= 1.3 then

calf.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ minetest.register_entity("wildcow:auroch_calf",{
130130
{name = "water_life:meat_raw", chance = 2, min = 1, max = 1,},
131131
},
132132
mama = {},
133+
predators = {["water_life:croc"]=1,
134+
["water_life:alligator"]=1,
135+
["water_life:snake"]=1,
136+
},
133137

134138
brainfunc = calf_brain,
135139

female.lua

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,30 @@ local function female_brain(self)
7777
end
7878

7979
if mobkit.timer(self,1) then
80+
local childent = nil
81+
local predator = nil
82+
local danger = ""
8083
local prty = mobkit.get_queue_priority(self)
8184
local obj = self.object
8285
local pos = self.object:get_pos()
8386
local bosspos = water_life.headpos(self)
8487
local calf = water_life.pregnant(self)
8588
local dna = water_life.dna(self)
89+
local baby = wildcow.whereismum(self,8,true) -- true searches for calfs, not females
90+
if baby and #baby > 0 then
91+
childent = baby[1]:get_luaentity() -- get the entity to do further checks
92+
end
8693

94+
if childent then
95+
predator = water_life.get_closest_enemy(childent,true)
96+
if predator then
97+
if predator:is_player() then
98+
danger = "\n DANGER: "..predator:get_player_name()
99+
else
100+
danger = "\n DANGER: "..predator:get_luaentity().name
101+
end
102+
end
103+
end
87104

88105
if calf > 0 then
89106
calf = os.clock() - calf
@@ -119,10 +136,22 @@ local function female_brain(self)
119136

120137
obj:set_nametag_attributes({
121138
color = '#ff7373',
122-
text = tostring(water_life.is_alive(self)).."\n"..kepala.."\n"..hamil.."\n"..tostring(water_life.hunger(self)).."% hunger\n"..tostring(water_life.horny(self)).."% horny",
139+
text = tostring(water_life.is_alive(self)).."\n"..kepala.."\n"..hamil.."\n"..tostring(water_life.hunger(self)).."% hunger\n"..tostring(water_life.horny(self)).."% horny"..danger,
123140
})
124141
end
125-
142+
143+
if prty < 50 and predator and baby[1] then -- do not mess with MAMA !
144+
local ppos = predator:get_pos()
145+
local bpos = baby[1]:get_pos()
146+
local dist = water_life.dist2tgt(childent,predator)
147+
if math.abs(ppos.y - bpos.y) < 3 and dist < 8 and not water_life.inwater(predator) then
148+
wildcow.hq_overrun(self,50,predator)
149+
end
150+
end
151+
152+
153+
154+
126155
if prty < 20 and water_life.inwater(self.object) then
127156
mobkit.hq_liquid_recovery(self,20)
128157
water_life.hunger(self,-5)

male.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ minetest.register_entity("wildcow:auroch_male",{
177177
lung_capacity = 20, -- seconds
178178
max_hp = 25,
179179
timeout = wildcow.lifetime,
180-
attack={range=0.5,damage_groups={fleshy=5}},
180+
attack={range=0.5,damage_groups={fleshy=10}},
181181
sounds = {
182182
--scared='deer_scared',
183183
--hurt = 'deer_hurt',

0 commit comments

Comments
 (0)