SOLVED Revert Back to Normal Projectile after using Power Up Ammo

I been needing help on this for about 2 days now, but when the ammo count goes to zero for certain power ups, I want the player to go back to his normal shooting. What happens is after the count does down to zero, he is still firing the power up projectiles.

Machine Gun Script

GML:
///Machine Gun Ammo Script

function scr_machinegunammo(){
    if machinegun_ammo > 1
    {
        machinegun_ammo -= 1
    }
else
{
    machinegun_ammo = 0
    scr_normalshoot()
}
}
Normal Shoot Script

Code:
// / @desc Normal Shooting

function scr_normalshoot(){
    if gamepad_button_check(0,gp_face3) && canShoot
{
canShoot = false
alarm[0] = shoot_delay
var dir = 0;
if gamepad_axis_value(0,gp_axislh) = 0
&& gamepad_axis_value(0,gp_axislv) = 0
{
if image_xscale < 0 //if facing left
{dir = 180}
//an else isn't needed cus the dir is already 0
}
else
{dir = point_direction(0, 0, gamepad_axis_value(0,gp_axislh), gamepad_axis_value(0,gp_axislv))}
with (instance_create_layer(x,y,"BULLETS",obj_projectile))
{
direction = dir;
speed = 20;
}
}

}
 

Nidoking

Member
You're showing what happens when you call the normalshoot function and the machinegun function. The problem is that you're not using the ammo count to decide which function to call, and you don't appear to be setting anything when you run out of machinegun ammo to tell the game to switch weapons. Your logic needs to be "when the machinegun runs out of ammo, switch to the normal gun". The code for shooting the machinegun isn't even here, so nothing you've posted is going to affect whether that happens or not. This logic is "Fire a machinegun bullet, and if the ammo has run out, additionally fire a normal bullet." You should write what you want to do in plain language and then try to write code that does things that way. You don't seem to have a very solid grasp of what your game is doing, so you won't be able to change it easily.
 
Top