Shooter (4.5.9.) How to make a projectile that destroys multiple enemies.

kevintron

Active member
Now that that Byte off 4 has finished I wanted to work on the things that didn't make the cut. I had an idea for my secondary player weapon. I wanted a "super projectile". This would be a ammo based projectile that once it destroys one enemy it keeps going until off screen continuing to destroy along they way. I'm lost as to what needs to be changed to make this happen. The way I understand it(which is probably off) the object is automatically destroyed when a monster is. Is the monster gonna need to spawn and relaunch the projectile after its destroyed? Or does somewhere the game object code itself just need to say nothing can destroy it but the screen edge?
 
Oh, i have a projectile that can destroy multiple monsters.
If you have a separate gameobject for your stronger projectile, you can do it like this:
i changed a part in the ProjectSettings - SubRoutines in the script Handle Object Collissions

Look for this part of the script:
You can add the piece of code between
"LDX selfobject" and "DestroyObject"

My stronger gameobject projectile is gameObject #12, you can change that number in the code below.

Code:
    BEQ +skipCollision
                            
            TXA
            STA otherObject
            ;; There was a collision between a monster and a weapon.
            ;; weapon is self.
            ;; monster is other.
                ;;;;DestroyObject
                ;ChangeActionStep otherObject, #$07
                JSR doHandleHurtMonster                ;;;;here the monster gets destroyed, in diffrent ways depending  on 
                                                                           ;;;if your game has monsters with health or monster-death-animations..
                                
                                                            
                    LDX selfObject
                    ;;;;;;;;;;;;;;;;;;Added code so that this playerprojectile continues through multiple monsters                           
                    LDA Object_type,x
                    CMP #12  ;;;<!!--Here you set the number of your stronger projectile gameobject.
                    BNE +notStrongProj
                        JMP +done ;;;if it is, skip destroying the projectile, and jmp to end of script
                    +notStrongProj:
                    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
                    DestroyObject
                            
                    JMP +done               
        +skipCollision

When this script runs, and the projectile collides with the monster. the monster gets destroyed and IF it is the strong projectile, it just continues through the monster.

If you have monsters with different health, this projectile will kill them in one shot! Because the projectile doesent get destroyed and continues hurting the monster for every frame that it passes through it.
 
Top Bottom