Code:
procedure projectile_update_new()
atom dist,period,theta
atom amplitude,frequency
sequence list,object_list
integer bullet_id,ctype
atom x,y,start_time,angle,elapsed_time,vec,modvec,d
integer lifetime,speed
--collision
integer object_type
sequence stats
integer found_solid
for i=1 to length(client_list) do
list=projectile_get_list(client_list[i][client_projectile])
object_list=object_get_list( client_list[i][client_objectlist] )
for j=1 to length(list) do
if length(list[j]) then
x=list[j][projectile_x]
y=list[j][projectile_y]
angle=list[j][projectile_angle]
start_time=list[j][projectile_start_time]
bullet_id=list[j][projectile_bullet_id]
ctype=list[j][projectile_type]
lifetime=real(object_delta(ctype, object_lifetime))
speed=real(object_delta(ctype, object_speed))
elapsed_time=current_time()-start_time
if elapsed_time>=lifetime then
projectile_free(client_list[i][client_projectile],j)
else
dist = (elapsed_time / 1000.0) * (speed / 10.0)
if is_even(bullet_id) then
period=0
else
period=PI
end if
if sequence(object_delta(ctype,object_wavy)) then
theta = angle + (PI * 64) * sin(period + 6 * PI * (elapsed_time / 1000))
x += dist * cos(theta)
y += dist * sin(theta)
else
x += dist * cos(angle)
y += dist * sin(angle)
if sequence(object_delta(ctype,object_amplitude)) then
--puts(1,"amplitude\n")
amplitude=real(object_delta(ctype,object_amplitude))
frequency=real(object_delta(ctype,object_frequency))
d = amplitude * sin(period + elapsed_time / lifetime * frequency * 2 * PI)
x += d * cos(angle + PI / 2)
y += d * sin(angle + PI / 2)
end if
end if
found_solid=0
for k=1 to length(object_list) do
if length(object_list[k]) then
object_type=object_get_type(client_list[i][client_objectlist],k)
if sequence(object_delta(object_type,object_OccupySquare)) then
if point_distance(x,y,object_get_x(client_list[i][client_objectlist],k),object_get_y(client_list[i][client_objectlist],k))<1 then
projectile_free(client_list[i][client_projectile],j)
found_solid=1
exit
end if
end if
end if
end for
if found_solid=0 then
for k=1 to length(object_list) do
if length(object_list[k]) then
object_type=object_get_type(client_list[i][client_objectlist],k)
if sequence(object_delta(object_type,object_enemy)) then
if point_distance(x,y,object_get_x(client_list[i][client_objectlist],k),object_get_y(client_list[i][client_objectlist],k))<0.5 then
stats=object_get_stats(client_list[i][client_objectlist],k)
if real(object_delta(ctype,object_mindamage))>stats[stat_health][2] then
enemyhit_packet_write( i, bullet_id, object_get_id(client_list[i][client_objectlist],k),1)
else
enemyhit_packet_write( i, bullet_id, object_get_id(client_list[i][client_objectlist],k),0)
end if
projectile_free(client_list[i][client_projectile],j)
exit
end if
end if
end if
end for
end if
end if
end if
end for
end for
end procedure