hedgewars/uGearsList.pas
changeset 10040 4ac87acbaed9
parent 10015 4feced261c68
parent 10032 db65298717da
child 10108 c68cf030eded
equal deleted inserted replaced
10019:c00db97a668f 10040:4ac87acbaed9
    18 
    18 
    19 {$INCLUDE "options.inc"}
    19 {$INCLUDE "options.inc"}
    20 unit uGearsList;
    20 unit uGearsList;
    21 
    21 
    22 interface
    22 interface
    23 uses uFloat, uTypes;
    23 uses uFloat, uTypes, SDLh;
    24 
    24 
    25 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    25 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    26 procedure DeleteGear(Gear: PGear);
    26 procedure DeleteGear(Gear: PGear);
    27 procedure InsertGearToList(Gear: PGear);
    27 procedure InsertGearToList(Gear: PGear);
    28 procedure RemoveGearFromList(Gear: PGear);
    28 procedure RemoveGearFromList(Gear: PGear);
   154 end;
   154 end;
   155 
   155 
   156 
   156 
   157 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   157 function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
   158 var gear: PGear;
   158 var gear: PGear;
       
   159     c: byte;
   159 begin
   160 begin
   160 inc(GCounter);
   161 inc(GCounter);
   161 
   162 
   162 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   163 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   163 
   164 
   180 gear^.ImpactSound:= sndNone;
   181 gear^.ImpactSound:= sndNone;
   181 gear^.Density:= _1;
   182 gear^.Density:= _1;
   182 // Define ammo association, if any.
   183 // Define ammo association, if any.
   183 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
   184 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
   184 gear^.CollisionMask:= $FFFF;
   185 gear^.CollisionMask:= $FFFF;
       
   186 gear^.Tint:= $FFFFFFFF;
   185 
   187 
   186 if CurrentHedgehog <> nil then
   188 if CurrentHedgehog <> nil then
   187     begin
   189     begin
   188     gear^.Hedgehog:= CurrentHedgehog;
   190     gear^.Hedgehog:= CurrentHedgehog;
   189     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
   191     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
   235                 gear^.Density:= _3;
   237                 gear^.Density:= _3;
   236                 gear^.Z:= cHHZ;
   238                 gear^.Z:= cHHZ;
   237                 if (GameFlags and gfAISurvival) <> 0 then
   239                 if (GameFlags and gfAISurvival) <> 0 then
   238                     if gear^.Hedgehog^.BotLevel > 0 then
   240                     if gear^.Hedgehog^.BotLevel > 0 then
   239                         gear^.Hedgehog^.Effects[heResurrectable] := 1;
   241                         gear^.Hedgehog^.Effects[heResurrectable] := 1;
       
   242                 // this would presumably be set in the frontend
       
   243                 // if we weren't going to do that yet, would need to reinit GetRandom
       
   244                 // oh, and, randomising slightly R and B might be nice too.
       
   245                 //gear^.Tint:= $fa00efff or ((random(80)+128) shl 16)
       
   246                 //gear^.Tint:= $faa4efff
       
   247                 //gear^.Tint:= (($e0+random(32)) shl 24) or
       
   248                 //             ((random(80)+128) shl 16) or
       
   249                 //             (($d5+random(32)) shl 8) or $ff
       
   250                 c:= random(32);
       
   251                 gear^.Tint:= (($e0+c) shl 24) or
       
   252                              ((random(90)+128) shl 16) or
       
   253                              (($d5+c) shl 8) or $ff
   240                 end;
   254                 end;
   241        gtShell: begin
   255        gtShell: begin
   242                 gear^.Elasticity:= _0_8;
   256                 gear^.Elasticity:= _0_8;
   243                 gear^.Friction:= _0_8;
   257                 gear^.Friction:= _0_8;
   244                 gear^.Radius:= 4;
   258                 gear^.Radius:= 4;
   272                         end;
   286                         end;
   273                     State:= State or gstInvisible;
   287                     State:= State or gstInvisible;
   274                     Health:= random(vobFrameTicks);
   288                     Health:= random(vobFrameTicks);
   275                     if gear^.Timer = 0 then Timer:= random(vobFramesCount);
   289                     if gear^.Timer = 0 then Timer:= random(vobFramesCount);
   276                     Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8;
   290                     Damage:= (random(2) * 2 - 1) * (vobVelocity + random(vobVelocity)) * 8;
       
   291                     Tint:= (ExplosionBorderColor and RMask shl RShift) or
       
   292                            (ExplosionBorderColor and GMask shl GShift) or
       
   293                            (ExplosionBorderColor and BMask shl BShift) or $FF;
   277                     end
   294                     end
   278                 end;
   295                 end;
   279        gtGrave: begin
   296        gtGrave: begin
   280                 gear^.ImpactSound:= sndGraveImpact;
   297                 gear^.ImpactSound:= sndGraveImpact;
   281                 gear^.nImpactSounds:= 1;
   298                 gear^.nImpactSounds:= 1;
   400    gtFirePunch: begin
   417    gtFirePunch: begin
   401                 if gear^.Timer = 0 then gear^.Timer:= 3000;
   418                 if gear^.Timer = 0 then gear^.Timer:= 3000;
   402                 gear^.Radius:= 15;
   419                 gear^.Radius:= 15;
   403                 gear^.Tag:= Y
   420                 gear^.Tag:= Y
   404                 end;
   421                 end;
   405    gtAirAttack: gear^.Z:= cHHZ+2;
   422    gtAirAttack: begin
       
   423                 gear^.Z:= cHHZ+2;
       
   424                 gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
       
   425                 end;
   406      gtAirBomb: begin
   426      gtAirBomb: begin
   407                 gear^.Radius:= 5;
   427                 gear^.Radius:= 5;
   408                 gear^.Density:= _2;
   428                 gear^.Density:= _2;
   409                 end;
   429                 end;
   410    gtBlowTorch: begin
   430    gtBlowTorch: begin
   485                 if gear^.Timer = 0 then gear^.Timer:= 5001;
   505                 if gear^.Timer = 0 then gear^.Timer:= 5001;
   486                 end;
   506                 end;
   487      gtRCPlane: begin
   507      gtRCPlane: begin
   488                 if gear^.Timer = 0 then gear^.Timer:= 15000;
   508                 if gear^.Timer = 0 then gear^.Timer:= 15000;
   489                 gear^.Health:= 3;
   509                 gear^.Health:= 3;
   490                 gear^.Radius:= 8
   510                 gear^.Radius:= 8;
       
   511                 gear^.Tint:= gear^.Hedgehog^.Team^.Clan^.Color shl 8 or $FF
   491                 end;
   512                 end;
   492      gtJetpack: begin
   513      gtJetpack: begin
   493                 gear^.Health:= 2000;
   514                 gear^.Health:= 2000;
   494                 gear^.Damage:= 100;
   515                 gear^.Damage:= 100;
   495                 gear^.State:= Gear^.State or gstSubmersible
   516                 gear^.State:= Gear^.State or gstSubmersible
   544                 gear^.Damage:= 100;
   565                 gear^.Damage:= 100;
   545                 end;
   566                 end;
   546  gtPoisonCloud: begin
   567  gtPoisonCloud: begin
   547                 if gear^.Timer = 0 then gear^.Timer:= 5000;
   568                 if gear^.Timer = 0 then gear^.Timer:= 5000;
   548                 gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000;
   569                 gear^.dY:= int2hwfloat(-4 + longint(getRandom(8))) / 1000;
       
   570                 gear^.Tint:= $C0C000C0
   549                 end;
   571                 end;
   550  gtResurrector: begin
   572  gtResurrector: begin
   551                 gear^.Radius := 100;
   573                 gear^.Radius := 100;
   552                 gear^.Tag := 0
   574                 gear^.Tag := 0;
       
   575                 gear^.Tint:= $F5DB35FF
   553                 end;
   576                 end;
   554      gtWaterUp: begin
   577      gtWaterUp: begin
   555                 gear^.Tag := 47;
   578                 gear^.Tag := 47;
   556                 end;
   579                 end;
   557   gtNapalmBomb: begin
   580   gtNapalmBomb: begin