Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ///Code for adding gun reloads to Hotline Miami 1 source. GMS1 (and posssibly GMS2???) compatible.
- ///DISCLAIMER: I FUCKED UP AND THUS SOME PARTS OF THIS PASTE WILL BE CHANGED FROM HOW THEY ARE PRESENTED IN THE VIDEO. CHECK PINNED COMMENT FOR MORE INFO.
- //First, add these two global variables to the create event of objTitle.
- //Global ammo variables.
- global.mags = 0
- global.shells = 0
- //Next add the following local and global variables to the create event of objPlayerMouse.
- mags = global.mags
- shells = global.shells
- global.reloadspeed = yourspeedhere
- //Then, add a destroy event to objPlayerMouse and set these variables within the destroy event.
- global.mags = mags
- global.shells = shells
- //Next add these script calls to their respective places
- scrReload() - Step event of objPlayerMouse
- scrReloadManually() - Press R Key event of objPlayerMouse
- scrReloadManuallyShotguns() - Press R Key event of objPlayerMouse
- scrIsReloading(sprite_index) - scrPlayerPickup2 and scrPlayerPickup1
- //Now we can add tracking for shells and mags to the player's HUD. Keep in mind that this is not a tutorial covering UI.
- //Add this code to around line 87 in scrScoreDrawStory. (Given that you haven't already edited it in any way)
- if objPlayer.shells > 0 ammostring = string(objPlayer.ammo) + "/" + string(maxammo) + "rnds" + " |" + string(objPlayer.shells) + " reserve"
- else if objPlayer.mags > 0 ammostring = string(objPlayer.ammo) + "/" + string(maxammo) + "rnds" + " |" + string(objPlayer.mags) + " reserve"
- //scrIsReloading
- if argument0 = sprPReloadDoubleBarrel
- or argument0 = sprPReloadSilencer
- or argument0 = sprPReloadShotgun
- or argmuent0 = sprPCockShotgun
- return true
- //scrReloadManually
- if sprite_index = sprPWalkSilencer {
- if ammo < 13 and mags > 0 {
- sprite_index = sprPReloadSilencer
- image_index = 0
- image_speed = 0
- }
- }else exit
- //scrReloadManuallyShotguns
- if sprite_index = sprPWalkDoubleBarrel {
- if ammo < 2 and shells > 0 {
- sprite_index = sprPReloadDoubleBarrel
- image_index = 0
- image_speed = 0
- }
- }
- if sprite_index = sprPWalkShotgun {
- if ammo < 6 and shells > 0 {
- sprite_index = sprPReloadShotgun
- image_index = 0
- image_speed = 0
- }
- }
- else exit
- //scrReload
- //Check if the player is currently reloading and whether or not they have the reserve ammo to reload.
- if scrIsReloading(sprite_index) and shells > 0 or scrIsReloading(sprite_index) and mags > 0 {
- //Double Barrel Reload
- if ammo < 2 and shells > 0 {
- if sprite_index = sprPReloadDoubleBarrel {
- if image_index < sprite_get_number(sprite_index) - 1 {
- image_index += global.reloadspeed * 1.5
- if image_index >= 3 and image_index - global.reloadspeed < 3 {
- repeat (2) {
- my_id = instance_create(x + lengthdir_x(5, dir - 5 * left), y + lengthdir_y(5, dir - 5 * left), objShell)
- my_id.sprite_index = sprShotgunShell
- my_id.image_angle = dir
- my_id.direction = dir - 90 * left - 20 + random(30)
- my_id.speed = 1 + random(2)
- }
- }
- if image_index >= 11 and image_index - global.reloadspeed * 1.5 < 11 audio_play_sound(sndInsertShell, 0, false)
- if image_index >= 16 and image_index - global.reloadspeed * 1.5 < 16 audio_play_sound(sndInsertShell, 0, false)
- } else {
- ammo = 2; //Refill the ammo.
- shells -= 2; //Decrement the number of shells.
- if shells <= 0 shells = 0; //Ensure shells don't go below zero.
- if sprite_index = sprPReloadDoubleBarrel sprite_index = sprPWalkDoubleBarrel;
- }
- }
- }
- //Silencer Reload
- if ammo < 13 and mags > 0 {
- if sprite_index = sprPReloadSilencer {
- if image_index < sprite_get_number(sprite_index) - 1 {
- image_index += global.reloadspeed
- if image_index >= 5 and image_index - global.reloadspeed < 5 {
- audio_play_sound(sndEjectClipHandgun, 0, false)
- my_id = instance_create(x + lengthdir_x(5, dir - 5 * left), y + lengthdir_y(5, dir - 5 * left), objGunClip)
- my_id.image_index = 3
- my_id.image_angle = dir
- my_id.direction = dir - 90 * left - 20 + random(30)
- my_id.speed = 1 + random(2)
- }
- if image_index >= 10 and image_index - global.reloadspeed < 10 audio_play_sound(sndInsertClipHandgun, 0, false)
- } else {
- ammo = 13
- mags -= 1
- if sprite_index = sprPReloadSilencer sprite_index = sprPWalkSilencer
- audio_play_sound(sndSlideHandgun, 0, false)
- }
- }
- }
- //Shotgun Reload
- if sprite_index = sprPReloadShotgun {
- if ammo < 6 and shells > 0 {
- if image_index * 10 = 47.5 audio_play_sound(sndInsertShell, 0, false)
- if image_index < 9 image_index += global.reloadspeed else {
- ammo += 1
- shells -= 1
- image_index = 5
- audio_play_sound(sndInsertShell, 0, false)
- if shells = 0 { sprite_index = sprPCockShotgun image_speed = 0.25 audio_play_sound(sndCockShotgun, 0, false) exit }
- }
- } else {
- if image_index < sprite_get_number(sprite_index) - 1 image_index += global.reloadspeed
- else {
- audio_play_sound(sndCockShotgun, 0, false)
- sprite_index = sprPCockShotgun
- image_speed = 0.25
- }
- }
- }
- }
- ///objGunClip
- //Create
- image_speed=0
- dir=0
- ammo=0
- friction=0.1
- //Step
- if speed>0 image_angle+=sign(vspeed)*speed*3
- //Collisions
- move_bounce_all(0)
- speed*=0.2
- //Draw
- draw_sprite_ext(sprite_index,image_index,x,y,image_xscale,image_yscale,image_angle,image_blend,image_alpha)
Add Comment
Please, Sign In to add comment