A
Ash Ketchum
Guest
If i have too many of the turrets with this code in, i get serious lag.
But i want to have lots of turrets.
Step
Any thoughts on making it faster?
But i want to have lots of turrets.
Step
Code:
direction = image_angle
/////
if rounds < 1
{
reloading = 1
}
if reloading = 1
{
reloading_time += reload_speed/50;
if reloading_time > 100
{
rounds = clip_size;
reloading = 0
reloading_time = 0
}
}
///////////////
if (!collision_line(x,y,target.x,target.y,obj_solid,0,0))and distance_to_object(target) < view and ammunition > 0
{
if fuel > 0 and ammunition > 0
{ if system = 1 or 2
dir = point_direction(x,y,target.x,target.y)
image_angle += median(-pivot/350, pivot/350, ((((dir - image_angle) mod 360) + 540) mod 360) - 180);
}
/////
if system = 1 or 2
{
playerDir = point_direction(x,y,target.x,target.y)
}
else
{
playerDir = point_direction(x,y,mytarget.x,mytarget.y)
}
if (playerDir>direction-FOV && playerDir<direction+FOV)^^(playerDir+360>direction-FOV && playerDir+360<direction+FOV)
^^(playerDir-360>direction-FOV && playerDir-360<direction+FOV)
{
if rounds > 0 and reloading = 0 and ammunition > 0
{
time+=ROF
if time >1000
{
barrel.sprite_index = BarrelS_spr image_speed = 0.01
time = 0
var length,;
length = barrel_length
//////////////ONE
for (i = 0; i < gauge; i += 1)
{
lead = instance_create(x+lengthdir_x(length,direction),y+lengthdir_y(length,direction),ammo)
lead.direction = direction+ random(spread)-spread/2;
lead.image_angle = direction
lead.damage = damage
lead.speed = bulletspeed
lead.friendly = 1
lead.parent = id
rounds -=1
ammunition -=1
}
}}}}
else
{
if time > 0
{
time -= ROF/4
}
if fuel > 0
{
dir = point_direction(x,y,mytarget.x,mytarget.y)
image_angle += median(-pivot/350, pivot/350, ((((dir - image_angle) mod 360) + 540) mod 360) - 180);
}
}
if direction <> point_direction(x,y,mytarget.x,mytarget.y)
{
fuel-=fuel_consumption/500
}