maibe here is the problem, If I cancel this part where it detects collisions, I don't have the FPS drop
function update_muni_proyectil(count,force_n_id, debe_morir)
//force_n_id = force_getmyforce_n_ID(_muni[count].obj)
if _muni[count].tipo$ = "proyectil" or _muni[count].tipo$ = "proyectil aa"
//set_timer("proyectil A",0,3)
if _muni[count].activa = 0
if getdistance(cam_pivot,_muni[count].obj) < 100
_muni[count].activa = 1
endif
endif
//set_timer("proyectil A",1,3)
//set_timer("proyectil B",0,3)
x1# = getobjectx(_muni[count].obj)
y1# = getobjecty(_muni[count].obj)
z1# = getobjectz(_muni[count].obj)
force_apply(_muni[count].obj ,force_n_id)
//MoveObjectLocalZ(_muni[count].obj, 1)
//set_timer("proyectil B",1,3)
if _muni[count].vida > 1 and _muni[count].activa = 1 // <<<<<<<<<<<<< HERE START THE PROBLEM
// posicion nueva de la municion ¿choco algo?
//set_timer("proyectil C",0,3)
x2# = getobjectx(_muni[count].obj)
y2# = getobjecty(_muni[count].obj)
z2# = getobjectz(_muni[count].obj)
//set_timer("proyectil C",1,3)
//set_timer("proyectil D",0,3) //start timer
//Calcular si va a chocar contra algo
ObjectRayCast(0,x1#,y1#,z1#,x2#,y2#,z2#)
n=GetObjectRayCastNumHits()
// set_timer("proyectil D",1,3) // end timer
// set_timer("proyectil E",0,3)
for i = 0 to n-1
victima = getObjectRayCastHitID(i)
if victima <> 0
for s = _squad.length to 0 step -1
for airplane = 1 to 16
if victima = _squad[s].airplane_pivot[airplane]
obj = GetObjectRayCastHitID(i)
x#=GetObjectRayCastx(i)
y#=GetObjectRayCastY(i)
z#=GetObjectRayCastz(i)
crear_explo(0,"red",x#,y#,z#,8)
critical_hit = random(0,100)
if critical_hit > 30
crear_explo(0,"red",x#,y#,z#,random(10,20))
endif
endif
next airplane
next s
endif
//colision de municion con BARCOS
for barco_n =_barco.length to 0 step-1
if victima = _barco[barco_n].obj and _barco[barco_n].obj <> _muni[count].origen
obj = GetObjectRayCastHitID(i)
x#=GetObjectRayCastx(i)
y#=GetObjectRayCastY(i)
z#=GetObjectRayCastz(i)
nx#=GetObjectRayCastNormalX(i)
ny#=GetObjectRayCastNormalY(i)
nz#=GetObjectRayCastNormalZ(i)
tx#=GetScreenXFrom3D(x#,y#,z#)
ty#=GetScreenYFrom3D(x#,y#,z#)
crear_explo(0,"red",x#,y#,z#,2)
last_vida = _barco[barco_n].vida
_barco[barco_n].vida = _barco[barco_n].vida- random(1,10)*10
_muni[count].vida = 1000
critical_hit = random(0,100)
if critical_hit > 90
crear_splash(_muni[count].obj,random(20,60),"explo")
crear_explo(0,"red",x#,y#,z#,random(10,20))
endif
// points for hit
if _muni[count].flag = _barco[barco_n].flag
send_radio_msg(_barco[barco_n].tipo$ ,msg_origen_txt_by_id(_muni[count].origen),"CEASE FIRE!!!! you hit one of our ships!!!!",_muni[count].flag)
// friendli fire!!! NEGATIVE POINTS
// hit an friendly ship
points = -10
// kill an friendly ship!!
if _barco[barco_n].vida <= 0
points = -5000
send_radio_msg(_barco[barco_n].tipo$,msg_origen_txt_by_id(_muni[count].origen),"You have just sunk a ship of your own side!",_muni[count].flag)
endif
shooter = _muni[count].origen
add_points(shooter ,points)
else
// Hit points, you hit a enemy aircraft
points = 5
// kill an enemy ship!!
if _barco[barco_n].vida <= 0 and last_vida > 0
_human[player_human_id].ships_sink = _human[player_human_id].ships_sink + 1
save_humans()
points = 1000
send_radio_msg(msg_origen_txt_by_id(_muni[count].origen),"","Enemy "+ _barco[barco_n].tipo$ + " ship destroyed!!!",_muni[count].flag)
endif
shooter = _muni[count].origen
add_points(shooter ,points)
endif
endif
next barco_n
//colision de municion contra otros aviones
for avion_n = _avion.length to 0 step-1
if victima = _avion[avion_n].lowpoly and _avion[avion_n].obj <> _muni[count].origen
obj = GetObjectRayCastHitID(i)
//if _avion[avion_n].control$ = "player" or _muni[count].origen = player_avion_obj_id
check_3d_damage(avion_n, -1, count)
//endif
x#=GetObjectRayCastx(i)
y#=GetObjectRayCastY(i)
z#=GetObjectRayCastz(i)
crear_explo(0,"red",x#,y#,z#,5)
last_vida = _avion[avion_n].vida
_avion[avion_n].vida = _avion[avion_n].vida - random(1,10)*30
_muni[count].vida = 1000
//points for hit
if _muni[count].flag = _avion[avion_n].flag
send_radio_msg(msg_origen_txt_by_id(_avion[avion_n].obj) ,msg_origen_txt_by_id(_muni[count].origen),"CEASE FIRE!!!! you hit a friendly aircraft!!!!",_avion[n].flag)
// friendli fire!!! NEGATIVE POINTS
points = -10
if _avion[avion_n].vida <= 0
points = -1000
endif
shooter = _muni[count].origen
add_points(shooter ,points)
else
// Hit points, you hit a enemy aircraft
points = 5
if _avion[avion_n].vida <= 0 and last_vida > 0
points = 500
_human[player_human_id].airplanes_down = _human[player_human_id].airplanes_down + 1
send_radio_msg(msg_origen_txt_by_id(_muni[count].origen),"","Enemy " + _avion[avion_n].tipo$ + " aircraft destroy! ",_muni[count].flag)
endif
shooter = _muni[count].origen
add_points(shooter ,points)
endif
endif
next
// here i SUM THE NEW POINTS FOR HITING!
origen_points = origen_points + points
next
//set_timer("proyectil E",1,3)
endif
//set_timer("proyectil F",0,3)
MoveObjectLocalZ(_muni[count].obj,-2) // ??? y esto??
_muni[count].vida = _muni[count].vida + 1
//set_timer("proyectil F",0,3)
endif
endfunction debe_morir