M
MegaJim73
Guest
I'm trying to implement a hitscan system in an FPS I'm making. It creates the appropriate impact when the gun hits an enemy (obj_enemy_basic) or wall (obj_wall_basic), but simply passes through when it hits a destructible pillar (obj_pillar). Help would be gladly appreciated.
Code:
{
// check whether you can shoot
if (not can_shoot) exit;
can_shoot = false;
// show the animation and play the sound
image_speed = 0.5;
image_index = 0;
sound_play(snd_pstl);
global.ammo-=1;
var xx, yy, ii;
xx = global.camx;
yy = global.camy;
repeat (256)
{
xx += 4*global.camcos;
yy -= 4*global.camsin;
with (obj_monster_basic)
if ((id != other.id) && collision_circle(global.camx,global.camy,128,id,1,0))
{
with (id) alert=1;
}
ii = collision_line(global.camx,global.camy,xx,yy,obj_wall_basic,1,0);
if (ii == noone)
{
ii = instance_position(xx,yy,obj_monster_basic);
if (ii == noone) continue;
with (ii)
{
mhealth-=1;
hurt=1;
t=instance_create(xx,yy,blood_type);
t.z1=ii.z1*0.75;
}
break;
ii = instance_position(xx,yy,obj_pillar1);
if (ii == noone) continue;
with (ii)
{
if (indestructible==0)
{
mhealth-=1;
t=instance_create(xx,yy,blood_type);
t.z1=ii.z1*0.75;
};
else
t=instance_create(xx,yy,blood_type);
t.z1=ii.z1*0.75;
}
break;
}
else
{
ii = instance_position(xx,yy,obj_wall_basic);
if (ii == noone) continue;
with (ii)
{
t=instance_create(xx,yy,obj_ricochet);
t.direction=obj_player.direction;
}
break;
}
}
}