hedgewars/uGears.pas
changeset 3100 5fe9c4ac4c99
parent 3098 e5a1bc4e56fd
child 3102 3435cdc1e557
equal deleted inserted replaced
3099:cc13b42ab593 3100:5fe9c4ac4c99
   578 var Gear: PGear;
   578 var Gear: PGear;
   579     team: PTeam;
   579     team: PTeam;
   580        i: LongWord;
   580        i: LongWord;
   581     flag: Boolean;
   581     flag: Boolean;
   582 begin
   582 begin
   583 Gear:= GearsList;
   583 	Gear:= GearsList;
   584 
   584 
   585 while Gear <> nil do
   585 	while Gear <> nil do
   586     begin
   586 	begin
   587     if Gear^.Kind = gtHedgehog then
   587 		if Gear^.Kind = gtHedgehog then
   588         begin
   588 			begin
   589         inc(Gear^.Damage, min(cHealthDecrease, max(0,Gear^.Health - 1 - Gear^.Damage)));
   589         if PHedgehog(Gear^.Hedgehog)^.Poisoned then
   590         if PHedgehog(Gear^.Hedgehog)^.King then
   590           inc(Gear^.Damage, min(5, max(0,Gear^.Health - 1 - Gear^.Damage)));
   591             begin
   591 				inc(Gear^.Damage, min(cHealthDecrease, max(0,Gear^.Health - 1 - Gear^.Damage)));
   592             flag:= false;
   592 				if PHedgehog(Gear^.Hedgehog)^.King then
   593             team:= PHedgehog(Gear^.Hedgehog)^.Team;
   593 				begin
   594             for i:= 0 to Pred(team^.HedgehogsNumber) do
   594 					flag:= false;
   595                 if (team^.Hedgehogs[i].Gear <> nil) and 
   595 					team:= PHedgehog(Gear^.Hedgehog)^.Team;
   596                    (not team^.Hedgehogs[i].King) and 
   596 					for i:= 0 to Pred(team^.HedgehogsNumber) do
   597                    (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) then flag:= true;
   597 						if (team^.Hedgehogs[i].Gear <> nil) and 
   598             if not flag then inc(Gear^.Damage, min(5, max(0,Gear^.Health - 1 - Gear^.Damage)))
   598 							(not team^.Hedgehogs[i].King) and 
   599             end
   599 							(team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) 
   600         end;
   600 						then begin
   601 
   601 								flag:= true;
   602     Gear:= Gear^.NextGear
   602 						end;
   603     end;
   603 					if not flag then inc(Gear^.Damage, min(5, max(0,Gear^.Health - 1 - Gear^.Damage)))
       
   604 				end;
       
   605 			end;
       
   606 
       
   607 		Gear:= Gear^.NextGear
       
   608 	end;
   604 end;
   609 end;
   605 
   610 
   606 procedure ProcessGears;
   611 procedure ProcessGears;
   607 const delay: LongWord = 0;
   612 const delay: LongWord = 0;
   608     step: (stDelay, stChDmg, stSweep, stTurnReact,
   613     step: (stDelay, stChDmg, stSweep, stTurnReact,
  1813                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1818                                 Gear^.State:= (Gear^.State or gstMoving) and (not gstLoser);
  1814                                 if not Gear^.Invulnerable then
  1819                                 if not Gear^.Invulnerable then
  1815                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1820                                     Gear^.State:= (Gear^.State or gstMoving) and (not gstWinner);
  1816                                 Gear^.Active:= true;
  1821                                 Gear^.Active:= true;
  1817                                 FollowGear:= Gear
  1822                                 FollowGear:= Gear
  1818                                 end
  1823 														end;
  1819                             end
  1824 
       
  1825 													if ((Mask and EXPLPoisoned) <> 0) and (Gear^.Kind = gtHedgehog) then
       
  1826 														PHedgehog(Gear^.Hedgehog)^.Poisoned := true;
       
  1827 							end;
       
  1828 
  1820                         end;
  1829                         end;
  1821                 gtGrave: begin
  1830                 gtGrave: begin
  1822 // Run the calcs only once we know we have a type that will need damage
  1831 // Run the calcs only once we know we have a type that will need damage
  1823                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
  1832                         if hwRound(hwAbs(Gear^.X-int2hwFloat(X))+hwAbs(Gear^.Y-int2hwFloat(Y))) < dmgBase then
  1824                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1833                             dmg:= dmgBase - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));