From bdbe5f6a672f7642f8343eacc269eecc95b8828f Mon Sep 17 00:00:00 2001 From: Maksim Gamarnik Date: Tue, 31 May 2016 10:50:49 +0300 Subject: [PATCH] Crack_anylenght and mobs update --- games/default/files/mobs_animal/chicken.lua | 25 +++++----- games/default/files/mobs_animal/kitten.lua | 2 +- games/default/files/mobs_redo/api.lua | 50 ++++++++++++++++---- textures/base/crack_anylength_android.png | Bin 908 -> 819 bytes 4 files changed, 56 insertions(+), 21 deletions(-) diff --git a/games/default/files/mobs_animal/chicken.lua b/games/default/files/mobs_animal/chicken.lua index f60691d72..f764431b7 100644 --- a/games/default/files/mobs_animal/chicken.lua +++ b/games/default/files/mobs_animal/chicken.lua @@ -57,19 +57,20 @@ mobs:register_mob("mobs_animal:chicken", { do_custom = function(self) - if not self.child - and math.random(1, 500) == 1 then - - local pos = self.object:getpos() - - minetest.add_item(pos, "mobs:egg") - - minetest.sound_play("default_place_node_hard", { - pos = pos, - gain = 1.0, - max_hear_distance = 5, - }) + if self.child + or math.random(1, 5000) > 1 then + return end + + local pos = self.object:getpos() + + minetest.add_item(pos, "mobs:egg") + + minetest.sound_play("default_place_node_hard", { + pos = pos, + gain = 1.0, + max_hear_distance = 5, + }) end, }) diff --git a/games/default/files/mobs_animal/kitten.lua b/games/default/files/mobs_animal/kitten.lua index fcb5121fe..bee5fb318 100644 --- a/games/default/files/mobs_animal/kitten.lua +++ b/games/default/files/mobs_animal/kitten.lua @@ -38,7 +38,7 @@ mobs:register_mob("mobs_animal:kitten", { walk_start = 0, walk_end = 96, }, - follow = {"mobs:rat", "default:fish_raw"}, + follow = {"mobs_animal:rat", "default:fish_raw"}, view_range = 8, on_rightclick = function(self, clicker) diff --git a/games/default/files/mobs_redo/api.lua b/games/default/files/mobs_redo/api.lua index 3eed3720f..ccdb86b47 100644 --- a/games/default/files/mobs_redo/api.lua +++ b/games/default/files/mobs_redo/api.lua @@ -1,5 +1,5 @@ --- Mobs Api (8th May 2016) +-- Mobs Api (23rd May 2016) mobs = {} mobs.mod = "redo" @@ -15,7 +15,6 @@ local remove_far = minetest.setting_getbool("remove_far_mobs") -- pathfinding settings local enable_pathfinding = true -local enable_pathfind_digging = false local stuck_timeout = 3 -- how long before mob gets stuck in place and starts searching local stuck_path_timeout = 10 -- how long will mob follow path before giving up @@ -812,10 +811,9 @@ function smart_mobs(self, s, p, dist, dtime) if not self.path.way then self.path.following = false --- self.path.stuck = true -- lets make way by digging/building if not accessible - if enable_pathfind_digging then + if self.pathfinding == 2 then -- add block and remove one block above so -- there is room to jump if needed @@ -1135,6 +1133,31 @@ local follow_flop = function(self) end end +-- dogshoot attack switch and counter function +local dogswitch = function(self, dtime) + + -- switch mode not activated + if not self.dogshoot_switch + or not dtime then + return 0 + end + + self.dogshoot_count = self.dogshoot_count + dtime + + if self.dogshoot_count > self.dogshoot_count_max then + + self.dogshoot_count = 0 + + if self.dogshoot_switch == 1 then + self.dogshoot_switch = 2 + else + self.dogshoot_switch = 1 + end + end + + return self.dogshoot_switch +end + -- execute current state (stand, walk, run, attacks) local do_states = function(self, dtime) @@ -1413,7 +1436,8 @@ local do_states = function(self, dtime) end elseif self.attack_type == "dogfight" - or (self.attack_type == "dogshoot" and dist <= self.reach) then + or (self.attack_type == "dogshoot" and dogswitch(self, dtime) == 2) + or (self.attack_type == "dogshoot" and dist <= self.reach and dogswitch(self) == 0) then if self.fly and dist > self.reach then @@ -1561,9 +1585,9 @@ local do_states = function(self, dtime) if self.double_melee_attack and math.random(1, 2) == 1 then - set_animation(self, "punch") - else set_animation(self, "punch2") + else + set_animation(self, "punch") end local p2 = p @@ -1603,7 +1627,8 @@ local do_states = function(self, dtime) end elseif self.attack_type == "shoot" - or (self.attack_type == "dogshoot" and dist > self.reach) then + or (self.attack_type == "dogshoot" and dogswitch(self, dtime) == 1) + or (self.attack_type == "dogshoot" and dist > self.reach and dogswitch(self) == 0) then p.y = p.y - .5 s.y = s.y + .5 @@ -1731,6 +1756,12 @@ end local mob_punch = function(self, hitter, tflp, tool_capabilities, dir) + -- error checking when mod profiling is enabled + if not tool_capabilities then + print ("[MOBS] mod profiling enabled, damage not enabled") + return + end + -- direction error check dir = dir or {x = 0, y = 0, z = 0} @@ -2222,6 +2253,9 @@ minetest.register_entity(name, { explosion_radius = def.explosion_radius, custom_attack = def.custom_attack, double_melee_attack = def.double_melee_attack, + dogshoot_switch = def.dogshoot_switch, + dogshoot_count = 0, + dogshoot_count_max = def.dogshoot_count_max or 5, on_blast = def.on_blast or do_tnt, diff --git a/textures/base/crack_anylength_android.png b/textures/base/crack_anylength_android.png index 02191a73c0cfad4c6841153bf1286628634bc51d..8fa3a7dbca0468149840fa6050ae67d19c1fc182 100644 GIT binary patch delta 761 zcmVHzM7(z#KNFN3IS1Q$IK!5fnUm{7)&uub-T2i?h zgAqpIc#D{5IL8q>#puU@(2*R{M}bg66#31roKi_LqtAXz!%$Be4CDmJAWXy##;{Yl z7-7a(+tQe67^TUnaU3z7W8m0+q(~0wvp_5%i_A9k?;tk&=PK1@Fi6tk3w((bAwxYU z`H1??{sH724}T(NbQm9sROkqlAvN50<4VIQO-^5A^dm)bNFN142~lLU0gXZ{(QJ&v zpSyBO{EyuK5Kzk4SA>lHeCNJnUpxC>lieP8tT1f$bNUZ&xV_?f7;>N@Xm}VIh*6rH zzQ{me-CU493WO5&tIkHTm25W0fdj*l>VNidaL-p=27i1T*tyU4%NU127zl!rOP<0j z{S-=auZ+UQ*$q>ighWCCT~;aZ?Tk-M8JPQ7wz;1;nEMG#bmzs1nFn+qvj>)85ITlU z@ORsTwhI}^xeR6nt8_787=(h5gR<~10bi^>3y;qM)iY%cO+|H9$+C$9fgw_aj##z~ zI?%qa9Dkg){wm;1^@nfwAFtxVYT3Fr)pMOl^?}1MTfhJ*sxG2LGSRNRZ60*(LG8lH zgGIVXm?DsavhbS0fx}@y7$JsS-eaf|L47F!DL@A-0WQ%d{PmSX#U$Yc-LLn4yr114 zT=krosh;<`R3A70Fk3|}s>O>5l^v?q%AJg$)N<4rTeN?)gA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