hedgewars/uGears.pas
changeset 53 0e27949850e3
parent 51 b6e3ae05857f
child 54 839fd258ae6f
equal deleted inserted replaced
52:ae2950c5465c 53:0e27949850e3
    48              dX: Real;
    48              dX: Real;
    49              dY: Real;
    49              dY: Real;
    50              Kind: TGearType;
    50              Kind: TGearType;
    51              Pos: Longword;
    51              Pos: Longword;
    52              doStep: TGearStepProcedure;
    52              doStep: TGearStepProcedure;
    53              HalfWidth, HalfHeight: integer;
    53              Radius: integer;
    54              Angle, Power : Cardinal;
    54              Angle, Power : Cardinal;
    55              DirAngle: real;
    55              DirAngle: real;
    56              Timer : LongWord;
    56              Timer : LongWord;
    57              Elasticity: Real;
    57              Elasticity: Real;
    58              Friction  : Real;
    58              Friction  : Real;
    87                                   end;
    87                                   end;
    88                  end;
    88                  end;
    89 
    89 
    90 procedure DeleteGear(Gear: PGear); forward;
    90 procedure DeleteGear(Gear: PGear); forward;
    91 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
    91 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
    92 procedure AmmoShove(Ammo, Gear: PGear; Power: Longword); forward;
    92 procedure AmmoShove(Ammo: PGear; Power: integer); forward;
    93 function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear; forward;
    93 function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear; forward;
    94 procedure SpawnBoxOfSmth; forward;
    94 procedure SpawnBoxOfSmth; forward;
    95 procedure AfterAttack; forward;
    95 procedure AfterAttack; forward;
    96 
    96 
    97 {$INCLUDE GSHandlers.inc}
    97 {$INCLUDE GSHandlers.inc}
   135 Result.CollIndex:= High(Longword);
   135 Result.CollIndex:= High(Longword);
   136 if CurrentTeam <> nil then
   136 if CurrentTeam <> nil then
   137    Result.Hedgehog:= @CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog];
   137    Result.Hedgehog:= @CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog];
   138 case Kind of
   138 case Kind of
   139    gtAmmo_Bomb: begin
   139    gtAmmo_Bomb: begin
   140                 Result.HalfWidth:= 4;
   140                 Result.Radius:= 4;
   141                 Result.HalfHeight:= 4;
       
   142                 Result.Elasticity:= 0.6;
   141                 Result.Elasticity:= 0.6;
   143                 Result.Friction:= 0.995;
   142                 Result.Friction:= 0.995;
   144                 Result.Timer:= Timer
   143                 Result.Timer:= Timer
   145                 end;
   144                 end;
   146     gtHedgehog: begin
   145     gtHedgehog: begin
   147                 Result.HalfWidth:= 6;
   146                 Result.Radius:= cHHRadius;
   148                 Result.HalfHeight:= cHHHalfHeight;
       
   149                 Result.Elasticity:= 0.002;
   147                 Result.Elasticity:= 0.002;
   150                 Result.Friction:= 0.999;
   148                 Result.Friction:= 0.999;
   151                 end;
   149                 end;
   152 gtAmmo_Grenade: begin
   150 gtAmmo_Grenade: begin
   153                 Result.HalfWidth:= 4;
   151                 Result.Radius:= 4;
   154                 Result.HalfHeight:= 4;
       
   155                 end;
   152                 end;
   156    gtHealthTag: begin
   153    gtHealthTag: begin
   157                 Result.Timer:= 1500;
   154                 Result.Timer:= 1500;
   158                 end;
   155                 end;
   159        gtGrave: begin
   156        gtGrave: begin
   160                 Result.HalfWidth:= 10;
   157                 Result.Radius:= 10;
   161                 Result.HalfHeight:= 10;
       
   162                 Result.Elasticity:= 0.6;
   158                 Result.Elasticity:= 0.6;
   163                 end;
   159                 end;
   164          gtUFO: begin
   160          gtUFO: begin
   165                 Result.HalfWidth:= 5;
   161                 Result.Radius:= 5;
   166                 Result.HalfHeight:= 2;
       
   167                 Result.Timer:= 500;
   162                 Result.Timer:= 500;
   168                 Result.Elasticity:= 0.9
   163                 Result.Elasticity:= 0.9
   169                 end;
   164                 end;
   170  gtShotgunShot: begin
   165  gtShotgunShot: begin
   171                 Result.Timer:= 900;
   166                 Result.Timer:= 900;
   172                 Result.HalfWidth:= 2;
   167                 Result.Radius:= 2
   173                 Result.HalfHeight:= 2
       
   174                 end;
   168                 end;
   175  gtActionTimer: begin
   169  gtActionTimer: begin
   176                 Result.Timer:= Timer
   170                 Result.Timer:= Timer
   177                 end;
   171                 end;
   178   gtPickHammer: begin
   172   gtPickHammer: begin
   179                 Result.HalfWidth:= 10;
   173                 Result.Radius:= 10;
   180                 Result.HalfHeight:= 2;
       
   181                 Result.Timer:= 4000
   174                 Result.Timer:= 4000
   182                 end;
   175                 end;
   183   gtSmokeTrace: begin
   176   gtSmokeTrace: begin
   184                 Result.X:= Result.X - 16;
   177                 Result.X:= Result.X - 16;
   185                 Result.Y:= Result.Y - 16;
   178                 Result.Y:= Result.Y - 16;
   186                 Result.State:= 8
   179                 Result.State:= 8
   187                 end;
   180                 end;
   188         gtRope: begin
   181         gtRope: begin
   189                 Result.HalfWidth:= 3;
   182                 Result.Radius:= 3;
   190                 Result.HalfHeight:= 3;
       
   191                 Result.Friction:= 500;
   183                 Result.Friction:= 500;
   192                 RopePoints.Count:= 0;
   184                 RopePoints.Count:= 0;
   193                 end;
   185                 end;
   194    gtExplosion: begin
   186    gtExplosion: begin
   195                 Result.X:= Result.X - 25;
   187                 Result.X:= Result.X - 25;
   196                 Result.Y:= Result.Y - 25;
   188                 Result.Y:= Result.Y - 25;
   197                 end;
   189                 end;
   198         gtMine: begin
   190         gtMine: begin
   199                 Result.HalfWidth:= 3;
   191                 Result.Radius:= 3;
   200                 Result.HalfHeight:= 3;
       
   201                 Result.Elasticity:= 0.55;
   192                 Result.Elasticity:= 0.55;
   202                 Result.Friction:= 0.995;
   193                 Result.Friction:= 0.995;
   203                 Result.Timer:= 3000;
   194                 Result.Timer:= 3000;
   204                 end;
   195                 end;
   205         gtCase: begin
   196         gtCase: begin
   206                 Result.HalfWidth:= 14;
   197                 Result.Radius:= 14;
   207                 Result.HalfHeight:= 14;
       
   208                 Result.Elasticity:= 0.6
   198                 Result.Elasticity:= 0.6
   209                 end;
   199                 end;
   210   gtDEagleShot: begin
   200   gtDEagleShot: begin
   211                 Result.HalfWidth:= 1;
   201                 Result.Radius:= 1;
   212                 Result.HalfHeight:= 1;
   202                 Result.Radius:= 1;
   213                 Result.Health:= 50
   203                 Result.Health:= 50
   214                 end;
   204                 end;
   215     gtDynamite: begin
   205     gtDynamite: begin
   216                 Result.HalfWidth:= 3;
   206                 Result.Radius:= 3;
   217                 Result.HalfHeight:= 3;
       
   218                 Result.Elasticity:= 0.03;
   207                 Result.Elasticity:= 0.03;
   219                 Result.Friction:= 0.03;
   208                 Result.Friction:= 0.03;
   220                 Result.Timer:= 5000;
   209                 Result.Timer:= 5000;
   221                 end;
   210                 end;
   222      end;
   211      end;
   229 end;
   218 end;
   230 
   219 
   231 procedure DeleteGear(Gear: PGear);
   220 procedure DeleteGear(Gear: PGear);
   232 var team: PTeam;
   221 var team: PTeam;
   233 begin
   222 begin
   234 if Gear.CollIndex < High(Longword) then DeleteCR(Gear);
   223 if Gear.CollIndex < High(Longword) then DeleteCI(Gear);
   235 if Gear.Kind = gtHedgehog then
   224 if Gear.Kind = gtHedgehog then
   236    if CurAmmoGear <> nil then
   225    if CurAmmoGear <> nil then
   237       begin
   226       begin
   238       {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: Sending gm_Destroy, hh handle = '+inttostr(integer(Gear)));{$ENDIF}
   227       {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: Sending gm_Destroy, hh handle = '+inttostr(integer(Gear)));{$ENDIF}
   239       Gear.Message:= gm_Destroy;
   228       Gear.Message:= gm_Destroy;
   577          end;
   566          end;
   578       Gear:= Gear.NextGear
   567       Gear:= Gear.NextGear
   579       end
   568       end
   580 end;
   569 end;
   581 
   570 
   582 procedure AmmoShove(Ammo, Gear: PGear; Power: Longword);
   571 procedure AmmoShove(Ammo: PGear; Power: integer);
   583 begin
   572 var t: PGearArray;
   584 case Gear.Kind of
   573     i: integer;
   585      gtHedgehog,
   574 begin
   586          gtMine,
   575 t:= CheckGearsCollision(Ammo);
   587          gtCase: begin
   576 i:= t.Count;
   588                  inc(Gear.Damage, Power);
   577 while i > 0 do
   589                  Gear.dX:= Ammo.dX * Power * 0.01;
   578     begin
   590                  Gear.dY:= Ammo.dY * Power * 0.01;
   579     dec(i);
   591                  Gear.Active:= true;
   580     case t.ar[i].Kind of
   592                  FollowGear:= Gear
   581            gtHedgehog,
   593                  end;
   582                gtMine,
   594      end;
   583                gtCase: begin
       
   584                        inc(t.ar[i].Damage, Power);
       
   585                        t.ar[i].dX:= Ammo.dX * Power * 0.01;
       
   586                        t.ar[i].dY:= Ammo.dY * Power * 0.01;
       
   587                        t.ar[i].Active:= true;
       
   588                        DeleteCI(t.ar[i]);
       
   589                        FollowGear:= t.ar[i]
       
   590                        end;
       
   591            end
       
   592     end
   595 end;
   593 end;
   596 
   594 
   597 procedure AssignHHCoords;
   595 procedure AssignHHCoords;
   598 var Gear: PGear;
   596 var Gear: PGear;
   599     pX, pY: integer;
   597     pX, pY: integer;
   674   y:= -1;
   672   y:= -1;
   675   while (y < 1023) and not b do
   673   while (y < 1023) and not b do
   676         begin
   674         begin
   677         inc(y);
   675         inc(y);
   678         i:= x - 13;
   676         i:= x - 13;
   679         while (i <= x + 13) and not b do // 13 is gtCase HalfWidth-1
   677         while (i <= x + 13) and not b do // 13 is gtCase Radius-1
   680               begin
   678               begin
   681               if Land[y, i] <> 0 then
   679               if Land[y, i] <> 0 then
   682                  begin
   680                  begin
   683                  b:= true;
   681                  b:= true;
   684                  end;
   682                  end;