Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- validweapon [0] = 0
- validweapon [1] = 1
- validweapon [2] = 2
- validweapon [3] = 3
- validweapon [4] = 4
- validweapon [5] = 5
- validweapon [6] = 6
- validweapon [7] = 7
- validweapon [8] = 17
- validweapon [9] = 28
- validweapon [10] = 31
- globalvar check;
- scrMoveSolidOn()
- if weaponfind= 0 {
- i = 0
- target = 0
- if checkreload > 0 checkreload -= 1
- else {
- checkreload = 10
- global.check = 0
- while i < instance_number(objWeapon) and global.check = 0 {
- target = scrInstanceNearest(objWeapon, i)
- if instance_exists(target) {
- // Check if the image_index is within the valid range
- var isValidWeapon = false;
- var j;
- for (j = 0; j < array_length_1d(validweapon); j++) {
- if (validweapon[j] == target.image_index) {
- isValidWeapon = true;
- break;
- }
- }
- if (isValidWeapon) {
- if !scrCollisionLineExt(x,y,target.x,target.y,4,objSolid,objShootThrough,objDoorV) {
- global.check=1
- weaponfind=1
- }
- }
- }
- i += 1
- }
- }
- if weaponfind = 0 and instance_exists(objPlayer) {
- dist = point_distance(x,y,objPlayer.x,objPlayer.y)
- if dist < 64 {
- dir = point_direction(objPlayer.x,objPlayer.y,x,y)
- direction = dir - 180
- scrMoveSolidOn()
- if place_free(x+lengthdir_x(1,dir),y+lengthdir_y(1,dir)) {
- x+=lengthdir_x(1,dir)
- y+=lengthdir_y(1,dir)
- }
- scrMoveSolidOff()
- image_speed=0.1
- }
- }
- } else {
- if !instance_exists(target) {
- weaponfind = 0 speed = 0
- } else {
- speed=2
- direction = point_direction(x,y,target.x,target.y)
- image_speed = 0.2
- if place_meeting(x,y,target) {
- my_id = -123123
- if target.image_index = 0 {
- my_id = instance_create(x, y, objEnemy) my_id.sprite_index = sprEWalkM16
- }
- else if target.image_index=1 {
- my_id = instance_create(x, y, objEnemy) my_id.sprite_index = sprEWalkShotgun
- }
- else if target.image_index=2 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkClub
- }
- else if target.image_index=3 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkPipe
- }
- else if target.image_index=4 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkBat
- }
- else if target.image_index=5 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkKnife
- }
- else if target.image_index=6 {
- my_id = instance_create (x, y, objEnemy) my_id.sprite_index = sprEWalkDoubleBarrel
- }
- else if target.image_index=7 {
- my_id = instance_create (x, y, objEnemy) my_id.sprite_index = sprEWalkSilencer
- }
- else if target.image_index=17 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkCrowbar
- }
- else if target.image_index=28 {
- my_id = instance_create (x, y, objEnemyMelee) my_id.sprite_index = sprEWalkKatana
- }
- else if target.image_index=31 {
- my_id = instance_create (x, y, objEnemy) my_id.sprite_index = sprEWalkFAL
- } else exit
- if instance_exists(target) my_id.ammo=target.ammo
- audio_play_sound(sndPickupWeapon,0,false)
- with target instance_destroy()
- with my_id {
- if scrMovingPlayerExists() scrChasePlayer(path, objPlayer.x, objPlayer.y)
- }
- instance_destroy()
- }
- if !place_free(x+hspeed*3,y+vspeed*3) {
- if !place_free(x+hspeed*3,y) hspeed=-hspeed
- if !place_free(x,y+vspeed*3) vspeed=-vspeed
- weaponfind=0
- }
- }
- }
- //scrMoveSolidOff()
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement