hedgewars/uGears.pas
changeset 1861 98de5dc5fda7
parent 1854 6e05013899b2
child 1863 705c01571196
equal deleted inserted replaced
1860:ce140b2b928a 1861:98de5dc5fda7
   428 CheckNoDamage:= true;
   428 CheckNoDamage:= true;
   429 Gear:= GearsList;
   429 Gear:= GearsList;
   430 while Gear <> nil do
   430 while Gear <> nil do
   431 	begin
   431 	begin
   432 	if Gear^.Kind = gtHedgehog then
   432 	if Gear^.Kind = gtHedgehog then
   433         begin
   433 		begin
   434 		if (Gear^.Damage <> 0) and
   434 		if (Gear^.Damage <> 0) and
   435 		(not Gear^.Invulnerable) then
   435 		(not Gear^.Invulnerable) then
   436 		    begin
   436 			begin
   437             CheckNoDamage:= false;
   437 			CheckNoDamage:= false;
   438             uStats.HedgehogDamaged(Gear);
   438 			uStats.HedgehogDamaged(Gear);
   439             dmg:= HwRound(int2HwFloat(Gear^.Damage) * cDamageModifier);
   439 			dmg:= Gear^.Damage;
   440             if Gear^.Health < dmg then
   440 			if Gear^.Health < dmg then
   441                 Gear^.Health:= 0
   441 				Gear^.Health:= 0
   442             else
   442 			else
   443                 dec(Gear^.Health, dmg);
   443 				dec(Gear^.Health, dmg);
   444 
   444 
   445             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
   445 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y) - cHHRadius - 12,
   446                     gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   446 					gtHealthTag, dmg, _0, _0, 0)^.Hedgehog:= Gear^.Hedgehog;
   447 
   447 
   448             RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   448 			RenderHealth(PHedgehog(Gear^.Hedgehog)^);
   449             RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   449 			RecountTeamHealth(PHedgehog(Gear^.Hedgehog)^.Team);
   450 
   450 
   451 		    end;
   451 			end;
   452 	    Gear^.Damage:= 0;
   452 		Gear^.Damage:= 0;
   453         end;
   453 		end;
   454 	Gear:= Gear^.NextGear
   454 	Gear:= Gear^.NextGear
   455 	end;
   455 	end;
   456 end;
   456 end;
   457 
   457 
   458 procedure HealthMachine;
   458 procedure HealthMachine;
  1042 							ty:= round(ly)
  1042 							ty:= round(ly)
  1043 							end;
  1043 							end;
  1044 						// reached edge of land. assume infinite beam. Extend it way out past camera
  1044 						// reached edge of land. assume infinite beam. Extend it way out past camera
  1045 						if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
  1045 						if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then
  1046 							begin
  1046 							begin
  1047 							lx:= lx + dx * (LAND_WIDTH div 4);
  1047 							tx:= round(lx + dx * (LAND_WIDTH div 4));
  1048 							ly:= ly + dy * (LAND_WIDTH div 4)
  1048 							ty:= round(ly + dy * (LAND_WIDTH div 4));
  1049 							end;
  1049 							end;
  1050 						
  1050 						
  1051 						//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
  1051 						//if (abs(lx-tx)>8) or (abs(ly-ty)>8) then
  1052 							begin
  1052 							begin
  1053 							glDisable(GL_TEXTURE_2D);
  1053 							glDisable(GL_TEXTURE_2D);
  1206                          posCaseHealth: begin
  1206                          posCaseHealth: begin
  1207                                         i:= (GameTicks shr 6) mod 64;
  1207                                         i:= (GameTicks shr 6) mod 64;
  1208                                         if i > 12 then i:= 0;
  1208                                         if i > 12 then i:= 0;
  1209                                         DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
  1209                                         DrawSprite(sprFAid, hwRound(Gear^.X) - 24 + WorldDx, hwRound(Gear^.Y) - 24 + WorldDy, i);
  1210                                         end;
  1210                                         end;
       
  1211                          posCaseUtility: begin
       
  1212                                         DrawSprite(sprUtility, hwRound(Gear^.X) - 20 + WorldDx, hwRound(Gear^.Y) - 16 + WorldDy, 0);
       
  1213                                         end;
  1211                          end;
  1214                          end;
  1212         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1215         gtDynamite: DrawSprite2(sprDynamite, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 25 + WorldDy, Gear^.Tag and 1, Gear^.Tag shr 1);
  1213      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1216      gtClusterBomb: DrawRotated(sprClusterBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1214          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1217          gtCluster: DrawSprite(sprClusterParticle, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, 0);
  1215            gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8);
  1218            gtFlame: DrawSprite(sprFlame, hwRound(Gear^.X) - 8 + WorldDx, hwRound(Gear^.Y) - 8 + WorldDy, (GameTicks div 128 + LongWord(Gear^.Tag)) mod 8);
  1285 	begin
  1288 	begin
  1286 	dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1289 	dmg:= dmgRadius  + cHHRadius div 2 - hwRound(Distance(Gear^.X - int2hwFloat(X), Gear^.Y - int2hwFloat(Y)));
  1287 	if (dmg > 1) and
  1290 	if (dmg > 1) and
  1288 		((Gear^.State and gstNoDamage) = 0) then
  1291 		((Gear^.State and gstNoDamage) = 0) then
  1289 		begin
  1292 		begin
  1290 		dmg:= min(dmg div 2, Radius);
  1293 		dmg:= modifyDamage(min(dmg div 2, Radius));
  1291 		case Gear^.Kind of
  1294 		case Gear^.Kind of
  1292 			gtHedgehog,
  1295 			gtHedgehog,
  1293 				gtMine,
  1296 				gtMine,
  1294 				gtCase,
  1297 				gtCase,
  1295 				gtTarget,
  1298 				gtTarget,
  1335 begin
  1338 begin
  1336 Gear^.Radius:= cShotgunRadius;
  1339 Gear^.Radius:= cShotgunRadius;
  1337 t:= GearsList;
  1340 t:= GearsList;
  1338 while t <> nil do
  1341 while t <> nil do
  1339 	begin
  1342 	begin
  1340 	dmg:= min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25);
  1343 	dmg:= modifyDamage(min(Gear^.Radius + t^.Radius - hwRound(Distance(Gear^.X - t^.X, Gear^.Y - t^.Y)), 25));
  1341 	if dmg > 0 then
  1344 	if dmg > 0 then
  1342 	case t^.Kind of
  1345 	case t^.Kind of
  1343 		gtHedgehog,
  1346 		gtHedgehog,
  1344 			gtMine,
  1347 			gtMine,
  1345 			gtCase,
  1348 			gtCase,
  1372 var t: PGearArray;
  1375 var t: PGearArray;
  1373     i: LongInt;
  1376     i: LongInt;
  1374 begin
  1377 begin
  1375 t:= CheckGearsCollision(Ammo);
  1378 t:= CheckGearsCollision(Ammo);
  1376 i:= t^.Count;
  1379 i:= t^.Count;
       
  1380 
       
  1381 Damage:= modifyDamage(Damage);
  1377 
  1382 
  1378 while i > 0 do
  1383 while i > 0 do
  1379 	begin
  1384 	begin
  1380 	dec(i);
  1385 	dec(i);
  1381 	if (t^.ar[i]^.State and gstNoDamage) = 0 then
  1386 	if (t^.ar[i]^.State and gstNoDamage) = 0 then
  1551 if (cCaseFactor = 0) or
  1556 if (cCaseFactor = 0) or
  1552    (CountGears(gtCase) >= 5) or
  1557    (CountGears(gtCase) >= 5) or
  1553    (getrandom(cCaseFactor) <> 0) then exit;
  1558    (getrandom(cCaseFactor) <> 0) then exit;
  1554 
  1559 
  1555 FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
  1560 FollowGear:= AddGear(0, 0, gtCase, 0, _0, _0, 0);
  1556 case getrandom(2) of
  1561 case getrandom(20) of
  1557      0: begin
  1562      0..6: begin
  1558         FollowGear^.Health:= 25;
  1563         FollowGear^.Health:= 25;
  1559         FollowGear^.Pos:= posCaseHealth
  1564         FollowGear^.Pos:= posCaseHealth
  1560         end;
  1565         end;
  1561      1: begin
  1566      7..13: begin
  1562         t:= 0;
  1567         t:= 0;
  1563         for i:= Low(TAmmoType) to High(TAmmoType) do
  1568         for i:= Low(TAmmoType) to High(TAmmoType) do
  1564             inc(t, Ammoz[i].Probability);
  1569             if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
       
  1570                 inc(t, Ammoz[i].Probability);
  1565         t:= GetRandom(t);
  1571         t:= GetRandom(t);
  1566         i:= Low(TAmmoType);
  1572         i:= Low(TAmmoType);
  1567         dec(t, Ammoz[i].Probability);
  1573         if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
       
  1574             dec(t, Ammoz[i].Probability);
  1568         while t >= 0 do
  1575         while t >= 0 do
  1569           begin
  1576           begin
  1570           inc(i);
  1577           inc(i);
  1571           dec(t, Ammoz[i].Probability)
  1578           if (Ammoz[i].Ammo.Propz and ammoprop_Utility) = 0 then
       
  1579               dec(t, Ammoz[i].Probability)
  1572           end;
  1580           end;
  1573         PlaySound(sndReinforce, false, CurrentTeam^.voicepack);
  1581         PlaySound(sndReinforce, false, CurrentTeam^.voicepack);
  1574         FollowGear^.Pos:= posCaseAmmo;
  1582         FollowGear^.Pos:= posCaseAmmo;
       
  1583         FollowGear^.State:= Longword(i)
       
  1584         end;
       
  1585      14..19: begin 
       
  1586         t:= 0;
       
  1587         for i:= Low(TAmmoType) to High(TAmmoType) do
       
  1588             if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
       
  1589                 inc(t, Ammoz[i].Probability);
       
  1590         t:= GetRandom(t);
       
  1591         i:= Low(TAmmoType);
       
  1592         if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
       
  1593             dec(t, Ammoz[i].Probability);
       
  1594         while t >= 0 do
       
  1595           begin
       
  1596           inc(i);
       
  1597           if (Ammoz[i].Ammo.Propz and ammoprop_Utility) <> 0 then
       
  1598               dec(t, Ammoz[i].Probability)
       
  1599           end;
       
  1600         PlaySound(sndReinforce, false, CurrentTeam^.voicepack);
       
  1601         FollowGear^.Pos:= posCaseUtility;
  1575         FollowGear^.State:= Longword(i)
  1602         FollowGear^.State:= Longword(i)
  1576         end;
  1603         end;
  1577      end;
  1604      end;
  1578  
  1605  
  1579 FindPlace(FollowGear, true, 0, LAND_WIDTH)
  1606 FindPlace(FollowGear, true, 0, LAND_WIDTH)