hedgewars/uGearsHandlersMess.pas
branchios-revival
changeset 11312 966ae86aac75
parent 11304 a20f416c91ec
child 11337 aa3f886c6298
equal deleted inserted replaced
11311:ef2592892432 11312:966ae86aac75
  1092 procedure doStepBee(Gear: PGear);
  1092 procedure doStepBee(Gear: PGear);
  1093 begin
  1093 begin
  1094     AllInactive := false;
  1094     AllInactive := false;
  1095     Gear^.X := Gear^.X + Gear^.dX;
  1095     Gear^.X := Gear^.X + Gear^.dX;
  1096     Gear^.Y := Gear^.Y + Gear^.dY;
  1096     Gear^.Y := Gear^.Y + Gear^.dY;
       
  1097     WorldWrap(Gear);
  1097     Gear^.dY := Gear^.dY + cGravity;
  1098     Gear^.dY := Gear^.dY + cGravity;
  1098     CheckGearDrowning(Gear);
  1099     CheckGearDrowning(Gear);
  1099     CheckCollision(Gear);
  1100     CheckCollision(Gear);
  1100     if (Gear^.State and gstCollision) <> 0 then
  1101     if (Gear^.State and gstCollision) <> 0 then
  1101         begin
  1102         begin
  1957     // TODO: do real calculation?
  1958     // TODO: do real calculation?
  1958     land:= TestCollisionXwithGear(Gear, 2);
  1959     land:= TestCollisionXwithGear(Gear, 2);
  1959     if land = 0 then land:= TestCollisionYwithGear(Gear,-2);
  1960     if land = 0 then land:= TestCollisionYwithGear(Gear,-2);
  1960     if land = 0 then land:= TestCollisionXwithGear(Gear,-2);
  1961     if land = 0 then land:= TestCollisionXwithGear(Gear,-2);
  1961     if land = 0 then land:= TestCollisionYwithGear(Gear, 2);
  1962     if land = 0 then land:= TestCollisionYwithGear(Gear, 2);
  1962     if (land <> 0) and (land and lfBouncy = 0) then
  1963     if (land <> 0) and ((land and lfBouncy = 0) or ((Gear^.State and gstMoving) = 0)) then
  1963         begin
  1964         begin
  1964         if ((Gear^.State and gstMoving) <> 0) or (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
  1965         if ((Gear^.State and gstMoving) <> 0) or (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
  1965             begin
  1966             begin
  1966             PlaySound(sndRopeAttach);
  1967             PlaySound(sndRopeAttach);
  1967             Gear^.dX:= _0;
  1968             Gear^.dX:= _0;
  2673                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  2674                 2: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtNapalmBomb, 0, cBombsSpeed * Gear^.Tag, _0, 0);
  2674                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  2675                 3: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtDrill, gsttmpFlag, cBombsSpeed * Gear^.Tag, _0, Gear^.Timer + 1);
  2675             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  2676             //4: FollowGear := AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtWaterMelon, 0, cBombsSpeed *
  2676             //                 Gear^.Tag, _0, 5000);
  2677             //                 Gear^.Tag, _0, 5000);
  2677             end;
  2678             end;
  2678         Gear^.dX := Gear^.dX + int2hwFloat(30 * Gear^.Tag);
  2679         Gear^.dX := Gear^.dX + int2hwFloat(Gear^.Damage * Gear^.Tag);
  2679         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  2680         if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
  2680             FollowGear^.State:= FollowGear^.State or gstSubmersible;
  2681             FollowGear^.State:= FollowGear^.State or gstSubmersible;
  2681         StopSoundChan(Gear^.SoundChannel, 4000);
  2682         StopSoundChan(Gear^.SoundChannel, 4000);
  2682         end;
  2683         end;
  2683 
  2684 
  2706         Gear^.Tag := -1;
  2707         Gear^.Tag := -1;
  2707         Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
  2708         Gear^.X := int2hwFloat(max(LAND_WIDTH,4096) + 2048);
  2708         end;
  2709         end;
  2709 
  2710 
  2710     Gear^.Y := int2hwFloat(topY-300);
  2711     Gear^.Y := int2hwFloat(topY-300);
  2711     Gear^.dX := int2hwFloat(Gear^.Target.X - 5 * Gear^.Tag * 15);
  2712     Gear^.dX := int2hwFloat(Gear^.Target.X) - int2hwFloat(Gear^.Tag * Gear^.Health * Gear^.Damage) / 2;
  2712 
  2713 
  2713     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
  2714     // calcs for Napalm Strike, so that it will hit the target (without wind at least :P)
  2714     if (Gear^.State = 2) then
  2715     if (Gear^.State = 2) then
  2715         Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900
  2716         Gear^.dX := Gear^.dX - cBombsSpeed * Gear^.Tag * 900
  2716     // calcs for regular falling gears
  2717     // calcs for regular falling gears
  2717     else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then
  2718     else if (int2hwFloat(Gear^.Target.Y) - Gear^.Y > _0) then
  2718             Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 /
  2719             Gear^.dX := Gear^.dX - cBombsSpeed * hwSqrt((int2hwFloat(Gear^.Target.Y) - Gear^.Y) * 2 /
  2719                 cGravity) * Gear^.Tag;
  2720                 cGravity) * Gear^.Tag;
  2720 
  2721 
  2721     Gear^.Health := 6;
       
  2722     Gear^.doStep := @doStepAirAttackWork;
  2722     Gear^.doStep := @doStepAirAttackWork;
  2723     Gear^.SoundChannel := LoopSound(sndPlane, 4000);
  2723     Gear^.SoundChannel := LoopSound(sndPlane, 4000);
  2724 
  2724 
  2725 end;
  2725 end;
  2726 
  2726 
  5196 end;
  5196 end;
  5197 
  5197 
  5198 ////////////////////////////////////////////////////////////////////////////////
  5198 ////////////////////////////////////////////////////////////////////////////////
  5199 procedure doStepPoisonCloud(Gear: PGear);
  5199 procedure doStepPoisonCloud(Gear: PGear);
  5200 begin
  5200 begin
  5201     WorldWrap(Gear);
  5201     // don't bounce
       
  5202     if WorldEdge <> weBounce then
       
  5203         WorldWrap(Gear);
  5202     if Gear^.Timer = 0 then
  5204     if Gear^.Timer = 0 then
  5203         begin
  5205         begin
  5204         DeleteGear(Gear);
  5206         DeleteGear(Gear);
  5205         exit
  5207         exit
  5206         end;
  5208         end;
  5252                     // do 1/2 current hp worth of damage if extra damage is enabled (1/3 damage if not)
  5254                     // do 1/2 current hp worth of damage if extra damage is enabled (1/3 damage if not)
  5253                     if cDamageModifier > _1 then
  5255                     if cDamageModifier > _1 then
  5254                         d:= 2
  5256                         d:= 2
  5255                     else
  5257                     else
  5256                         d:= 3;
  5258                         d:= 3;
  5257                     // always round up
  5259 
  5258                     if dmg mod d > 0 then
  5260                     // always rounding down
  5259                         dmg:= dmg div d + 1
  5261                     dmg:= dmg div d;
  5260                     else
  5262 
  5261                         dmg:= dmg div d;
  5263                     if dmg > 0 then
  5262 
  5264                         ApplyDamage(tmp, CurrentHedgehog, dmg, dsUnknown);
  5263                     ApplyDamage(tmp, CurrentHedgehog, dmg, dsUnknown);
       
  5264                     end;
  5265                     end;
  5265                 end;
  5266                 end;
  5266 
  5267 
  5267             if (tmp^.Kind <> gtHedgehog) or (dmg > 0) or (tmp^.Health > tmp^.Damage) then
  5268             if (tmp^.Kind <> gtHedgehog) or (dmg > 0) or (tmp^.Health > tmp^.Damage) then
  5268                 begin
  5269                 begin
  5428         begin
  5429         begin
  5429         // now really resurrect the hogs with the hp saved in the graves
  5430         // now really resurrect the hogs with the hp saved in the graves
  5430         for i:= 0 to graves.size - 1 do
  5431         for i:= 0 to graves.size - 1 do
  5431             if graves.ar^[i]^.Health > 0 then
  5432             if graves.ar^[i]^.Health > 0 then
  5432                 begin
  5433                 begin
  5433                 resgear := AddGear(hwRound(graves.ar^[i]^.X), hwRound(graves.ar^[i]^.Y), gtHedgehog, gstWait, _0, _0, 0);
  5434                 resgear := AddGear(hwRound(graves.ar^[i]^.X), hwRound(graves.ar^[i]^.Y), gtHedgehog, gstWait, _0, _0, 0,graves.ar^[i]^.Pos);
  5434                 resgear^.Hedgehog := graves.ar^[i]^.Hedgehog;
  5435                 resgear^.Hedgehog := graves.ar^[i]^.Hedgehog;
  5435                 resgear^.Health := graves.ar^[i]^.Health;
  5436                 resgear^.Health := graves.ar^[i]^.Health;
  5436                 PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := resgear;
  5437                 PHedgehog(graves.ar^[i]^.Hedgehog)^.Gear := resgear;
  5437                 graves.ar^[i]^.Message:= graves.ar^[i]^.Message or gmDestroy;
  5438                 graves.ar^[i]^.Message:= graves.ar^[i]^.Message or gmDestroy;
  5438                 graves.ar^[i]^.Active:= true;
  5439                 graves.ar^[i]^.Active:= true;
  5790 spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
  5791 spewing ice cubes.  The cubes will be visual gears only.  The scatter from them and the impact snow dust should help hide imprecisions in things like the GearsNear effect.
  5791 For now we assume a "ray" like a deagle projected out from the gun.
  5792 For now we assume a "ray" like a deagle projected out from the gun.
  5792 All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".
  5793 All these effects assume the ray's angle is not changed and that the target type was unchanged over a number of ticks.  This is a simplifying assumption for "gun was applying freezing effect to the same target".
  5793   * When fired at water a layer of ice textured land is added above the water.
  5794   * When fired at water a layer of ice textured land is added above the water.
  5794   * When fired at non-ice land (land and lfLandMask and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
  5795   * When fired at non-ice land (land and lfLandMask and not lfIce) the land is overlaid with a thin layer of ice textured land around that point (say, 1 or 2px into land, 1px above). For attractiveness, a slope would probably be needed.
  5795   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.  As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.  If the effect is interrupted before reaching the top, the freezing state is cleared.
  5796   * When fired at a hog (land and $00FF <> 0), while the hog is targetted, the hog's state is set to frozen.
  5796 A frozen hog will animate differently.  To be decided, but possibly in a similar fashion to a grave when it comes to explosions.  The hog might (possibly) not be damaged by explosions.  This might make freezing potentially useful for friendlies in a bad position.  It might be better to allow damage though.
  5797     As long as the gun is on the hog, a frozen hog sprite creeps up from the feet to the head.
  5797 A frozen hog stays frozen for a certain number of turns. Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again.
  5798     If the effect is interrupted before reaching the top, the freezing state is cleared.
       
  5799 A frozen hog will animate differently.
       
  5800     To be decided, but possibly in a similar fashion to a grave when it comes to explosions.
       
  5801     The hog might (possibly) not be damaged by explosions.
       
  5802     This might make freezing potentially useful for friendlies in a bad position.
       
  5803     It might be better to allow damage though.
       
  5804 A frozen hog stays frozen for a certain number of turns.
       
  5805     Each turn the frozen overlay becomes fainter, until it fades and the hog animates normally again.
  5798 *)
  5806 *)
  5799 
  5807 
  5800 
  5808 
  5801 procedure updateFuel(Gear: PGear);
  5809 procedure updateFuel(Gear: PGear);
  5802 var
  5810 var