[SOLVED] Projectile on Maze module help 4.5.6.

5kids2feed

Well-known member
So.. I've had many errors while messing around with everything on this module.. I've tried to refrain from asking too many questions and figure out basic things on my own. I was able to fix my hud with the missing variable errors I was getting and a couple other things. All because I was adding my own pixels and such.

But..

This seems like such a simple thing and I can't understand why it's happening.. I shoot my projectile at my monster and it doesn't even register and flies right through him. I have it set as a player weapon. I have doHurtMonster inserted in the game... bounding boxes are setup on both the monster and the projectile... "monster" is checked off on the monster attributes.. I was following along on a tutorial.. They don't register each other though. The projectile will destroy itself on solid objects and the edge of the screen.. but not the monster. I've tried setting the monster health at 1 and 0 to see if that was it.. but my brain is about to explode trying to figure out this simple thing. Any help would be greatly appreciated. Thanks!
 
Last edited:

dale_coop

Moderator
Staff member
The reason is that in the Maze module, the player projectile is not implemented (collision detection between a player weapon object and monsters).
Here's how you could add the code to destroy monsters with your projectiles:
Modify the script assigned to the "Handle Object Collisions" in your "Project Settings > Scripts Settings" (under Subroutines), and line 55, just after the comments line :
Code:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Add all that code for adding the player weapon object support :
Code:
        LDA Object_flags,x
        AND #%00000100
        BNE +isWeapon
            JMP +notPlayerWeapon
        +isWeapon:
                LDX #$00
                loop_objectCollision:
                    CPX selfObject
                        BNE +notSelfObject
                            JMP +skipCollision
                        +notSelfObject
                LDA Object_status,x
                AND #%10000000
                BNE +isActive
                    JMP +skipCollision
                +isActive:
                LDA Object_flags,x
                AND #%00001000
                BNE isMonsterWeaponCol
                    JMP +notAmonsterWeaponCollision
                isMonsterWeaponCol:
                    JSR getOtherColBox
                    JSR doCompareBoundingBoxes
                        ;;; if they have collided, it is a 1
                        ;;; if not, it is a zero.
                        BEQ +skipCollision
                            TXA
                            STA otherObject
                            ;; There was a collision between a monster and a weapon.
                            ;; weapon is self.
                            ;; monster is other.
                           
                            ;; HERE, what do do when the player weapon is colliding against a monster :
                            ; JSR doHandleHurtMonster
                            DestroyObject
                            AddValue #$06, myScore, #$05, #$02
                            UpdateHudElement #$03

                            JMP +done              
                    +skipCollision
                +notAmonsterWeaponCollision
                INX
                CPX #TOTAL_MAX_OBJECTS
                BEQ +lastCollisionForThisObject
                    JMP loop_objectCollision
            +lastCollisionForThisObject
            JMP +done
            +notPlayerWeapon:
 

5kids2feed

Well-known member
Omg.. Dale... I love you.. It works! That makes so much sense. Didn't think how projectiles were setup in the Maze Module.

Only one issue.. the projectile doesn't destroy itself when it hits the monster. The monster dies but not my weapon. I have it set to destroy when it hits a solid object or the edge.. could there possibly be a little line of code i'm missing for that?

Seriously, thank you so much for your help.
 

dale_coop

Moderator
Staff member
No problem, to destroy the player weapon...
Modify the script... around line 95, just before the line:
Code:
                            JMP +done
Add those lines:
Code:
                            ;; now we can destoy the player weapon
                            LDX selfObject
                            DestroyObject
                            LDX otherObject
 

5kids2feed

Well-known member
That was it! I would've never figured that one out on my own since my coding skills are non existent. You're the man. Thank you as always.
 

5kids2feed

Well-known member
Dale... I have another issue if you're still around lol. What's an easy way to fix this? My game is so small. Like 7 spaces on the overworld along with the bottom row for start, win, and end screens. Do I have too much unnecessary code because I was adding things to the maze module? Somehow i'm at 247 bites :/

Untitled.jpg
 

5kids2feed

Well-known member
WAIT. Jumped the gun again. Sorry, Dale. It's because I made one of my game object files too big by accident. Carry on :)
 

5kids2feed

Well-known member
Hey @dale_coop buddy ol' pal!.. say I wanted to add in the collisions for a monster weapon to hurt a player.. what would I script in it? Trying to change the code myself but messing it up lol.
 

dale_coop

Moderator
Staff member
To implement monster weapon (if not yet in your module):
 

5kids2feed

Well-known member
All hail King Dale!

Works! ..but one problem.. it hurts the player as soon as the monster starts to shoot projectile instead of when it touches him. hmmmm.

EDIT: Nevermind! was placing it on the top of the script instead of the bottom hahha. oh boy. Got it! You the man!
 
Last edited:
Top Bottom