hedgewars/uGears.pas
changeset 2428 6800f8aa0184
parent 2424 b52344de23ae
child 2451 5affd0840927
equal deleted inserted replaced
2427:241e3bb6a146 2428:6800f8aa0184
    52 			Tag: LongInt;
    52 			Tag: LongInt;
    53 			Tex: PTexture;
    53 			Tex: PTexture;
    54 			Z: Longword;
    54 			Z: Longword;
    55 			IntersectGear: PGear;
    55 			IntersectGear: PGear;
    56 			TriggerId: Longword;
    56 			TriggerId: Longword;
       
    57 			FlightTime: Longword;
    57 			uid: Longword
    58 			uid: Longword
    58 			end;
    59 			end;
    59 
    60 
    60 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    61 function  AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
    61 procedure ProcessGears;
    62 procedure ProcessGears;
    74     GearsList: PGear = nil;
    75     GearsList: PGear = nil;
    75     KilledHHs: Longword = 0;
    76     KilledHHs: Longword = 0;
    76     SuddenDeathDmg: Boolean = false;
    77     SuddenDeathDmg: Boolean = false;
    77     SpeechType: Longword = 1;
    78     SpeechType: Longword = 1;
    78     SpeechText: shortstring;
    79     SpeechText: shortstring;
       
    80 	TrainingTargetGear: PGear = nil;
    79 
    81 
    80 implementation
    82 implementation
    81 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
    83 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
    82 	uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers,
    84 	uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI, uAmmos, uTriggers,
    83 {$IFDEF GLES11}
    85 {$IFDEF GLES11}
   222 Result^.dY:= dY;
   224 Result^.dY:= dY;
   223 Result^.doStep:= doStepHandlers[Kind];
   225 Result^.doStep:= doStepHandlers[Kind];
   224 Result^.CollisionIndex:= -1;
   226 Result^.CollisionIndex:= -1;
   225 Result^.Timer:= Timer;
   227 Result^.Timer:= Timer;
   226 Result^.Z:= cUsualZ;
   228 Result^.Z:= cUsualZ;
       
   229 Result^.FlightTime:= 0;
   227 Result^.uid:= Counter;
   230 Result^.uid:= Counter;
   228 
   231 
   229 if CurrentTeam <> nil then
   232 if CurrentTeam <> nil then
   230 	begin
   233 	begin
   231 	Result^.Hedgehog:= CurrentHedgehog;
   234 	Result^.Hedgehog:= CurrentHedgehog;
   695                   end;
   698                   end;
   696 end;
   699 end;
   697 
   700 
   698 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   701 procedure ApplyDamage(Gear: PGear; Damage: Longword);
   699 var s: shortstring;
   702 var s: shortstring;
   700     vampDmg, tmpDmg: Longword;
   703     vampDmg, tmpDmg, i: Longword;
       
   704 	vg: PVisualGear;
   701 begin
   705 begin
   702 	if (Gear^.Kind = gtHedgehog) and (Damage>=1) then
   706 	if (Gear^.Kind = gtHedgehog) and (Damage>=1) then
   703     begin
   707     begin
   704 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
   708 	AddDamageTag(hwRound(Gear^.X), hwRound(Gear^.Y), Damage, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color);
   705     tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
   709     tmpDmg:= min(Damage, max(0,Gear^.Health-Gear^.Damage));
   716                 str(vampDmg, s);
   720                 str(vampDmg, s);
   717                 s:= '+' + s;
   721                 s:= '+' + s;
   718                 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   722                 AddCaption(s, CurrentHedgehog^.Team^.Clan^.Color, capgrpAmmoinfo);
   719                 RenderHealth(CurrentHedgehog^);
   723                 RenderHealth(CurrentHedgehog^);
   720                 RecountTeamHealth(CurrentHedgehog^.Team);
   724                 RecountTeamHealth(CurrentHedgehog^.Team);
       
   725 				i:= 0;
       
   726 				while i < vampDmg do
       
   727 					begin
       
   728 					vg:= AddVisualGear(hwRound(CurrentHedgehog^.Gear^.X), hwRound(CurrentHedgehog^.Gear^.Y), vgtHealth);
       
   729 					if vg <> nil then vg^.Frame:= 10;
       
   730 					inc(i, 5);
       
   731 					end;
   721                 end
   732                 end
   722             end;
   733             end;
   723         if ((GameFlags and gfKarma) <> 0) and
   734         if ((GameFlags and gfKarma) <> 0) and
   724            ((GameFlags and gfInvulnerable) = 0) and
   735            ((GameFlags and gfInvulnerable) = 0) and
   725            not CurrentHedgehog^.Gear^.Invulnerable then
   736            not CurrentHedgehog^.Gear^.Invulnerable then
  1247 		end
  1258 		end
  1248 	end;
  1259 	end;
  1249 
  1260 
  1250 if Gear^.Invulnerable then
  1261 if Gear^.Invulnerable then
  1251     begin
  1262     begin
  1252     DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
  1263     glColor4f(1, 1, 1, 0.25 + abs(1 - ((RealTicks div 2) mod 1500) / 750));
       
  1264 	DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0);
       
  1265 	glColor4f(1, 1, 1, 1);
  1253     end;
  1266     end;
  1254 if cVampiric and
  1267 if cVampiric and
  1255    (CurrentHedgehog^.Gear <> nil) and
  1268    (CurrentHedgehog^.Gear <> nil) and
  1256    (CurrentHedgehog^.Gear = Gear) then
  1269    (CurrentHedgehog^.Gear = Gear) then
  1257     begin
  1270     begin
       
  1271     glColor4f(1, 1, 1, 0.25 + abs(1 - (RealTicks mod 1500) / 750));
  1258     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
  1272     DrawSprite(sprVampiric, sx - 24, sy - 24, 0);
       
  1273 	glColor4f(1, 1, 1, 1);
  1259     end;
  1274     end;
  1260 end;
  1275 end;
  1261 
  1276 
  1262 procedure DrawRopeLinesRQ(Gear: PGear);
  1277 procedure DrawRopeLinesRQ(Gear: PGear);
  1263 begin
  1278 begin
  1400 while Gear<>nil do
  1415 while Gear<>nil do
  1401 	begin
  1416 	begin
  1402 	case Gear^.Kind of
  1417 	case Gear^.Kind of
  1403        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1418        gtAmmo_Bomb: DrawRotated(sprBomb, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, Gear^.DirAngle);
  1404 
  1419 
  1405        gtRCPlane: if (Gear^.Tag = -1) then
  1420        gtRCPlane: begin
       
  1421                   if (Gear^.Tag = -1) then
  1406                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
  1422                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, -1,  DxDy2Angle(Gear^.dX, Gear^.dY) + 90)
  1407                   else
  1423                   else
  1408                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
  1424                      DrawRotated(sprPlane, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,0,DxDy2Angle(Gear^.dY, Gear^.dX));
  1409 
  1425                   if ((TrainingFlags and tfRCPlane) <> 0) and (TrainingTargetGear <> nil) and ((Gear^.State and gstDrowning) = 0) then
       
  1426 					 DrawRotatedf(sprFinger, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, GameTicks div 32 mod 16, 0, DxDy2Angle(Gear^.X - TrainingTargetGear^.X, TrainingTargetGear^.Y - Gear^.Y));
       
  1427                   end;
  1410        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1428        gtBall: DrawRotatedf(sprBalls, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, Gear^.Tag,0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1411 
  1429 
  1412        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1430        gtDrill: DrawRotated(sprDrill, hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy, 0, DxDy2Angle(Gear^.dY, Gear^.dX));
  1413 
  1431 
  1414         gtHedgehog: DrawHH(Gear);
  1432         gtHedgehog: DrawHH(Gear);
  1494 var i: LongInt;
  1512 var i: LongInt;
  1495 	Gear: PGear;
  1513 	Gear: PGear;
  1496 begin
  1514 begin
  1497 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1515 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
  1498 
  1516 
       
  1517 if (TrainingFlags and tfSpawnTargets) <> 0 then
       
  1518 	begin
       
  1519 	TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0);
       
  1520 	FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
       
  1521 	end;
       
  1522 
  1499 if ((GameFlags and gfForts) = 0) and ((GameFlags and gfMines) <> 0) then
  1523 if ((GameFlags and gfForts) = 0) and ((GameFlags and gfMines) <> 0) then
  1500 	for i:= 0 to Pred(cLandAdditions) do
  1524 	for i:= 0 to Pred(cLandAdditions) do
  1501 		begin
  1525 		begin
  1502 		Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1526 		Gear:= AddGear(0, 0, gtMine, 0, _0, _0, 0);
  1503 		Gear^.TriggerId:= i + 1;
  1527 		Gear^.TriggerId:= i + 1;
  1640 Damage:= modifyDamage(Damage);
  1664 Damage:= modifyDamage(Damage);
  1641 
  1665 
  1642 while i > 0 do
  1666 while i > 0 do
  1643 	begin
  1667 	begin
  1644 	dec(i);
  1668 	dec(i);
  1645     Gear:= t^.ar[i];
  1669 	Gear:= t^.ar[i];
  1646     if (Gear^.State and gstNoDamage) = 0 then
  1670 	if (Gear^.State and gstNoDamage) = 0 then
  1647         case Gear^.Kind of
  1671 		begin
       
  1672 		if (Gear^.Kind = gtHedgehog) and (Ammo^.State and gsttmpFlag <> 0) then Gear^.FlightTime:= 1;
       
  1673 		
       
  1674 		case Gear^.Kind of
  1648 			gtHedgehog,
  1675 			gtHedgehog,
  1649 			gtMine,
  1676 			gtMine,
  1650 			gtTarget,
  1677 			gtTarget,
  1651 			gtCase: begin
  1678 			gtCase: begin
  1652 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1679 					if (Ammo^.Kind = gtDrill) then begin Ammo^.Timer:= 0; exit; end;
  1673 						end;
  1700 						end;
  1674 					
  1701 					
  1675 					FollowGear:= Gear
  1702 					FollowGear:= Gear
  1676 					end;
  1703 					end;
  1677 		end
  1704 		end
       
  1705 		end;
  1678 	end;
  1706 	end;
  1679 if i <> 0 then SetAllToActive
  1707 if i <> 0 then SetAllToActive
  1680 end;
  1708 end;
  1681 
  1709 
  1682 procedure AssignHHCoords;
  1710 procedure AssignHHCoords;