hedgewars/uGearsList.pas
changeset 7110 c91d33837b0d
parent 7093 2d7f1fb73335
child 7168 8defaabce92e
equal deleted inserted replaced
7020:846cea23aea2 7110:c91d33837b0d
    31 
    31 
    32 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
    32 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
    33     uTextures, uScript, uRenderUtils, uAI, uCollisions,
    33     uTextures, uScript, uRenderUtils, uAI, uCollisions,
    34     uGearsRender, uGearsUtils;
    34     uGearsRender, uGearsUtils;
    35 
    35 
       
    36 var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
       
    37 
    36 procedure InsertGearToList(Gear: PGear);
    38 procedure InsertGearToList(Gear: PGear);
    37 var tmp, ptmp: PGear;
    39 var tmp, ptmp: PGear;
    38 begin
    40 begin
    39     tmp:= GearsList;
    41     tmp:= GearsList;
    40     ptmp:= GearsList;
    42     ptmp:= GearsList;
    72 end;
    74 end;
    73     
    75     
    74 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    76 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    75 var gear: PGear;
    77 var gear: PGear;
    76 begin
    78 begin
    77 inc(Counter);
    79 inc(GCounter);
    78 AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
    80 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
    79 
    81 
    80 New(gear);
    82 New(gear);
    81 FillChar(gear^, sizeof(TGear), 0);
    83 FillChar(gear^, sizeof(TGear), 0);
    82 gear^.X:= int2hwFloat(X);
    84 gear^.X:= int2hwFloat(X);
    83 gear^.Y:= int2hwFloat(Y);
    85 gear^.Y:= int2hwFloat(Y);
    89 gear^.dY:= dY;
    91 gear^.dY:= dY;
    90 gear^.doStep:= doStepHandlers[Kind];
    92 gear^.doStep:= doStepHandlers[Kind];
    91 gear^.CollisionIndex:= -1;
    93 gear^.CollisionIndex:= -1;
    92 gear^.Timer:= Timer;
    94 gear^.Timer:= Timer;
    93 gear^.FlightTime:= 0;
    95 gear^.FlightTime:= 0;
    94 gear^.uid:= Counter;
    96 gear^.uid:= GCounter;
    95 gear^.SoundChannel:= -1;
    97 gear^.SoundChannel:= -1;
    96 gear^.ImpactSound:= sndNone;
    98 gear^.ImpactSound:= sndNone;
    97 gear^.nImpactSounds:= 0;
    99 gear^.nImpactSounds:= 0;
    98 gear^.Density:= _1;
   100 gear^.Density:= _1;
    99 // Define ammo association, if any.
   101 // Define ammo association, if any.
   146                 gear^.Angle:= cMaxAngle div 2;
   148                 gear^.Angle:= cMaxAngle div 2;
   147                 gear^.Density:= _3;
   149                 gear^.Density:= _3;
   148                 gear^.Z:= cHHZ;
   150                 gear^.Z:= cHHZ;
   149                 if (GameFlags and gfAISurvival) <> 0 then
   151                 if (GameFlags and gfAISurvival) <> 0 then
   150                     if gear^.Hedgehog^.BotLevel > 0 then
   152                     if gear^.Hedgehog^.BotLevel > 0 then
   151                         gear^.Hedgehog^.Effects[heResurrectable] := 0;
   153                         gear^.Hedgehog^.Effects[heResurrectable] := 1;
   152                 end;
   154                 end;
   153        gtShell: begin
   155        gtShell: begin
   154                 gear^.Radius:= 4;
   156                 gear^.Radius:= 4;
   155                 gear^.Density:= _1;
   157                 gear^.Density:= _1;
   156                 end;
   158                 end;
   166      gtFlake: begin
   168      gtFlake: begin
   167                 with Gear^ do
   169                 with Gear^ do
   168                     begin
   170                     begin
   169                     Pos:= 0;
   171                     Pos:= 0;
   170                     Radius:= 1;
   172                     Radius:= 1;
   171                     DirAngle:= random * 360;
   173                     DirAngle:= random(360);
   172                     if State and gstTmpFlag = 0 then
   174                     if State and gstTmpFlag = 0 then
   173                         begin
   175                         begin
   174                         dx.isNegative:= GetRandom(2) = 0;
   176                         dx.isNegative:= GetRandom(2) = 0;
   175                         dx.QWordValue:= GetRandom(100000000);
   177                         dx.QWordValue:= GetRandom(100000000);
   176                         dy.isNegative:= false;
   178                         dy.isNegative:= false;
   453                 gear^.Health:= 200;
   455                 gear^.Health:= 200;
   454                 gear^.Timer:= 0;
   456                 gear^.Timer:= 0;
   455                 gear^.Tag:= TotalRounds + 3;
   457                 gear^.Tag:= TotalRounds + 3;
   456                 gear^.Pos:= 1;
   458                 gear^.Pos:= 1;
   457                 end;
   459                 end;
       
   460       gtIceGun: gear^.Health:= 1000;
   458     end;
   461     end;
   459 
   462 
   460 InsertGearToList(gear);
   463 InsertGearToList(gear);
   461 AddGear:= gear;
   464 AddGear:= gear;
   462 
   465