hedgewars/uGears.pas
changeset 6531 c938a35588af
parent 6530 dc6ce7eb556b
child 6543 697e9b730189
equal deleted inserted replaced
6530:dc6ce7eb556b 6531:c938a35588af
    37 
    37 
    38 procedure initModule;
    38 procedure initModule;
    39 procedure freeModule;
    39 procedure freeModule;
    40 function  SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
    40 function  SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content: Longword ): PGear;
    41 function  SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear;
    41 function  SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean ): PGear;
    42 <<<<<<< local
       
    43 function  GetAmmo: TAmmoType;
       
    44 function  GetUtility: TAmmoType;
       
    45 =======
       
    46 function  GetAmmo(Hedgehog: PHedgehog): TAmmoType;
    42 function  GetAmmo(Hedgehog: PHedgehog): TAmmoType;
    47 function  GetUtility(Hedgehog: PHedgehog): TAmmoType;
    43 function  GetUtility(Hedgehog: PHedgehog): TAmmoType;
    48 procedure ResurrectHedgehog(gear: PGear);
       
    49 >>>>>>> other
       
    50 procedure HideHog(HH: PHedgehog);
    44 procedure HideHog(HH: PHedgehog);
    51 procedure RestoreHog(HH: PHedgehog);
    45 procedure RestoreHog(HH: PHedgehog);
    52 procedure ProcessGears;
    46 procedure ProcessGears;
    53 procedure EndTurnCleanup;
    47 procedure EndTurnCleanup;
    54 procedure SetAllToActive;
    48 procedure SetAllToActive;
   661 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
   655 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
   662     for i:= 0 to Pred(vobCount*2) do
   656     for i:= 0 to Pred(vobCount*2) do
   663         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
   657         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
   664 end;
   658 end;
   665 
   659 
   666 procedure doMakeExplosion(X, Y, Radius: LongInt; AttackingHog: PHedgehog; Mask: Longword; const Tint: LongWord);
       
   667 var Gear: PGear;
       
   668     dmg, dmgRadius, dmgBase: LongInt;
       
   669     fX, fY: hwFloat;
       
   670     vg: PVisualGear;
       
   671     i, cnt: LongInt;
       
   672 begin
       
   673 if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
       
   674 if Radius > 25 then KickFlakes(Radius, X, Y);
       
   675 
       
   676 if ((Mask and EXPLNoGfx) = 0) then
       
   677     begin
       
   678     vg:= nil;
       
   679     if Radius > 50 then vg:= AddVisualGear(X, Y, vgtBigExplosion)
       
   680     else if Radius > 10 then vg:= AddVisualGear(X, Y, vgtExplosion);
       
   681     if vg <> nil then
       
   682         vg^.Tint:= Tint;
       
   683     end;
       
   684 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion);
       
   685 
       
   686 if (Mask and EXPLAllDamageInRadius) = 0 then
       
   687     dmgRadius:= Radius shl 1
       
   688 else
       
   689     dmgRadius:= Radius;
       
   690 dmgBase:= dmgRadius + cHHRadius div 2;
       
   691 fX:= int2hwFloat(X);
       
   692 fY:= int2hwFloat(Y);
       
   693 Gear:= GearsList;
       
   694 while Gear <> nil do
       
   695     begin
       
   696     dmg:= 0;
       
   697     //dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
       
   698     //if (dmg > 1) and
       
   699     if (Gear^.State and gstNoDamage) = 0 then
       
   700         begin
       
   701         case Gear^.Kind of
       
   702             gtHedgehog,
       
   703                 gtMine,
       
   704                 gtBall,
       
   705                 gtMelonPiece,
       
   706                 gtGrenade,
       
   707                 gtClusterBomb,
       
   708             //    gtCluster, too game breaking I think
       
   709                 gtSMine,
       
   710                 gtCase,
       
   711                 gtTarget,
       
   712                 gtFlame,
       
   713                 gtExplosives,
       
   714                 gtStructure: begin
       
   715 // Run the calcs only once we know we have a type that will need damage
       
   716                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
       
   717                             dmg:= dmgBase - max(hwRound(Distance(Gear^.X - fX, Gear^.Y - fY)),Gear^.Radius);
       
   718                         if dmg > 1 then
       
   719                             begin
       
   720                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
       
   721                             //AddFileLog('Damage: ' + inttostr(dmg));
       
   722                             if (Mask and EXPLNoDamage) = 0 then
       
   723                                 begin
       
   724                                 if not Gear^.Invulnerable then
       
   725                                     ApplyDamage(Gear, AttackingHog, dmg, dsExplosion)
       
   726                                 else
       
   727                                     Gear^.State:= Gear^.State or gstWinner;
       
   728                                 end;
       
   729                             if ((Mask and EXPLDoNotTouchAny) = 0) and (((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog)) then
       
   730                                 begin
       
   731                                 DeleteCI(Gear);
       
   732                                 Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - fX)/(Gear^.Density/_3);
       
   733                                 Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - fY)/(Gear^.Density/_3);
       
   734 
       
   735                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
       
   736                                 if not Gear^.Invulnerable then
       
   737                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
       
   738                                 Gear^.Active:= true;
       
   739                                 if Gear^.Kind <> gtFlame then FollowGear:= Gear
       
   740                                 end;
       
   741                             if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) and (not Gear^.Invulnerable) then
       
   742                                 Gear^.Hedgehog^.Effects[hePoisoned] := true;
       
   743                             end;
       
   744 
       
   745                         end;
       
   746                 gtGrave: begin
       
   747 // Run the calcs only once we know we have a type that will need damage
       
   748                         if hwRound(hwAbs(Gear^.X-fX)+hwAbs(Gear^.Y-fY)) < dmgBase then
       
   749                             dmg:= dmgBase - hwRound(Distance(Gear^.X - fX, Gear^.Y - fY));
       
   750                         if dmg > 1 then
       
   751                             begin
       
   752                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
       
   753                             Gear^.dY:= - _0_004 * dmg;
       
   754                             Gear^.Active:= true
       
   755                             end
       
   756                         end;
       
   757             end;
       
   758         end;
       
   759     Gear:= Gear^.NextGear
       
   760     end;
       
   761 
       
   762 if (Mask and EXPLDontDraw) = 0 then
       
   763     if (GameFlags and gfSolidLand) = 0 then
       
   764         begin
       
   765         cnt:= DrawExplosion(X, Y, Radius) div 1608; // approx 2 16x16 circles to erase per chunk
       
   766         if (cnt > 0) and (SpritesData[sprChunk].Texture <> nil) then
       
   767             for i:= 0 to cnt do
       
   768                 AddVisualGear(X, Y, vgtChunk)
       
   769         end;
       
   770 
       
   771 uAIMisc.AwareOfExplosion(0, 0, 0)
       
   772 end;
       
   773 
   660 
   774 procedure ShotgunShot(Gear: PGear);
   661 procedure ShotgunShot(Gear: PGear);
   775 var t: PGear;
   662 var t: PGear;
   776     dmg, r, dist: LongInt;
   663     dmg, r, dist: LongInt;
   777     dx, dy: hwFloat;
   664     dx, dy: hwFloat;
   899                         Gear^.dX:= Ammo^.dX * Power * _0_005;
   786                         Gear^.dX:= Ammo^.dX * Power * _0_005;
   900                         Gear^.dY:= Ammo^.dY * Power * _0_005
   787                         Gear^.dY:= Ammo^.dY * Power * _0_005
   901                         end
   788                         end
   902                     else
   789                     else
   903                         begin
   790                         begin
   904                         Gear^.dX:= (Ammo^.dX * Power * _0_01)/(Gear^.Density/_3);
   791                         Gear^.dX:= Ammo^.dX * Power * _0_01;
   905                         Gear^.dY:= (Ammo^.dY * Power * _0_01)/(Gear^.Density/_3);
   792                         Gear^.dY:= Ammo^.dY * Power * _0_01
   906                         end;
   793                         end;
   907 
   794 
   908                     Gear^.Active:= true;
   795                     Gear^.Active:= true;
   909                     Gear^.State:= Gear^.State or gstMoving;
   796                     Gear^.State:= Gear^.State or gstMoving;
   910 
   797