hedgewars/uGears.pas
changeset 3440 dee31c5149e0
parent 3437 858105ae769c
child 3442 69898c6ede14
equal deleted inserted replaced
3439:a98984e4f458 3440:dee31c5149e0
   132 
   132 
   133 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
   133 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
   134             @doStepBomb,
   134             @doStepBomb,
   135             @doStepHedgehog,
   135             @doStepHedgehog,
   136             @doStepGrenade,
   136             @doStepGrenade,
   137             @doStepHealthTag,
       
   138             @doStepGrave,
   137             @doStepGrave,
   139             @doStepBee,
   138             @doStepBee,
   140             @doStepShotgunShot,
   139             @doStepShotgunShot,
   141             @doStepPickHammer,
   140             @doStepPickHammer,
   142             @doStepRope,
   141             @doStepRope,
   143             @doStepSmokeTrace,
       
   144             @doStepExplosion,
       
   145             @doStepMine,
   142             @doStepMine,
   146             @doStepCase,
   143             @doStepCase,
   147             @doStepDEagleShot,
   144             @doStepDEagleShot,
   148             @doStepDynamite,
   145             @doStepDynamite,
   149             @doStepBomb,
   146             @doStepBomb,
   168             @doStepCake,
   165             @doStepCake,
   169             @doStepSeduction,
   166             @doStepSeduction,
   170             @doStepWatermelon,
   167             @doStepWatermelon,
   171             @doStepCluster,
   168             @doStepCluster,
   172             @doStepBomb,
   169             @doStepBomb,
   173             @doStepSmokeTrace,
       
   174             @doStepWaterUp,
   170             @doStepWaterUp,
   175             @doStepDrill,
   171             @doStepDrill,
   176             @doStepBallgun,
   172             @doStepBallgun,
   177             @doStepBomb,
   173             @doStepBomb,
   178             @doStepRCPlane,
   174             @doStepRCPlane,
   179             @doStepSniperRifleShot,
   175             @doStepSniperRifleShot,
   180             @doStepJetpack,
   176             @doStepJetpack,
   181             @doStepMolotov,
   177             @doStepMolotov,
   182             @doStepCase,
   178             @doStepCase,
   183             @doStepBirdy,
   179             @doStepBirdy,
   184             @doStepBigExplosion,
       
   185             @doStepEggWork,
   180             @doStepEggWork,
   186             @doStepPortalShot,
   181             @doStepPortalShot,
   187             @doStepPiano,
   182             @doStepPiano,
   188             @doStepBomb,
   183             @doStepBomb,
   189             @doStepSineGunShot
   184             @doStepSineGunShot
   289                 gear^.Z:= cHHZ;
   284                 gear^.Z:= cHHZ;
   290                 end;
   285                 end;
   291 gtAmmo_Grenade: begin // bazooka
   286 gtAmmo_Grenade: begin // bazooka
   292                 gear^.Radius:= 4;
   287                 gear^.Radius:= 4;
   293                 end;
   288                 end;
   294    gtHealthTag: begin
       
   295                 gear^.Timer:= 1500;
       
   296                 gear^.Z:= 2002;
       
   297                 end;
       
   298        gtGrave: begin
   289        gtGrave: begin
   299                 gear^.ImpactSound:= sndGraveImpact;
   290                 gear^.ImpactSound:= sndGraveImpact;
   300                 gear^.nImpactSounds:= 1;
   291                 gear^.nImpactSounds:= 1;
   301                 gear^.Radius:= 10;
   292                 gear^.Radius:= 10;
   302                 gear^.Elasticity:= _0_6;
   293                 gear^.Elasticity:= _0_6;
   313                 gear^.Radius:= 2
   304                 gear^.Radius:= 2
   314                 end;
   305                 end;
   315   gtPickHammer: begin
   306   gtPickHammer: begin
   316                 gear^.Radius:= 10;
   307                 gear^.Radius:= 10;
   317                 gear^.Timer:= 4000
   308                 gear^.Timer:= 4000
   318                 end;
       
   319   gtSmokeTrace,
       
   320    gtEvilTrace: begin
       
   321                 gear^.X:= gear^.X - _16;
       
   322                 gear^.Y:= gear^.Y - _16;
       
   323                 gear^.State:= 8;
       
   324                 gear^.Z:= cSmokeZ
       
   325                 end;
   309                 end;
   326         gtRope: begin
   310         gtRope: begin
   327                 gear^.Radius:= 3;
   311                 gear^.Radius:= 3;
   328                 gear^.Friction:= _450;
   312                 gear^.Friction:= _450;
   329                 RopePoints.Count:= 0;
   313                 RopePoints.Count:= 0;
   462                 gear^.Radius:= 16; // todo: check
   446                 gear^.Radius:= 16; // todo: check
   463                 gear^.Timer:= 0;
   447                 gear^.Timer:= 0;
   464                 gear^.Health := 2000;
   448                 gear^.Health := 2000;
   465                 gear^.FlightTime := 2;
   449                 gear^.FlightTime := 2;
   466                 end;
   450                 end;
   467 gtBigExplosion: begin
       
   468                 gear^.Angle:= random(360);
       
   469                 end;
       
   470          gtEgg: begin 
   451          gtEgg: begin 
   471                 gear^.Radius:= 4;
   452                 gear^.Radius:= 4;
   472                 gear^.Elasticity:= _0_6;
   453                 gear^.Elasticity:= _0_6;
   473                 gear^.Friction:= _0_96;
   454                 gear^.Friction:= _0_96;
   474                 if gear^.Timer = 0 then gear^.Timer:= 3000
   455                 if gear^.Timer = 0 then gear^.Timer:= 3000
   531         if (hwRound(Gear^.Y) >= cWaterLine) then
   512         if (hwRound(Gear^.Y) >= cWaterLine) then
   532             begin
   513             begin
   533             t:= max(Gear^.Damage, Gear^.Health);
   514             t:= max(Gear^.Damage, Gear^.Health);
   534             Gear^.Damage:= t;
   515             Gear^.Damage:= t;
   535             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   516             if (cWaterOpacity < $FF) and (hwRound(Gear^.Y) < cWaterLine + 256) then
   536                 AddGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), gtHealthTag, t, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   517                 AddVisualGear(hwRound(Gear^.X), min(hwRound(Gear^.Y),cWaterLine+cVisibleWater+32), vgtHealthTag, t)^.Hedgehog:= Gear^.Hedgehog;
   537             uStats.HedgehogDamaged(Gear)
   518             uStats.HedgehogDamaged(Gear)
   538             end;
   519             end;
   539 
   520 
   540         team:= PHedgehog(Gear^.Hedgehog)^.Team;
   521         team:= PHedgehog(Gear^.Hedgehog)^.Team;
   541         if CurrentHedgehog^.Gear = Gear then
   522         if CurrentHedgehog^.Gear = Gear then
   592                 not PHedgehog(Gear^.Hedgehog)^.King and
   573                 not PHedgehog(Gear^.Hedgehog)^.King and
   593                 not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and
   574                 not PHedgehog(Gear^.Hedgehog)^.Effects[hePoisoned] and
   594                 not SuddenDeathDmg then
   575                 not SuddenDeathDmg then
   595                 Gear^.State:= Gear^.State or gstLoser;
   576                 Gear^.State:= Gear^.State or gstLoser;
   596 
   577 
   597             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
   578             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
   598                     gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   579                     vgtHealthTag, dmg)^.Hedgehog:= Gear^.Hedgehog;
   599 
   580 
   600             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   581             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   601             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   582             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   602 
   583 
   603             end;
   584             end;
   913         if ((GameFlags and gfKarma) <> 0) and
   894         if ((GameFlags and gfKarma) <> 0) and
   914            ((GameFlags and gfInvulnerable) = 0) and
   895            ((GameFlags and gfInvulnerable) = 0) and
   915            not CurrentHedgehog^.Gear^.Invulnerable then
   896            not CurrentHedgehog^.Gear^.Invulnerable then
   916            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   897            begin // this cannot just use Damage or it interrupts shotgun and gets you called stupid
   917            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   898            inc(CurrentHedgehog^.Gear^.Karma, tmpDmg);
   918            AddGear(hwRound(CurrentHedgehog^.Gear^.X),
   899            AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X),
   919                    hwRound(CurrentHedgehog^.Gear^.Y),
   900                    hwRound(CurrentHedgehog^.Gear^.Y),
   920                    gtHealthTag, tmpDmg, _0, _0, 0)^.Hedgehog:= CurrentHedgehog;
   901                    vgtHealthTag, tmpDmg)^.Hedgehog:= CurrentHedgehog;
   921            end;
   902            end;
   922         end;
   903         end;
   923     end;
   904     end;
   924     inc(Gear^.Damage, Damage);
   905     inc(Gear^.Damage, Damage);
   925 end;
   906 end;
  1167 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1148 {$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
  1168 if Radius > 25 then KickFlakes(Radius, X, Y);
  1149 if Radius > 25 then KickFlakes(Radius, X, Y);
  1169 
  1150 
  1170 if ((Mask and EXPLNoGfx) = 0) then
  1151 if ((Mask and EXPLNoGfx) = 0) then
  1171     begin
  1152     begin
  1172     if Radius > 50 then AddGear(X, Y, gtBigExplosion, 0, _0, _0, 0)
  1153     if Radius > 50 then AddVisualGear(X, Y, vgtBigExplosion)
  1173     else if Radius > 10 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
  1154     else if Radius > 10 then AddVIsualGear(X, Y, vgtExplosion);
  1174     end;
  1155     end;
  1175 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
  1156 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
  1176 
  1157 
  1177 if (Mask and EXPLAllDamageInRadius) = 0 then
  1158 if (Mask and EXPLAllDamageInRadius) = 0 then
  1178     dmgRadius:= Radius shl 1
  1159     dmgRadius:= Radius shl 1