hedgewars/uGears.pas
changeset 4647 20b982afbe6e
parent 4641 43d17e3b81de
child 4669 296dbccdf376
equal deleted inserted replaced
4588:5ef5415c4ee1 4647:20b982afbe6e
    45 
    45 
    46 
    46 
    47 implementation
    47 implementation
    48 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
    48 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
    49      uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables,
    49      uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables,
    50      uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug;
    50      uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture;
    51 
    51 
    52 
    52 
    53 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
    53 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord); forward;
    54 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); forward;
    54 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask, Tint: LongWord); forward;
    55 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
    55 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt); forward;
   126             @doStepPoisonCloud,
   126             @doStepPoisonCloud,
   127             @doStepHammer,
   127             @doStepHammer,
   128             @doStepHammerHit,
   128             @doStepHammerHit,
   129             @doStepResurrector,
   129             @doStepResurrector,
   130             @doStepNapalmBomb,
   130             @doStepNapalmBomb,
   131             @doStepSnowball
   131             @doStepSnowball,
       
   132             @doStepSnowflake
   132             );
   133             );
   133 
   134 
   134 procedure InsertGearToList(Gear: PGear);
   135 procedure InsertGearToList(Gear: PGear);
   135 var tmp, ptmp: PGear;
   136 var tmp, ptmp: PGear;
   136 begin
   137 begin
   218                 gear^.nImpactSounds:= 1;
   219                 gear^.nImpactSounds:= 1;
   219                 gear^.AdvBounce:= 1;
   220                 gear^.AdvBounce:= 1;
   220                 gear^.Radius:= 5;
   221                 gear^.Radius:= 5;
   221                 gear^.Elasticity:= _0_8;
   222                 gear^.Elasticity:= _0_8;
   222                 gear^.Friction:= _0_8;
   223                 gear^.Friction:= _0_8;
       
   224                 gear^.Density:= _1_5;
   223                 gear^.RenderTimer:= true;
   225                 gear^.RenderTimer:= true;
   224                 if gear^.Timer = 0 then gear^.Timer:= 3000
   226                 if gear^.Timer = 0 then gear^.Timer:= 3000
   225                 end;
   227                 end;
   226   gtWatermelon: begin
   228   gtWatermelon: begin
   227                 gear^.ImpactSound:= sndMelonImpact;
   229                 gear^.ImpactSound:= sndMelonImpact;
   228                 gear^.nImpactSounds:= 1;
   230                 gear^.nImpactSounds:= 1;
   229                 gear^.AdvBounce:= 1;
   231                 gear^.AdvBounce:= 1;
   230                 gear^.Radius:= 6;
   232                 gear^.Radius:= 6;
   231                 gear^.Elasticity:= _0_8;
   233                 gear^.Elasticity:= _0_8;
   232                 gear^.Friction:= _0_995;
   234                 gear^.Friction:= _0_995;
       
   235                 gear^.Density:= _2;
   233                 gear^.RenderTimer:= true;
   236                 gear^.RenderTimer:= true;
   234                 if gear^.Timer = 0 then gear^.Timer:= 3000
   237                 if gear^.Timer = 0 then gear^.Timer:= 3000
       
   238                 end;
       
   239   gtMelonPiece: begin
       
   240                 gear^.Density:= _2;
   235                 end;
   241                 end;
   236     gtHedgehog: begin
   242     gtHedgehog: begin
   237                 gear^.AdvBounce:= 1;
   243                 gear^.AdvBounce:= 1;
   238                 gear^.Radius:= cHHRadius;
   244                 gear^.Radius:= cHHRadius;
   239                 gear^.Elasticity:= _0_35;
   245                 gear^.Elasticity:= _0_35;
   240                 gear^.Friction:= _0_999;
   246                 gear^.Friction:= _0_999;
   241                 gear^.Angle:= cMaxAngle div 2;
   247                 gear^.Angle:= cMaxAngle div 2;
       
   248                 gear^.Density:= _3;
   242                 gear^.Z:= cHHZ;
   249                 gear^.Z:= cHHZ;
   243                 if (GameFlags and gfAISurvival) <> 0 then
   250                 if (GameFlags and gfAISurvival) <> 0 then
   244                     if gear^.Hedgehog^.BotLevel > 0 then
   251                     if gear^.Hedgehog^.BotLevel > 0 then
   245                         gear^.Hedgehog^.Effects[heResurrectable] := true;
   252                         gear^.Hedgehog^.Effects[heResurrectable] := true;
   246                 end;
   253                 end;
   247        gtShell: begin
   254        gtShell: begin
   248                 gear^.Radius:= 4;
   255                 gear^.Radius:= 4;
       
   256                 gear^.Density:= _1;
   249                 end;
   257                 end;
   250        gtSnowball: begin
   258        gtSnowball: begin
   251                 gear^.Radius:= 4;
   259                 gear^.Radius:= 4;
   252                 gear^.Elasticity:= _1;
   260                 gear^.Elasticity:= _1;
   253                 gear^.Friction:= _1;
   261                 gear^.Friction:= _1;
       
   262                 gear^.Density:= _0_5;
       
   263                 end;
       
   264 
       
   265      gtFlake: begin
       
   266                 with Gear^ do
       
   267                     begin
       
   268                     DirAngle:= random * 360;
       
   269                     dx.isNegative:= GetRandom(2) = 0;
       
   270                     dx.QWordValue:= GetRandom(100000000);
       
   271                     dy.isNegative:= false;
       
   272                     dy.QWordValue:= GetRandom(70000000);
       
   273                     if GetRandom(2) = 0 then dx := -dx;
       
   274                     Health:= random(vobFrameTicks);
       
   275                     Timer:= random(vobFramesCount);
       
   276                     Angle:= (random(2) * 2 - 1) * (1 + random(10000)) * vobVelocity
       
   277                     end
   254                 end;
   278                 end;
   255        gtGrave: begin
   279        gtGrave: begin
   256                 gear^.ImpactSound:= sndGraveImpact;
   280                 gear^.ImpactSound:= sndGraveImpact;
   257                 gear^.nImpactSounds:= 1;
   281                 gear^.nImpactSounds:= 1;
   258                 gear^.Radius:= 10;
   282                 gear^.Radius:= 10;
   286                 gear^.Health:= 10;
   310                 gear^.Health:= 10;
   287                 gear^.State:= gear^.State or gstMoving;
   311                 gear^.State:= gear^.State or gstMoving;
   288                 gear^.Radius:= 2;
   312                 gear^.Radius:= 2;
   289                 gear^.Elasticity:= _0_55;
   313                 gear^.Elasticity:= _0_55;
   290                 gear^.Friction:= _0_995;
   314                 gear^.Friction:= _0_995;
       
   315                 gear^.Density:= _0_9;
   291                 if cMinesTime < 0 then
   316                 if cMinesTime < 0 then
   292                     gear^.Timer:= getrandom(51)*100
   317                     gear^.Timer:= getrandom(51)*100
   293                 else
   318                 else
   294                     gear^.Timer:= cMinesTime;
   319                     gear^.Timer:= cMinesTime;
   295                 end;
   320                 end;
   297                 gear^.Health:= 10;
   322                 gear^.Health:= 10;
   298                 gear^.State:= gear^.State or gstMoving;
   323                 gear^.State:= gear^.State or gstMoving;
   299                 gear^.Radius:= 2;
   324                 gear^.Radius:= 2;
   300                 gear^.Elasticity:= _0_55;
   325                 gear^.Elasticity:= _0_55;
   301                 gear^.Friction:= _0_995;
   326                 gear^.Friction:= _0_995;
       
   327                 gear^.Density:= _0_9;
   302                 gear^.Timer:= 500;
   328                 gear^.Timer:= 500;
   303                 end;
   329                 end;
   304         gtCase: begin
   330         gtCase: begin
   305                 gear^.ImpactSound:= sndGraveImpact;
   331                 gear^.ImpactSound:= sndGraveImpact;
   306                 gear^.nImpactSounds:= 1;
   332                 gear^.nImpactSounds:= 1;
   311                 gear^.ImpactSound:= sndGrenadeImpact;
   337                 gear^.ImpactSound:= sndGrenadeImpact;
   312                 gear^.nImpactSounds:= 1;
   338                 gear^.nImpactSounds:= 1;
   313                 gear^.Radius:= 16;
   339                 gear^.Radius:= 16;
   314                 gear^.Elasticity:= _0_4;
   340                 gear^.Elasticity:= _0_4;
   315                 gear^.Friction:= _0_995;
   341                 gear^.Friction:= _0_995;
       
   342                 gear^.Density:= _6;
   316                 gear^.Health:= cBarrelHealth
   343                 gear^.Health:= cBarrelHealth
   317                 end;
   344                 end;
   318   gtDEagleShot: begin
   345   gtDEagleShot: begin
   319                 gear^.Radius:= 1;
   346                 gear^.Radius:= 1;
   320                 gear^.Health:= 50
   347                 gear^.Health:= 50
   325                 end;
   352                 end;
   326     gtDynamite: begin
   353     gtDynamite: begin
   327                 gear^.Radius:= 3;
   354                 gear^.Radius:= 3;
   328                 gear^.Elasticity:= _0_55;
   355                 gear^.Elasticity:= _0_55;
   329                 gear^.Friction:= _0_03;
   356                 gear^.Friction:= _0_03;
       
   357                 gear^.Density:= _2;
   330                 gear^.Timer:= 5000;
   358                 gear^.Timer:= 5000;
   331                 end;
   359                 end;
   332      gtCluster: begin
   360      gtCluster: begin
   333                 gear^.Radius:= 2;
   361                 gear^.Radius:= 2;
       
   362                 gear^.Density:= _1_5;
   334                 gear^.RenderTimer:= true
   363                 gear^.RenderTimer:= true
   335                 end;
   364                 end;
   336       gtShover: gear^.Radius:= 20;
   365       gtShover: gear^.Radius:= 20;
   337        gtFlame: begin
   366        gtFlame: begin
   338                 gear^.Tag:= GetRandom(32);
   367                 gear^.Tag:= GetRandom(32);
   339                 gear^.Radius:= 1;
   368                 gear^.Radius:= 1;
   340                 gear^.Health:= 5;
   369                 gear^.Health:= 5;
       
   370                 gear^.Density:= _1;
   341                 if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then
   371                 if (gear^.dY.QWordValue = 0) and (gear^.dX.QWordValue = 0) then
   342                     begin
   372                     begin
   343                     gear^.dY:= (getrandom - _0_8) * _0_03;
   373                     gear^.dY:= (getrandom - _0_8) * _0_03;
   344                     gear^.dX:= (getrandom - _0_5) * _0_4
   374                     gear^.dX:= (getrandom - _0_5) * _0_4
   345                     end
   375                     end
   348                 gear^.Radius:= 15;
   378                 gear^.Radius:= 15;
   349                 gear^.Tag:= Y
   379                 gear^.Tag:= Y
   350                 end;
   380                 end;
   351      gtAirBomb: begin
   381      gtAirBomb: begin
   352                 gear^.Radius:= 5;
   382                 gear^.Radius:= 5;
       
   383                 gear^.Density:= _2;
   353                 end;
   384                 end;
   354    gtBlowTorch: begin
   385    gtBlowTorch: begin
   355                 gear^.Radius:= cHHRadius + cBlowTorchC;
   386                 gear^.Radius:= cHHRadius + cBlowTorchC;
   356                 gear^.Timer:= 7500
   387                 gear^.Timer:= 7500
   357                 end;
   388                 end;
   366                 gear^.Timer:= 0
   397                 gear^.Timer:= 0
   367                 end;
   398                 end;
   368       gtMortar: begin
   399       gtMortar: begin
   369                 gear^.Radius:= 4;
   400                 gear^.Radius:= 4;
   370                 gear^.Elasticity:= _0_2;
   401                 gear^.Elasticity:= _0_2;
   371                 gear^.Friction:= _0_08
   402                 gear^.Friction:= _0_08;
       
   403                 gear^.Density:= _1;
   372                 end;
   404                 end;
   373         gtWhip: gear^.Radius:= 20;
   405         gtWhip: gear^.Radius:= 20;
   374       gtHammer: gear^.Radius:= 20;
   406       gtHammer: gear^.Radius:= 20;
   375     gtKamikaze: begin
   407     gtKamikaze: begin
   376                 gear^.Health:= 2048;
   408                 gear^.Health:= 2048;
   389                 gear^.nImpactSounds:= 4;
   421                 gear^.nImpactSounds:= 4;
   390                 gear^.AdvBounce:= 1;
   422                 gear^.AdvBounce:= 1;
   391                 gear^.Radius:= 4;
   423                 gear^.Radius:= 4;
   392                 gear^.Elasticity:= _0_5;
   424                 gear^.Elasticity:= _0_5;
   393                 gear^.Friction:= _0_96;
   425                 gear^.Friction:= _0_96;
       
   426                 gear^.Density:= _1_5;
   394                 gear^.RenderTimer:= true;
   427                 gear^.RenderTimer:= true;
   395                 gear^.Timer:= 5000
   428                 gear^.Timer:= 5000
   396                 end;
   429                 end;
   397        gtDrill: begin
   430        gtDrill: begin
   398                 gear^.Timer:= 5000;
   431                 gear^.Timer:= 5000;
   399                 gear^.Radius:= 4
   432                 gear^.Radius:= 4;
       
   433                 gear^.Density:= _1;
   400                 end;
   434                 end;
   401         gtBall: begin
   435         gtBall: begin
   402                 gear^.ImpactSound:= sndGrenadeImpact;
   436                 gear^.ImpactSound:= sndGrenadeImpact;
   403                 gear^.nImpactSounds:= 1;
   437                 gear^.nImpactSounds:= 1;
   404                 gear^.AdvBounce:= 1;
   438                 gear^.AdvBounce:= 1;
   405                 gear^.Radius:= 5;
   439                 gear^.Radius:= 5;
   406                 gear^.Tag:= random(8);
   440                 gear^.Tag:= random(8);
   407                 gear^.Timer:= 5000;
   441                 gear^.Timer:= 5000;
   408                 gear^.Elasticity:= _0_7;
   442                 gear^.Elasticity:= _0_7;
   409                 gear^.Friction:= _0_995;
   443                 gear^.Friction:= _0_995;
       
   444                 gear^.Density:= _1_5;
   410                 end;
   445                 end;
   411      gtBallgun: begin
   446      gtBallgun: begin
   412                 gear^.Timer:= 5001;
   447                 gear^.Timer:= 5001;
   413                 end;
   448                 end;
   414      gtRCPlane: begin
   449      gtRCPlane: begin
   420                 gear^.Health:= 2000;
   455                 gear^.Health:= 2000;
   421                 gear^.Damage:= 100
   456                 gear^.Damage:= 100
   422                 end;
   457                 end;
   423      gtMolotov: begin
   458      gtMolotov: begin
   424                 gear^.Radius:= 6;
   459                 gear^.Radius:= 6;
       
   460                 gear^.Density:= _2;
   425                 end;
   461                 end;
   426        gtBirdy: begin
   462        gtBirdy: begin
   427                 gear^.Radius:= 16; // todo: check
   463                 gear^.Radius:= 16; // todo: check
   428                 gear^.Timer:= 0;
   464                 gear^.Timer:= 0;
   429                 gear^.Health := 2000;
   465                 gear^.Health := 2000;
   431                 end;
   467                 end;
   432          gtEgg: begin
   468          gtEgg: begin
   433                 gear^.Radius:= 4;
   469                 gear^.Radius:= 4;
   434                 gear^.Elasticity:= _0_6;
   470                 gear^.Elasticity:= _0_6;
   435                 gear^.Friction:= _0_96;
   471                 gear^.Friction:= _0_96;
       
   472                 gear^.Density:= _1;
   436                 if gear^.Timer = 0 then gear^.Timer:= 3000
   473                 if gear^.Timer = 0 then gear^.Timer:= 3000
   437                 end;
   474                 end;
   438       gtPortal: begin
   475       gtPortal: begin
   439                 gear^.ImpactSound:= sndMelonImpact;
   476                 gear^.ImpactSound:= sndMelonImpact;
   440                 gear^.nImpactSounds:= 1;
   477                 gear^.nImpactSounds:= 1;
   444                 gear^.Timer:= 15000;
   481                 gear^.Timer:= 15000;
   445                 gear^.RenderTimer:= false;
   482                 gear^.RenderTimer:= false;
   446                 gear^.Health:= 100;
   483                 gear^.Health:= 100;
   447                 end;
   484                 end;
   448        gtPiano: begin
   485        gtPiano: begin
   449                 gear^.Radius:= 32
   486                 gear^.Radius:= 32;
       
   487                 gear^.Density:= _50;
   450                 end;
   488                 end;
   451  gtSineGunShot: begin
   489  gtSineGunShot: begin
   452                 gear^.Radius:= 5;
   490                 gear^.Radius:= 5;
   453                 gear^.Health:= 6000;
   491                 gear^.Health:= 6000;
   454                 end;
   492                 end;
   470                 gear^.Tag := 47;
   508                 gear^.Tag := 47;
   471                 end;
   509                 end;
   472   gtNapalmBomb: begin
   510   gtNapalmBomb: begin
   473                 gear^.Timer:= 1000;
   511                 gear^.Timer:= 1000;
   474                 gear^.Radius:= 5;
   512                 gear^.Radius:= 5;
       
   513                 gear^.Density:= _1_5;
   475                 end;
   514                 end;
   476     end;
   515     end;
   477 
   516 
   478 InsertGearToList(gear);
   517 InsertGearToList(gear);
   479 AddGear:= gear;
   518 AddGear:= gear;
   880      t: PGear;
   919      t: PGear;
   881 begin
   920 begin
   882     SpeechText:= ''; // in case it has not been consumed
   921     SpeechText:= ''; // in case it has not been consumed
   883 
   922 
   884     if (GameFlags and gfLowGravity) = 0 then
   923     if (GameFlags and gfLowGravity) = 0 then
       
   924         begin
   885         cGravity:= cMaxWindSpeed * 2;
   925         cGravity:= cMaxWindSpeed * 2;
       
   926         cGravityf:= 0.00025 * 2
       
   927         end;
   886 
   928 
   887     if (GameFlags and gfVampiric) = 0 then
   929     if (GameFlags and gfVampiric) = 0 then
   888         cVampiric:= false;
   930         cVampiric:= false;
   889 
   931 
   890     cDamageModifier:= _1;
   932     cDamageModifier:= _1;
  1055     Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
  1097     Gear:= AddGear(0, 0, gtExplosives, 0, _0, _0, 0);
  1056     FindPlace(Gear, false, 0, LAND_WIDTH);
  1098     FindPlace(Gear, false, 0, LAND_WIDTH);
  1057     end;
  1099     end;
  1058 
  1100 
  1059 if (GameFlags and gfLowGravity) <> 0 then
  1101 if (GameFlags and gfLowGravity) <> 0 then
       
  1102     begin
  1060     cGravity:= cMaxWindSpeed;
  1103     cGravity:= cMaxWindSpeed;
       
  1104     cGravityf:= 0.00025
       
  1105     end;
  1061 
  1106 
  1062 if (GameFlags and gfVampiric) <> 0 then
  1107 if (GameFlags and gfVampiric) <> 0 then
  1063     cVampiric:= true;
  1108     cVampiric:= true;
  1064 
  1109 
  1065 Gear:= GearsList;
  1110 Gear:= GearsList;
  1072 
  1117 
  1073 if (GameFlags and gfLaserSight) <> 0 then
  1118 if (GameFlags and gfLaserSight) <> 0 then
  1074     cLaserSighting:= true;
  1119     cLaserSighting:= true;
  1075 
  1120 
  1076 if (GameFlags and gfArtillery) <> 0 then
  1121 if (GameFlags and gfArtillery) <> 0 then
  1077     cArtillery:= true
  1122     cArtillery:= true;
       
  1123 
       
  1124 if (Theme = 'Snow') or (Theme = 'Christmas') then
       
  1125     for i:= 0 to Pred(vobCount*2) do
       
  1126         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(1024), gtFlake, 0, _0, _0, 0);
  1078 end;
  1127 end;
  1079 
  1128 
  1080 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1129 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
  1081 begin
  1130 begin
  1082 doMakeExplosion(X, Y, Radius, Mask, $FFFFFFFF);
  1131 doMakeExplosion(X, Y, Radius, Mask, $FFFFFFFF);