hedgewars/uGears.pas
changeset 39 b78e7185ed13
parent 38 c1ec4b15d70e
child 42 72ffe21f027c
equal deleted inserted replaced
38:c1ec4b15d70e 39:b78e7185ed13
   110                                                                doStepRope,
   110                                                                doStepRope,
   111                                                                doStepSmokeTrace,
   111                                                                doStepSmokeTrace,
   112                                                                doStepExplosion,
   112                                                                doStepExplosion,
   113                                                                doStepMine,
   113                                                                doStepMine,
   114                                                                doStepCase,
   114                                                                doStepCase,
   115                                                                doStepDEagleShot
   115                                                                doStepDEagleShot,
       
   116                                                                doStepDynamite
   116                                                                );
   117                                                                );
   117 
   118 
   118 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
   119 function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
   119 begin
   120 begin
   120 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+')');{$ENDIF}
   121 {$IFDEF DEBUGFILE}AddFileLog('AddGear: ('+inttostr(x)+','+inttostr(y)+')');{$ENDIF}
   206                 end;
   207                 end;
   207   gtDEagleShot: begin
   208   gtDEagleShot: begin
   208                 Result.HalfWidth:= 1;
   209                 Result.HalfWidth:= 1;
   209                 Result.HalfHeight:= 1;
   210                 Result.HalfHeight:= 1;
   210                 Result.Health:= 50
   211                 Result.Health:= 50
       
   212                 end;
       
   213     gtDynamite: begin
       
   214                 Result.HalfWidth:= 3;
       
   215                 Result.HalfHeight:= 3;
       
   216                 Result.Elasticity:= 0.03;
       
   217                 Result.Friction:= 0.03;
       
   218                 Result.Timer:= 5000;
   211                 end;
   219                 end;
   212      end;
   220      end;
   213 if GearsList = nil then GearsList:= Result
   221 if GearsList = nil then GearsList:= Result
   214                    else begin
   222                    else begin
   215                    GearsList.PrevGear:= Result;
   223                    GearsList.PrevGear:= Result;
   482                     end;
   490                     end;
   483        gtExplosion: DrawSprite(sprExplosion50, Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
   491        gtExplosion: DrawSprite(sprExplosion50, Round(Gear.X) + WorldDx, Round(Gear.Y) + WorldDy, Gear.State, Surface);
   484             gtMine: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
   492             gtMine: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
   485                        then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
   493                        then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
   486                        else DrawSprite(sprMineOn  , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
   494                        else DrawSprite(sprMineOn  , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
       
   495         //!!!              ACHTUNG!!!!
       
   496         gtDynamite: if ((Gear.State and gstAttacking) = 0)or((Gear.Timer and $3FF) < 420)
       
   497                        then DrawSprite(sprMineOff , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface)
       
   498                        else DrawSprite(sprMineOn  , Round(Gear.X) - 8 + WorldDx, Round(Gear.Y) - 8 + WorldDy, trunc(Gear.DirAngle), Surface);
       
   499         //!!!              ACHTUNG!!!!                     
   487             gtCase: DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
   500             gtCase: DrawSprite(sprCase, Round(Gear.X) - 16 + WorldDx, Round(Gear.Y) - 16 + WorldDy, 0, Surface);
   488               end;
   501               end;
   489       Gear:= Gear.NextGear
   502       Gear:= Gear.NextGear
   490       end;
   503       end;
   491 end;
   504 end;
   525 TargetPoint.X:= NoPointX;
   538 TargetPoint.X:= NoPointX;
   526 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
   539 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
   527 DrawExplosion(X, Y, Radius);
   540 DrawExplosion(X, Y, Radius);
   528 if Radius = 50 then AddGear(X, Y, gtExplosion, 0);
   541 if Radius = 50 then AddGear(X, Y, gtExplosion, 0);
   529 if (Mask and EXPLAutoSound)<>0 then PlaySound(sndExplosion);
   542 if (Mask and EXPLAutoSound)<>0 then PlaySound(sndExplosion);
   530 if (Mask and EXPLNoDamage)<>0 then exit;
       
   531 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;
   543 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;
   532 Gear:= GearsList;
   544 Gear:= GearsList;
   533 while Gear <> nil do
   545 while Gear <> nil do
   534       begin
   546       begin
   535       dmg:= Radius - Round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - Y)));
   547       dmg:= Radius - Round(sqrt(sqr(Gear.X - X) + sqr(Gear.Y - Y)));
   538          dmg:= dmg shr 1;
   550          dmg:= dmg shr 1;
   539          case Gear.Kind of
   551          case Gear.Kind of
   540               gtHedgehog,
   552               gtHedgehog,
   541                   gtMine,
   553                   gtMine,
   542                   gtCase: begin
   554                   gtCase: begin
   543                           inc(Gear.Damage, dmg);
   555                           if (Mask and EXPLNoDamage) = 0 then inc(Gear.Damage, dmg);
   544                           Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
   556                           Gear.dX:= Gear.dX + dmg / 200 * sign(Gear.X - X);
   545                           Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);
   557                           Gear.dY:= Gear.dY + dmg / 200 * sign(Gear.Y - Y);
   546                           Gear.Active:= true;
   558                           Gear.Active:= true;
   547                           FollowGear:= Gear
   559                           FollowGear:= Gear
   548                           end;
   560                           end;