summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTenPlus1 <kinsellaja@yahoo.com>2016-05-12 11:43:59 +0100
committerTenPlus1 <kinsellaja@yahoo.com>2016-05-12 11:43:59 +0100
commit3db852563c78f61c5756a8dce37b2b15e9db99ab (patch)
tree760c2a6ebb3ff1b4304b78bdcb92209cfe7f4014
parentc8932731d8842aed34a10c227c6d9ec04edaf13a (diff)
Added new dogshoot features for punch/shoot switching
-rw-r--r--api.lua36
1 files changed, 33 insertions, 3 deletions
diff --git a/api.lua b/api.lua
index 166fc43..41c7f61 100644
--- a/api.lua
+++ b/api.lua
@@ -1,5 +1,5 @@
--- Mobs Api (8th May 2016)
+-- Mobs Api (12th May 2016)
mobs = {}
mobs.mod = "redo"
@@ -1134,6 +1134,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)
@@ -1412,7 +1437,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
@@ -1602,7 +1628,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
@@ -2220,6 +2247,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,