hedgewars/uGearsList.pas
branchwebgl
changeset 8330 aaefa587e277
parent 8026 4a4f21070479
parent 8161 0b8beacff8a5
child 8833 c13ebed437cb
equal deleted inserted replaced
8116:d24257910f8d 8330:aaefa587e277
    33 
    33 
    34 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
    34 uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
    35     uTextures, uScript, uRenderUtils, uAI, uCollisions,
    35     uTextures, uScript, uRenderUtils, uAI, uCollisions,
    36     uGearsRender, uGearsUtils, uDebug;
    36     uGearsRender, uGearsUtils, uDebug;
    37 
    37 
       
    38 const
       
    39     GearKindAmmoTypeMap : array [TGearType] of TAmmoType = (
       
    40 (*          gtFlame *)   amNothing
       
    41 (*       gtHedgehog *) , amNothing
       
    42 (*           gtMine *) , amMine
       
    43 (*           gtCase *) , amNothing
       
    44 (*     gtExplosives *) , amNothing
       
    45 (*        gtGrenade *) , amGrenade
       
    46 (*          gtShell *) , amBazooka
       
    47 (*          gtGrave *) , amNothing
       
    48 (*            gtBee *) , amBee
       
    49 (*    gtShotgunShot *) , amShotgun
       
    50 (*     gtPickHammer *) , amPickHammer
       
    51 (*           gtRope *) , amRope
       
    52 (*     gtDEagleShot *) , amDEagle
       
    53 (*       gtDynamite *) , amDynamite
       
    54 (*    gtClusterBomb *) , amClusterBomb
       
    55 (*        gtCluster *) , amClusterBomb
       
    56 (*         gtShover *) , amBaseballBat  // Shover is only used for baseball bat right now
       
    57 (*      gtFirePunch *) , amFirePunch
       
    58 (*    gtATStartGame *) , amNothing
       
    59 (*   gtATFinishGame *) , amNothing
       
    60 (*      gtParachute *) , amParachute
       
    61 (*      gtAirAttack *) , amAirAttack
       
    62 (*        gtAirBomb *) , amAirAttack
       
    63 (*      gtBlowTorch *) , amBlowTorch
       
    64 (*         gtGirder *) , amGirder
       
    65 (*       gtTeleport *) , amTeleport
       
    66 (*       gtSwitcher *) , amSwitch
       
    67 (*         gtTarget *) , amNothing
       
    68 (*         gtMortar *) , amMortar
       
    69 (*           gtWhip *) , amWhip
       
    70 (*       gtKamikaze *) , amKamikaze
       
    71 (*           gtCake *) , amCake
       
    72 (*      gtSeduction *) , amSeduction
       
    73 (*     gtWatermelon *) , amWatermelon
       
    74 (*     gtMelonPiece *) , amWatermelon
       
    75 (*    gtHellishBomb *) , amHellishBomb
       
    76 (*        gtWaterUp *) , amNothing
       
    77 (*          gtDrill *) , amDrill
       
    78 (*        gtBallGun *) , amBallgun
       
    79 (*           gtBall *) , amBallgun
       
    80 (*        gtRCPlane *) , amRCPlane
       
    81 (*gtSniperRifleShot *) , amSniperRifle
       
    82 (*        gtJetpack *) , amJetpack
       
    83 (*        gtMolotov *) , amMolotov
       
    84 (*          gtBirdy *) , amBirdy
       
    85 (*            gtEgg *) , amBirdy
       
    86 (*         gtPortal *) , amPortalGun
       
    87 (*          gtPiano *) , amPiano
       
    88 (*        gtGasBomb *) , amGasBomb
       
    89 (*    gtSineGunShot *) , amSineGun
       
    90 (*   gtFlamethrower *) , amFlamethrower
       
    91 (*          gtSMine *) , amSMine
       
    92 (*    gtPoisonCloud *) , amNothing
       
    93 (*         gtHammer *) , amHammer
       
    94 (*      gtHammerHit *) , amHammer
       
    95 (*    gtResurrector *) , amResurrector
       
    96 (*    gtPoisonCloud *) , amNothing
       
    97 (*       gtSnowball *) , amSnowball
       
    98 (*          gtFlake *) , amNothing
       
    99 //(*      gtStructure *) , amStructure  // TODO - This will undoubtedly change once there is more than one structure
       
   100 (*        gtLandGun *) , amLandGun
       
   101 (*         gtTardis *) , amTardis
       
   102 (*         gtIceGun *) , amIceGun
       
   103 (*        gtAddAmmo *) , amNothing
       
   104 (*  gtGenericFaller *) , amNothing
       
   105 (*          gtKnife *) , amKnife
       
   106     );
       
   107 
       
   108 
    38 var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
   109 var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
       
   110 
       
   111 const
       
   112     cUsualZ = 500;
       
   113     cOnHHZ = 2000;
    39 
   114 
    40 procedure InsertGearToList(Gear: PGear);
   115 procedure InsertGearToList(Gear: PGear);
    41 var tmp, ptmp: PGear;
   116 var tmp, ptmp: PGear;
    42 begin
   117 begin
    43     tmp:= GearsList;
   118     tmp:= GearsList;
    84 begin
   159 begin
    85 inc(GCounter);
   160 inc(GCounter);
    86 
   161 
    87 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
   162 AddFileLog('AddGear: #' + inttostr(GCounter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
    88 
   163 
    89    
   164 
    90 New(gear);
   165 New(gear);
    91 FillChar(gear^, sizeof(TGear), 0);
   166 FillChar(gear^, sizeof(TGear), 0);
    92 gear^.X:= int2hwFloat(X);
   167 gear^.X:= int2hwFloat(X);
    93 gear^.Y:= int2hwFloat(Y);
   168 gear^.Y:= int2hwFloat(Y);
    94 gear^.Target.X:= NoPointX;
   169 gear^.Target.X:= NoPointX;
   106 gear^.Density:= _1;
   181 gear^.Density:= _1;
   107 // Define ammo association, if any.
   182 // Define ammo association, if any.
   108 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
   183 gear^.AmmoType:= GearKindAmmoTypeMap[Kind];
   109 gear^.CollisionMask:= $FFFF;
   184 gear^.CollisionMask:= $FFFF;
   110 
   185 
   111 if CurrentHedgehog <> nil then 
   186 if CurrentHedgehog <> nil then
   112     begin
   187     begin
   113     gear^.Hedgehog:= CurrentHedgehog;
   188     gear^.Hedgehog:= CurrentHedgehog;
   114     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
   189     if (CurrentHedgehog^.Gear <> nil) and (hwRound(CurrentHedgehog^.Gear^.X) = X) and (hwRound(CurrentHedgehog^.Gear^.Y) = Y) then
   115         gear^.CollisionMask:= $FF7F
   190         gear^.CollisionMask:= $FF7F
   116     end;
   191     end;
   117 
   192 
   118 if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
   193 if (Ammoz[Gear^.AmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
   119     gear^.Z:= cHHZ+1
   194     gear^.Z:= cHHZ+1
   120 else gear^.Z:= cUsualZ;
   195 else gear^.Z:= cUsualZ;
   121 
   196 
   122     
   197 
   123 case Kind of
   198 case Kind of
   124      gtGrenade,
   199      gtGrenade,
   125      gtClusterBomb,
   200      gtClusterBomb,
   126      gtGasBomb: begin
   201      gtGasBomb: begin
   127                 gear^.ImpactSound:= sndGrenadeImpact;
   202                 gear^.ImpactSound:= sndGrenadeImpact;
   461   gtNapalmBomb: begin
   536   gtNapalmBomb: begin
   462                 gear^.Timer:= 1000;
   537                 gear^.Timer:= 1000;
   463                 gear^.Radius:= 5;
   538                 gear^.Radius:= 5;
   464                 gear^.Density:= _1_5;
   539                 gear^.Density:= _1_5;
   465                 end;
   540                 end;
       
   541 {
   466    gtStructure: begin
   542    gtStructure: begin
   467                 gear^.Elasticity:= _0_55;
   543                 gear^.Elasticity:= _0_55;
   468                 gear^.Friction:= _0_995;
   544                 gear^.Friction:= _0_995;
   469                 gear^.Density:= _0_9;
   545                 gear^.Density:= _0_9;
   470                 gear^.Radius:= 13;
   546                 gear^.Radius:= 13;
   471                 gear^.Health:= 200;
   547                 gear^.Health:= 200;
   472                 gear^.Timer:= 0;
   548                 gear^.Timer:= 0;
   473                 gear^.Tag:= TotalRounds + 3;
   549                 gear^.Tag:= TotalRounds + 3;
   474                 gear^.Pos:= 1;
   550                 gear^.Pos:= 1;
   475                 end;
   551                 end;
       
   552 }
   476       gtIceGun: gear^.Health:= 1000;
   553       gtIceGun: gear^.Health:= 1000;
   477 gtGenericFaller:begin
   554 gtGenericFaller:begin
   478                 gear^.AdvBounce:= 1;
   555                 gear^.AdvBounce:= 1;
   479                 gear^.Radius:= 1;
   556                 gear^.Radius:= 1;
   480                 gear^.Elasticity:= _0_9;
   557                 gear^.Elasticity:= _0_9;
   568         inc(KilledHHs);
   645         inc(KilledHHs);
   569         RecountTeamHealth(team);
   646         RecountTeamHealth(team);
   570         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
   647         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0)  and
   571         //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
   648         //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
   572         (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
   649         (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
   573             with CurrentHedgehog^ do 
   650             with CurrentHedgehog^ do
   574                 begin
   651                 begin
   575                 inc(Team^.stats.AIKills);
   652                 inc(Team^.stats.AIKills);
   576                 FreeTexture(Team^.AIKillsTex);
   653                 FreeTexture(Team^.AIKillsTex);
   577                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   654                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
   578                 end
   655                 end