R
Red Phantom
Guest
So the gun successfully reloads 95% of the time, but on the rare occasion it does not re-load and the character cannot shoot to kill the enemies meaning he dies to the enemies and the game restarts.
The timeline used to re-load the gun!
The enemy(obj_soldier) also shoots and uses tml_Re_Load!
Code:
Keyboard Event for Z-key Key(i.e. when the main character presses z, shoot!):
execute code:
///SHOOT
if global.inconversation = true or instance_exists(obj_Red_Building_Locked_Text_Orphan) exit;
if loaded = true and sprite_index != spr_Meskhenet_Walking and vsp = 0
{
separate_bullets = instance_create(x + 10,y + 18,obj_Bullet); //relative origin of bullets has been tested and is correct.
if image_xscale = 1
{
separate_bullets.hspeed = 10
sprite_index = spr_Meskhenet_Walking_with_Pistol_Shot_Flipped
pistol_recoil_count = 1
}
if image_xscale = -1
{
separate_bullets.hspeed = -10
separate_bullets.x -= 25 //when Meskhenet faces other direction bullets x_origin must be adusted appropriately
sprite_index = spr_Meskhenet_Walking_with_Pistol_Shot
pistol_recoil_count = 1
}
loaded = false
script_execute(scr_Set_Time_Line,tml_Re_Load,false)
}
if loaded = true and sprite_index != spr_Meskhenet_Jumping and vsp !=0
{
separate_bullets = instance_create(x + 10,y + 18,obj_Bullet_Jumped); //relative origin of bullets has been tested and is correct.
if image_xscale = 1
{
separate_bullets.hspeed = 7.07
separate_bullets.vspeed = 7.07
sprite_index = spr_Meskhenet_Jumping_with_Pistol_Shot_Flipped
pistol_recoil_count = 1
}
if image_xscale = -1
{
separate_bullets.hspeed = -7.07
separate_bullets.vspeed = 7.07
sprite_index = spr_Meskhenet_Jumping_with_Pistol_Shot
separate_bullets.image_xscale = -1
separate_bullets.x -= 20 //when Meskhenet faces other direction bullets x_origin must be adusted appropriately
pistol_recoil_count = 1
}
loaded = false
script_execute(scr_Set_Time_Line,tml_Re_Load,false)
}
Code:
Information about time line: tml_Re_Load
Step 15:
execute code:
loaded = true
Code:
Step Event:
execute code:
///SHOOT
if obj_Meskhenet.meskhenet_health = 0 then exit
if global.inconversation = true then exit
//The next two lines fix Bug 39
if instance_number(obj_Exit_Game) = 1 then exit
if instance_number(obj_Red_Building_Locked_Text_Orphan) = 1 then exit
if obj_Meskhenet.vsp != 0 then exit
if loaded = true
{
if obj_Meskhenet.x > x + 20 //If Meskhenet is right of soldier (was 38)
{
instance_create(x + 26,y + 22,obj_Enemy_Bullet); //Shoot Right
(obj_Enemy_Bullet).hspeed = 10;
pistol_recoil_count = 1
}
if obj_Meskhenet.x < x + 1 //If Meskhenet is left of soldier
{
instance_create(x - 3,y + 21,obj_Enemy_Bullet); //Shoot Left
(obj_Enemy_Bullet).hspeed = -10;
pistol_recoil_count = 1
}
loaded = false
script_execute(scr_Set_Time_Line,tml_Re_Load,false)
}
//Pistol Recoil Count
if pistol_recoil_count > 0 then pistol_recoil_count += 1
finished_recoil_timer = 6
if pistol_recoil_count = finished_recoil_timer
{
sprite_index = spr_Soldier_Walking_Pointing_Gun
}