From 406fc2770d573f66a8f6a9c9948dac31c6e913e7 Mon Sep 17 00:00:00 2001 From: Benefit-Zebra <42458260+Benefit-Zebra@users.noreply.github.com> Date: Sat, 4 Jul 2020 13:59:33 +0530 Subject: [PATCH 1/6] Update bomb.py This will lead to solving of issue #90 --- assets/src/ba_data/python/bastd/actor/bomb.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/src/ba_data/python/bastd/actor/bomb.py b/assets/src/ba_data/python/bastd/actor/bomb.py index 9d2ff2a5..c5cb74a7 100644 --- a/assets/src/ba_data/python/bastd/actor/bomb.py +++ b/assets/src/ba_data/python/bastd/actor/bomb.py @@ -1005,11 +1005,11 @@ class Bomb(ba.Actor): ba.playsound(factory.activate_sound, 0.5, position=self.node.position) def _handle_hit(self, msg: ba.HitMessage) -> None: - ispunch = (msg.srcnode and msg.srcnode.getnodetype() == 'spaz') + ispunched = (msg.srcnode and msg.srcnode.getnodetype() == 'spaz') # Normal bombs are triggered by non-punch impacts; # impact-bombs by all impacts. - if (not self._exploded and not ispunch + if not ispunched and (not self._exploded or self.bomb_type in ['impact', 'land_mine']): # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the From 3044099832a88e6a7e1a0028b3403192713d2730 Mon Sep 17 00:00:00 2001 From: Benefit-Zebra <42458260+Benefit-Zebra@users.noreply.github.com> Date: Sat, 4 Jul 2020 14:01:57 +0530 Subject: [PATCH 2/6] Added comment for changes --- assets/src/ba_data/python/bastd/actor/bomb.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/assets/src/ba_data/python/bastd/actor/bomb.py b/assets/src/ba_data/python/bastd/actor/bomb.py index c5cb74a7..ae6d0666 100644 --- a/assets/src/ba_data/python/bastd/actor/bomb.py +++ b/assets/src/ba_data/python/bastd/actor/bomb.py @@ -1011,6 +1011,10 @@ class Bomb(ba.Actor): # impact-bombs by all impacts. if not ispunched and (not self._exploded or self.bomb_type in ['impact', 'land_mine']): + # We don't want to give the credit and points to player, + # who punched the bomb of other player in a chain reaction. + # And this will protect the bomb from getting hit_type 'punch'. + # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the # person causing them). From 229ed58c48d7423ea72bae5612d0e11af2ae5677 Mon Sep 17 00:00:00 2001 From: Benefit-Zebra <42458260+Benefit-Zebra@users.noreply.github.com> Date: Sat, 4 Jul 2020 14:23:58 +0530 Subject: [PATCH 3/6] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 19efe74b..77942c9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ ### 1.5.18 (20106) - A bit of project cleanup; tools/snippets is now tools/pcommand, etc. +- More code improvement ### 1.5.17 (20102) - More cleanup to logging and crash reporting system. From 500ad1a52e11eb976f398c1012641a97168a7ae1 Mon Sep 17 00:00:00 2001 From: Benefit-Zebra <42458260+Benefit-Zebra@users.noreply.github.com> Date: Sat, 4 Jul 2020 14:25:33 +0530 Subject: [PATCH 4/6] Adding myself to CONTRIBUTORS.md --- CONTRIBUTORS.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index b17b8450..7a0a5ed2 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -10,3 +10,7 @@ ### Roman Trapeznikov - Bug fixes and code cleanup + +### Benefit-Zebra +- Unofficial BombSquad Bug Finder +- Code Cleanup From 5fdd12b535a9af0c85cc3c807dbcf973a3fffbba Mon Sep 17 00:00:00 2001 From: Benefit-Zebra <42458260+Benefit-Zebra@users.noreply.github.com> Date: Sat, 4 Jul 2020 18:53:20 +0530 Subject: [PATCH 5/6] Update bomb.py Removed trailing whitespace --- assets/src/ba_data/python/bastd/actor/bomb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/assets/src/ba_data/python/bastd/actor/bomb.py b/assets/src/ba_data/python/bastd/actor/bomb.py index ae6d0666..47a7463d 100644 --- a/assets/src/ba_data/python/bastd/actor/bomb.py +++ b/assets/src/ba_data/python/bastd/actor/bomb.py @@ -1014,7 +1014,7 @@ class Bomb(ba.Actor): # We don't want to give the credit and points to player, # who punched the bomb of other player in a chain reaction. # And this will protect the bomb from getting hit_type 'punch'. - + # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the # person causing them). From 19e78590424d51a9baf0f5158b1c5eb797f75159 Mon Sep 17 00:00:00 2001 From: Eric Froemling Date: Mon, 6 Jul 2020 15:59:43 -0700 Subject: [PATCH 6/6] Bomb logic cleanup --- assets/src/ba_data/python/bastd/actor/bomb.py | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/assets/src/ba_data/python/bastd/actor/bomb.py b/assets/src/ba_data/python/bastd/actor/bomb.py index 47a7463d..fd4fa485 100644 --- a/assets/src/ba_data/python/bastd/actor/bomb.py +++ b/assets/src/ba_data/python/bastd/actor/bomb.py @@ -718,10 +718,16 @@ class Bomb(ba.Actor): # By default our hit type/subtype is our own, but we pick up types of # whoever sets us off so we know what caused a chain reaction. + # UPDATE (July 2020): not inheriting hit-types anymore; this causes + # weird effects such as land-mines inheriting 'punch' hit types and + # then not being able to destroy certain things they normally could, + # etc. Inheriting owner/source-node from things that set us off + # should be all we need I think... self.hit_type = 'explosion' self.hit_subtype = self.bomb_type # The node this came from. + # FIXME: can we unify this and source_player? self.owner = owner # Adding footing-materials to things can screw up jumping and flying @@ -1009,11 +1015,8 @@ class Bomb(ba.Actor): # Normal bombs are triggered by non-punch impacts; # impact-bombs by all impacts. - if not ispunched and (not self._exploded - or self.bomb_type in ['impact', 'land_mine']): - # We don't want to give the credit and points to player, - # who punched the bomb of other player in a chain reaction. - # And this will protect the bomb from getting hit_type 'punch'. + if (not self._exploded and + (not ispunched or self.bomb_type in ['impact', 'land_mine'])): # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the @@ -1025,13 +1028,15 @@ class Bomb(ba.Actor): # Also inherit the hit type (if a landmine sets off by a bomb, # the credit should go to the mine) # the exception is TNT. TNT always gets credit. - if self.bomb_type != 'tnt': - self.hit_type = msg.hit_type - self.hit_subtype = msg.hit_subtype + # UPDATE (July 2020): not doing this anymore. Causes too much + # weird logic such as bombs acting like punches. Holler if + # anything is noticeably broken due to this. + # if self.bomb_type != 'tnt': + # self.hit_type = msg.hit_type + # self.hit_subtype = msg.hit_subtype - ba.timer(100 + int(random.random() * 100), - ba.WeakCall(self.handlemessage, ExplodeMessage()), - timeformat=ba.TimeFormat.MILLISECONDS) + ba.timer(0.1 + random.random() * 0.1, + ba.WeakCall(self.handlemessage, ExplodeMessage())) assert self.node self.node.handlemessage('impulse', msg.pos[0], msg.pos[1], msg.pos[2], msg.velocity[0], msg.velocity[1],