hedgewars/uGearsHandlersMess.pas
changeset 12646 f30b70976577
parent 12626 d972b31f8881
child 12649 59b46e6f36ff
equal deleted inserted replaced
12645:36a650c0a885 12646:f30b70976577
  3292     dec(Gear^.Health);
  3292     dec(Gear^.Health);
  3293     Gear^.Timer := Gear^.Health*10;
  3293     Gear^.Timer := Gear^.Health*10;
  3294     if Gear^.Health mod 100 = 0 then
  3294     if Gear^.Health mod 100 = 0 then
  3295         Gear^.PortalCounter:= 0;
  3295         Gear^.PortalCounter:= 0;
  3296     // This is not seconds, but at least it is *some* feedback
  3296     // This is not seconds, but at least it is *some* feedback
  3297     if (Gear^.Health = 0) or ((Gear^.Message and gmAttack) <> 0) then
  3297     if (Gear^.Health <= 0) or ((Gear^.Message and gmAttack) <> 0) then
  3298         begin
  3298         begin
  3299         FollowGear := Gear;
  3299         FollowGear := Gear;
  3300         Gear^.RenderTimer := false;
  3300         Gear^.RenderTimer := false;
  3301         Gear^.doStep := @doStepCakeDown;
  3301         Gear^.doStep := @doStepCakeDown;
  3302         exit
  3302         exit
  3327     cakeData: PCakeData;
  3327     cakeData: PCakeData;
  3328 begin
  3328 begin
  3329     AllInactive := false;
  3329     AllInactive := false;
  3330 
  3330 
  3331     inc(Gear^.Tag);
  3331     inc(Gear^.Tag);
  3332     if Gear^.Tag < 100 then
  3332     // Animation delay. Skipped if cake only dropped a very short distance.
       
  3333     if (Gear^.Tag < 100) and (Gear^.FlightTime > 1) then
  3333         exit;
  3334         exit;
  3334     Gear^.Tag := 0;
  3335     Gear^.Tag := 0;
  3335 
  3336 
  3336     if Gear^.Pos = 6 then
  3337     if (Gear^.Pos = 6) or (Gear^.FlightTime <= 1) then
  3337         begin
  3338         begin
       
  3339         Gear^.Pos := 6;
  3338         cakeData:= PCakeData(Gear^.Data);
  3340         cakeData:= PCakeData(Gear^.Data);
  3339         with cakeData^ do
  3341         with cakeData^ do
  3340             begin
  3342             begin
  3341             for i:= 0 to Pred(cakeh) do
  3343             for i:= 0 to Pred(cakeh) do
  3342                 begin
  3344                 begin
  3343                 CakePoints[i].x := Gear^.X;
  3345                 CakePoints[i].x := Gear^.X;
  3344                 CakePoints[i].y := Gear^.Y
  3346                 CakePoints[i].y := Gear^.Y
  3345                 end;
  3347                 end;
  3346             CakeI := 0;
  3348             CakeI := 0;
  3347             end;
  3349             end;
       
  3350         (* This is called frequently if the cake is completely stuck.
       
  3351            With this a stuck cake takes equally long to explode then
       
  3352            a normal cake. Removing this code just makes the cake walking
       
  3353            for a few seconds longer. *)
       
  3354         if (Gear^.FlightTime <= 1) and (Gear^.Health > 2) then
       
  3355             dec(Gear^.Health);
       
  3356         Gear^.FlightTime := 0;
  3348         Gear^.doStep := @doStepCakeWalk
  3357         Gear^.doStep := @doStepCakeWalk
  3349         end
  3358         end
  3350     else
  3359     else
  3351         inc(Gear^.Pos)
  3360         inc(Gear^.Pos)
  3352 end;
  3361 end;
  3354 procedure doStepCakeFall(Gear: PGear);
  3363 procedure doStepCakeFall(Gear: PGear);
  3355 begin
  3364 begin
  3356     AllInactive := false;
  3365     AllInactive := false;
  3357 
  3366 
  3358     Gear^.dY := Gear^.dY + cGravity;
  3367     Gear^.dY := Gear^.dY + cGravity;
       
  3368     // FlightTime remembers the drop time
       
  3369     inc(Gear^.FlightTime);
  3359     if TestCollisionYwithGear(Gear, 1) <> 0 then
  3370     if TestCollisionYwithGear(Gear, 1) <> 0 then
  3360         Gear^.doStep := @doStepCakeUp
  3371         Gear^.doStep := @doStepCakeUp
  3361     else
  3372     else
  3362         begin
  3373         begin
  3363         Gear^.Y := Gear^.Y + Gear^.dY;
  3374         Gear^.Y := Gear^.Y + Gear^.dY;