hedgewars/uGears.pas
changeset 506 0889d833d47e
parent 505 fcba7d7aea0d
child 509 fd58135a4407
equal deleted inserted replaced
505:fcba7d7aea0d 506:0889d833d47e
    89 procedure SpawnBoxOfSmth; forward;
    89 procedure SpawnBoxOfSmth; forward;
    90 procedure AfterAttack; forward;
    90 procedure AfterAttack; forward;
    91 procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); forward;
    91 procedure FindPlace(Gear: PGear; withFall: boolean; Left, Right: LongInt); forward;
    92 procedure HedgehogStep(Gear: PGear); forward;
    92 procedure HedgehogStep(Gear: PGear); forward;
    93 procedure HedgehogChAngle(Gear: PGear); forward;
    93 procedure HedgehogChAngle(Gear: PGear); forward;
       
    94 procedure ShotgunShot(Gear: PGear); forward;
    94 
    95 
    95 {$INCLUDE GSHandlers.inc}
    96 {$INCLUDE GSHandlers.inc}
    96 {$INCLUDE HHHandlers.inc}
    97 {$INCLUDE HHHandlers.inc}
    97 
    98 
    98 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
    99 const doStepHandlers: array[TGearType] of TGearStepProcedure = (
   649     end
   650     end
   650 end;
   651 end;
   651 
   652 
   652 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
   653 procedure doMakeExplosion(X, Y, Radius: LongInt; Mask: LongWord);
   653 var Gear: PGear;
   654 var Gear: PGear;
   654     dmg: LongInt;
   655     dmg, dmgRadius: LongInt;
   655 begin
   656 begin
   656 TargetPoint.X:= NoPointX;
   657 TargetPoint.X:= NoPointX;
   657 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
   658 {$IFDEF DEBUGFILE}if Radius > 3 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
   658 if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius);
       
   659 if Radius = 50 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
   659 if Radius = 50 then AddGear(X, Y, gtExplosion, 0, _0, _0, 0);
   660 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false);
   660 if (Mask and EXPLAutoSound) <> 0 then PlaySound(sndExplosion, false);
   661 if (Mask and EXPLAllDamageInRadius)=0 then Radius:= Radius shl 1;
   661 if (Mask and EXPLAllDamageInRadius)=0 then dmgRadius:= Radius shl 1
       
   662                                       else dmgRadius:= Radius;
   662 Gear:= GearsList;
   663 Gear:= GearsList;
   663 while Gear <> nil do
   664 while Gear <> nil do
   664       begin
   665       begin
   665       dmg:= Radius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
   666       dmg:= dmgRadius - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
   666       if dmg > 0 then
   667       if dmg > 0 then
   667          begin
   668          begin
   668          dmg:= dmg div 2;
   669          dmg:= dmg div 2;
   669          case Gear^.Kind of
   670          case Gear^.Kind of
   670               gtHedgehog,
   671               gtHedgehog,
   673                  gtFlame: begin
   674                  gtFlame: begin
   674                           {$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
   675                           {$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
   675                           if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg);
   676                           if (Mask and EXPLNoDamage) = 0 then inc(Gear^.Damage, dmg);
   676                           if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
   677                           if ((Mask and EXPLDoNotTouchHH) = 0) or (Gear^.Kind <> gtHedgehog) then
   677                              begin
   678                              begin
       
   679                              DeleteCI(Gear);
   678                              Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
   680                              Gear^.dX:= Gear^.dX + SignAs(_0_005 * dmg + cHHKick, Gear^.X - int2hwFloat(X));
   679                              Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
   681                              Gear^.dY:= Gear^.dY + SignAs(_0_005 * dmg + cHHKick, Gear^.Y - int2hwFloat(Y));
   680                              Gear^.State:= Gear^.State or gstMoving;
   682                              Gear^.State:= Gear^.State or gstMoving;
   681                              Gear^.Active:= true;
   683                              Gear^.Active:= true;
   682                              FollowGear:= Gear
   684                              FollowGear:= Gear
   688                           end;
   690                           end;
   689               end;
   691               end;
   690          end;
   692          end;
   691       Gear:= Gear^.NextGear
   693       Gear:= Gear^.NextGear
   692       end;
   694       end;
       
   695 if (Mask and EXPLDontDraw) = 0 then DrawExplosion(X, Y, Radius);
   693 uAIMisc.AwareOfExplosion(0, 0, 0)
   696 uAIMisc.AwareOfExplosion(0, 0, 0)
       
   697 end;
       
   698 
       
   699 procedure ShotgunShot(Gear: PGear);
       
   700 var t: PGear;
       
   701     dmg: integer;
       
   702 begin
       
   703 Gear^.Radius:= 22;
       
   704 t:= GearsList;
       
   705 while t <> nil do
       
   706     begin
       
   707     dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25);
       
   708     if dmg >= 0 then
       
   709        case t^.Kind of
       
   710            gtHedgehog,
       
   711                gtMine,
       
   712                gtCase: begin
       
   713                        inc(t^.Damage, dmg);
       
   714                        DeleteCI(t);
       
   715                        t^.dX:= t^.dX + SignAs(Gear^.dX * dmg * _0_01 + cHHKick, t^.X - Gear^.X);
       
   716                        t^.dY:= t^.dY + Gear^.dY * dmg * _0_01;
       
   717                        t^.State:= t^.State or gstMoving;
       
   718                        t^.Active:= true;
       
   719                        FollowGear:= t
       
   720                        end;
       
   721               gtGrave: begin
       
   722                        t^.dY:= - _0_1;
       
   723                        t^.Active:= true
       
   724                        end;
       
   725            end;
       
   726     t:= t^.NextGear
       
   727     end;
       
   728 DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 22)
   694 end;
   729 end;
   695 
   730 
   696 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
   731 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
   697 var t: PGearArray;
   732 var t: PGearArray;
   698     i: LongInt;
   733     i: LongInt;