hedgewars/GSHandlers.inc
changeset 3552 ca819f8bd704
parent 3519 56cbc035b74b
child 3560 3e51dad04026
equal deleted inserted replaced
3550:149416b948fc 3552:ca819f8bd704
  2373         Gear^.DirAngle := DxDy2Angle(tdx, tdy);
  2373         Gear^.DirAngle := DxDy2Angle(tdx, tdy);
  2374     end;
  2374     end;
  2375 
  2375 
  2376     dec(Gear^.Health);
  2376     dec(Gear^.Health);
  2377     Gear^.Timer := Gear^.Health*10;
  2377     Gear^.Timer := Gear^.Health*10;
       
  2378     Gear^.PortalCounter:= 0;
  2378     // This is not seconds, but at least it is *some* feedback
  2379     // This is not seconds, but at least it is *some* feedback
  2379     if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then
  2380     if (Gear^.Health = 0) or ((Gear^.Message and gm_Attack) <> 0) then
  2380     begin
  2381     begin
  2381         FollowGear := Gear;
  2382         FollowGear := Gear;
  2382         Gear^.RenderTimer := false;
  2383         Gear^.RenderTimer := false;
  3232         // won't port stuff that moves away from me!
  3233         // won't port stuff that moves away from me!
  3233 
  3234 
  3234         // wow! good candidate there, let's see if the distance really is small enough!
  3235         // wow! good candidate there, let's see if the distance really is small enough!
  3235         if (Distance(Gear^.X-iterator^.X,Gear^.Y-iterator^.Y) > acptRadius) then
  3236         if (Distance(Gear^.X-iterator^.X,Gear^.Y-iterator^.Y) > acptRadius) then
  3236             continue;
  3237             continue;
  3237 
  3238 (*
  3238         noTrap := ((not Gear^.dY.isNegative or (Gear^.dY.QWordValue = 0))
  3239         noTrap := ((not Gear^.dY.isNegative or (Gear^.dY.QWordValue = 0))
  3239                   // can't be entered from above
  3240                   // can't be entered from above
  3240                   or ((conPortal^.dY.isNegative and not (conPortal^.dY.QWordValue = 0))));
  3241                   or ((conPortal^.dY.isNegative and not (conPortal^.dY.QWordValue = 0))));
  3241         // can't be left downwards; 
  3242         // can't be left downwards; 
  3242 
  3243 
  3243         // prevent getting stuck in a ground portal loop       
  3244         // prevent getting stuck in a ground portal loop       
  3244         if noTrap and (iterator^.dY.QWordValue < _0_08.QWordValue) then
  3245         if noTrap and (iterator^.dY.QWordValue < _0_08.QWordValue) then
  3245             continue;
  3246             continue; *)
  3246 
  3247 
  3247         iterator^.Active := true;
  3248         iterator^.Active := true;
  3248         iterator^.State := iterator^.State or gstMoving;
  3249         iterator^.State := iterator^.State or gstMoving;
  3249         DeleteCI(iterator);
  3250         DeleteCI(iterator);
  3250 
  3251 
  3253 
  3254 
  3254         // TODO: more accurate porting
  3255         // TODO: more accurate porting
  3255         cdxy := Distance(conPortal^.dX, conPortal^.dY);
  3256         cdxy := Distance(conPortal^.dX, conPortal^.dY);
  3256         s := (Int2hwFloat(Gear^.Radius)) / cdxy;
  3257         s := (Int2hwFloat(Gear^.Radius)) / cdxy;
  3257 
  3258 
  3258         iterator^.X := conPortal^.X + s * conPortal^.dX;
  3259         if iterator^.Kind = gtCake then
  3259         iterator^.Y := conPortal^.Y + s * conPortal^.dY;
  3260             begin
  3260 
  3261             iterator^.X := conPortal^.X ;
  3261         s := Distance(iterator^.dX, iterator^.dY) / cdxy;
  3262             iterator^.Y := conPortal^.Y ;
  3262 
  3263             end
  3263         iterator^.dX := s * conPortal^.dX;
  3264         else
  3264         iterator^.dY := s * conPortal^.dY;
  3265             begin
       
  3266             iterator^.X := conPortal^.X + s * conPortal^.dX;
       
  3267             iterator^.Y := conPortal^.Y + s * conPortal^.dY;
       
  3268 
       
  3269             s := Distance(iterator^.dX, iterator^.dY) / cdxy;
       
  3270 
       
  3271             iterator^.dX := s * conPortal^.dX;
       
  3272             iterator^.dY := s * conPortal^.dY
       
  3273             end;
  3265 
  3274 
  3266         FollowGear := iterator;
  3275         FollowGear := iterator;
  3267 
  3276 
  3268         s := _0_2 + _0_008 * Gear^.Health;
  3277         s := _0_2 + _0_008 * Gear^.Health;
  3269         iterator^.dX := s * iterator^.dX;
  3278         iterator^.dX := s * iterator^.dX;