hedgewars/uGears.pas
changeset 2424 b52344de23ae
parent 2407 9f413bd5150e
child 2428 6800f8aa0184
equal deleted inserted replaced
2423:32213ae19ba9 2424:b52344de23ae
   328                 Result^.Radius:= 2;
   328                 Result^.Radius:= 2;
   329                 Result^.RenderTimer:= true
   329                 Result^.RenderTimer:= true
   330                 end;
   330                 end;
   331       gtShover: Result^.Radius:= 20;
   331       gtShover: Result^.Radius:= 20;
   332        gtFlame: begin
   332        gtFlame: begin
   333                 Result^.Tag:= Counter mod 32;
   333                 Result^.Tag:= GetRandom(32);
   334                 Result^.Radius:= 1;
   334                 Result^.Radius:= 1;
   335                 Result^.Health:= 5;
   335                 Result^.Health:= 5;
   336                 if (Result^.dY.QWordValue = 0) and (Result^.dX.QWordValue = 0) then
   336                 if (Result^.dY.QWordValue = 0) and (Result^.dX.QWordValue = 0) then
   337                 	begin
   337                 	begin
   338                 	Result^.dY:= (getrandom - _0_8) * _0_03;
   338                 	Result^.dY:= (getrandom - _0_8) * _0_03;
  1629 if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius)
  1629 if (GameFlags and gfSolidLand) = 0 then DrawExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), cShotgunRadius)
  1630 end;
  1630 end;
  1631 
  1631 
  1632 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
  1632 procedure AmmoShove(Ammo: PGear; Damage, Power: LongInt);
  1633 var t: PGearArray;
  1633 var t: PGearArray;
       
  1634     Gear: PGear;
  1634     i: LongInt;
  1635     i: LongInt;
  1635 begin
  1636 begin
  1636 t:= CheckGearsCollision(Ammo);
  1637 t:= CheckGearsCollision(Ammo);
  1637 i:= t^.Count;
  1638 i:= t^.Count;
  1638 
  1639 
  1639 Damage:= modifyDamage(Damage);
  1640 Damage:= modifyDamage(Damage);
  1640 
  1641 
  1641 while i > 0 do
  1642 while i > 0 do
  1642 	begin
  1643 	begin
  1643 	dec(i);
  1644 	dec(i);
  1644 	if (t^.ar[i]^.State and gstNoDamage) = 0 then
  1645     Gear:= t^.ar[i];
  1645 		case t^.ar[i]^.Kind of
  1646     if (Gear^.State and gstNoDamage) = 0 then
       
  1647         case Gear^.Kind of
  1646 			gtHedgehog,
  1648 			gtHedgehog,
  1647 			gtMine,
  1649 			gtMine,
  1648 			gtTarget,
  1650 			gtTarget,
  1649 			gtCase: begin
  1651 			gtCase: begin
  1650 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1652 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1651                     if (not t^.ar[i]^.Invulnerable) then
  1653                     if (Ammo^.Kind = gtFlame) then Ammo^.Health:= 0;
  1652                         ApplyDamage(t^.ar[i], Damage)
  1654                     if (not Gear^.Invulnerable) then
       
  1655                         ApplyDamage(Gear, Damage)
  1653                     else
  1656                     else
  1654                         t^.ar[i]^.State:= t^.ar[i]^.State or gstWinner;
  1657                         Gear^.State:= Gear^.State or gstWinner;
  1655 
  1658 
  1656 					DeleteCI(t^.ar[i]);
  1659 					DeleteCI(Gear);
  1657 					t^.ar[i]^.dX:= Ammo^.dX * Power * _0_01;
  1660 					Gear^.dX:= Ammo^.dX * Power * _0_01;
  1658 					t^.ar[i]^.dY:= Ammo^.dY * Power * _0_01;
  1661 					Gear^.dY:= Ammo^.dY * Power * _0_01;
  1659 					t^.ar[i]^.Active:= true;
  1662 					Gear^.Active:= true;
  1660 					t^.ar[i]^.State:= t^.ar[i]^.State or gstMoving;
  1663 					Gear^.State:= Gear^.State or gstMoving;
  1661 
  1664 
  1662 					if TestCollisionXwithGear(t^.ar[i], hwSign(t^.ar[i]^.dX)) then
  1665 					if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
  1663 						begin
  1666 						begin
  1664 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -3, hwSign(t^.ar[i]^.dX))
  1667 						if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
  1665 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1668 							or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
  1666 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -2, hwSign(t^.ar[i]^.dX))
  1669 						if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
  1667 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1670 							or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
  1668 						if not (TestCollisionXwithXYShift(t^.ar[i], _0, -1, hwSign(t^.ar[i]^.dX))
  1671 						if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
  1669 							or TestCollisionYwithGear(t^.ar[i], -1)) then t^.ar[i]^.Y:= t^.ar[i]^.Y - _1;
  1672 							or TestCollisionYwithGear(Gear, -1)) then Gear^.Y:= Gear^.Y - _1;
  1670 						end;
  1673 						end;
  1671 
  1674 					
  1672 					FollowGear:= t^.ar[i]
  1675 					FollowGear:= Gear
  1673 					end;
  1676 					end;
  1674 		end
  1677 		end
  1675 	end;
  1678 	end;
  1676 SetAllToActive
  1679 if i <> 0 then SetAllToActive
  1677 end;
  1680 end;
  1678 
  1681 
  1679 procedure AssignHHCoords;
  1682 procedure AssignHHCoords;
  1680 var i, t, p, j: LongInt;
  1683 var i, t, p, j: LongInt;
  1681 	ar: array[0..Pred(cMaxHHs)] of PHedgehog;
  1684 	ar: array[0..Pred(cMaxHHs)] of PHedgehog;