hedgewars/uGears.pas
changeset 1002 14ecd5fd4fab
parent 1000 e7b204880318
child 1008 38bb05efd774
equal deleted inserted replaced
1001:502508979713 1002:14ecd5fd4fab
   508 if (Gear^.State and gstHHDeath) <> 0 then
   508 if (Gear^.State and gstHHDeath) <> 0 then
   509 	begin
   509 	begin
   510 	DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
   510 	DrawSprite(sprHHDeath, hwRound(Gear^.X) - 16 + WorldDx, hwRound(Gear^.Y) - 26 + WorldDy, Gear^.Pos);
   511 	exit
   511 	exit
   512 	end;
   512 	end;
       
   513 
   513 defaultPos:= true;
   514 defaultPos:= true;
   514 
   515 
       
   516 if (Gear^.State and gstDrowning) <> 0 then
       
   517 	begin
       
   518 	DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   519 			hwSign(Gear^.dX),
       
   520 			1,
       
   521 			7,
       
   522 			0);
       
   523 	defaultPos:= false
       
   524 	end else
       
   525 
   515 if (Gear^.State and gstHHDriven) <> 0 then
   526 if (Gear^.State and gstHHDriven) <> 0 then
   516 	begin
   527 	begin
   517 		hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
   528 	hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx;
   518 		hy:= hwRound(Gear^.Y) - 2 + WorldDy;
   529 	hy:= hwRound(Gear^.Y) - 2 + WorldDy;
   519 		aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   530 	aangle:= Gear^.Angle * 180 / cMaxAngle - 90;
   520 
   531 
   521 		if CurAmmoGear <> nil then
   532 	if CurAmmoGear <> nil then
       
   533 	begin
       
   534 		case CurAmmoGear^.Kind of
       
   535 			gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then
       
   536 					DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
       
   537 				else
       
   538 					DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   539 			gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   540 			gtRope: begin
       
   541 				if Gear^.X < CurAmmoGear^.X then
       
   542 					begin
       
   543 					dAngle:= 0;
       
   544 					m:= 1
       
   545 					end else
       
   546 					begin
       
   547 					dAngle:= 180;
       
   548 					m:= -1
       
   549 					end;
       
   550 				DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   551 						m,
       
   552 						1,
       
   553 						0,
       
   554 						DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
       
   555 				defaultPos:= false
       
   556 				end;
       
   557 			gtBlowTorch: begin
       
   558 				DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   559 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   560 						hwSign(Gear^.dX),
       
   561 						1,
       
   562 						3,
       
   563 						0);
       
   564 				defaultPos:= false
       
   565 				end;
       
   566 			gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
       
   567 			gtFirePunch: begin
       
   568 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   569 						hwSign(Gear^.dX),
       
   570 						1,
       
   571 						4,
       
   572 						0);
       
   573 				defaultPos:= false
       
   574 				end;
       
   575 			gtPickHammer,
       
   576 			gtTeleport: defaultPos:= false;
       
   577 			gtKamikaze: begin
       
   578 						if CurAmmoGear^.Pos = 0 then
       
   579 							DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   580 									hwSign(Gear^.dX),
       
   581 									1,
       
   582 									6,
       
   583 									0)
       
   584 						else
       
   585 							DrawRotatedF(sprKamikaze,
       
   586 									hwRound(Gear^.X) + WorldDx,
       
   587 									hwRound(Gear^.Y) + WorldDy,
       
   588 									CurAmmoGear^.Pos - 1,
       
   589 									1,
       
   590 									DxDy2Angle(Gear^.dY, Gear^.dX));
       
   591 
       
   592 						defaultPos:= false
       
   593 						end;
       
   594 		end;
       
   595 
       
   596 		case CurAmmoGear^.Kind of
       
   597 			gtShotgunShot,
       
   598 			gtDEagleShot,
       
   599 			gtShover: begin
       
   600 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   601 						hwSign(Gear^.dX),
       
   602 						0,
       
   603 						4,
       
   604 						0);
       
   605 				defaultPos:= false
       
   606 			end
       
   607 		end
       
   608 	end else
       
   609 
       
   610 	if ((Gear^.State and gstHHJumping) <> 0) then
       
   611 	begin
       
   612 	if ((Gear^.State and gstHHHJump) <> 0) then
       
   613 		DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   614 			- hwSign(Gear^.dX),
       
   615 			1,
       
   616 			1,
       
   617 			0)
       
   618 		else
       
   619 		DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   620 			hwSign(Gear^.dX),
       
   621 			1,
       
   622 			1,
       
   623 			0);
       
   624 	defaultPos:= false
       
   625 	end else
       
   626 
       
   627 	if (Gear^.Message and (gm_Left or gm_Right) <> 0) then
   522 		begin
   628 		begin
   523 			case CurAmmoGear^.Kind of
   629 		DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   524 				gtShotgunShot: if (CurAmmoGear^.State and gstAnimation <> 0) then
   630 			hwSign(Gear^.dX),
   525 						DrawRotated(sprShotgun, hx, hy, hwSign(Gear^.dX), aangle)
   631 			0,
   526 					else
   632 			PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
   527 						DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
   633 			0);
   528 				gtDEagleShot: DrawRotated(sprDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   529 				gtRope: begin
       
   530 					if Gear^.X < CurAmmoGear^.X then
       
   531 						begin
       
   532 						dAngle:= 0;
       
   533 						m:= 1
       
   534 						end else
       
   535 						begin
       
   536 						dAngle:= 180;
       
   537 						m:= -1
       
   538 						end;
       
   539 					DrawHedgehog(hwRound(Gear^.X) + WorldDx, hwRound(Gear^.Y) + WorldDy,
       
   540 							m,
       
   541 							1,
       
   542 							0,
       
   543 							DxDy2Angle(CurAmmoGear^.dY, CurAmmoGear^.dX) + dAngle);
       
   544 					defaultPos:= false
       
   545 					end;
       
   546 				gtBlowTorch: begin
       
   547 					DrawRotated(sprBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   548 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   549 							hwSign(Gear^.dX),
       
   550 							1,
       
   551 							3,
       
   552 							0);
       
   553 					defaultPos:= false
       
   554 					end;
       
   555 				gtShover: DrawRotated(sprHandBaseball, hx, hy, hwSign(Gear^.dX), aangle + 180);
       
   556 				gtFirePunch: begin
       
   557 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   558 							hwSign(Gear^.dX),
       
   559 							1,
       
   560 							4,
       
   561 							0);
       
   562 					defaultPos:= false
       
   563 					end;
       
   564 				gtPickHammer,
       
   565 				gtTeleport: defaultPos:= false;
       
   566 				gtKamikaze: begin
       
   567 							if CurAmmoGear^.Pos = 0 then
       
   568 								DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   569 										hwSign(Gear^.dX),
       
   570 										1,
       
   571 										6,
       
   572 										0)
       
   573 							else
       
   574 								DrawRotatedF(sprKamikaze,
       
   575 										hwRound(Gear^.X) + WorldDx,
       
   576 										hwRound(Gear^.Y) + WorldDy,
       
   577 										CurAmmoGear^.Pos - 1,
       
   578 										1,
       
   579 										DxDy2Angle(Gear^.dY, Gear^.dX));
       
   580 										
       
   581 							defaultPos:= false
       
   582 							end;
       
   583 			end;
       
   584 
       
   585 			case CurAmmoGear^.Kind of
       
   586 				gtShotgunShot,
       
   587 				gtDEagleShot,
       
   588 				gtShover: begin
       
   589 					DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   590 							hwSign(Gear^.dX),
       
   591 							0,
       
   592 							4,
       
   593 							0);
       
   594 					defaultPos:= false
       
   595 				end
       
   596 			end
       
   597 		end else
       
   598 
       
   599 		if ((Gear^.State and gstHHJumping) <> 0) then
       
   600 		begin
       
   601 		if ((Gear^.State and gstHHHJump) <> 0) then
       
   602 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   603 				- hwSign(Gear^.dX),
       
   604 				1,
       
   605 				1,
       
   606 				0)
       
   607 			else
       
   608 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   609 				hwSign(Gear^.dX),
       
   610 				1,
       
   611 				1,
       
   612 				0);
       
   613 			defaultPos:= false
   634 			defaultPos:= false
   614 		end else
   635 		end
   615 		
   636 	else
   616 		if (Gear^.Message and (gm_Left or gm_Right) <> 0) then
   637 
   617 			begin
   638 	if ((Gear^.State and gstAttacked) = 0) then
       
   639 	begin
       
   640 		amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   641 		case amt of
       
   642 			amBazooka,
       
   643 			amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
       
   644 			amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   645 			amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   646 			amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   647 			amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   648 		end;
       
   649 
       
   650 		case amt of
       
   651 			amAirAttack,
       
   652 			amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
       
   653 			amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   654 						hwSign(Gear^.dX),
       
   655 						1,
       
   656 						2,
       
   657 						0);
       
   658 			amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   659 						hwSign(Gear^.dX),
       
   660 						1,
       
   661 						3,
       
   662 						0);
       
   663 			amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0);
       
   664 			amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   665 						hwSign(Gear^.dX),
       
   666 						1,
       
   667 						5,
       
   668 						0);
       
   669 		else
   618 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   670 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
   619 				hwSign(Gear^.dX),
   671 				hwSign(Gear^.dX),
   620 				0,
   672 				0,
   621 				PHedgehog(Gear^.Hedgehog)^.visStepPos div 2,
   673 				4,
   622 				0);
   674 				0);
   623 				defaultPos:= false
       
   624 			end
       
   625 		else
       
   626 
       
   627 		if ((Gear^.State and gstAttacked) = 0) then
       
   628 		begin
       
   629 			amt:= CurrentHedgehog^.Ammo^[CurrentHedgehog^.CurSlot, CurrentHedgehog^.CurAmmo].AmmoType;
       
   630 			case amt of
       
   631 				amBazooka,
       
   632 				amMortar: DrawRotated(sprHandBazooka, hx, hy, hwSign(Gear^.dX), aangle);
       
   633 				amRope: DrawRotated(sprHandRope, hx, hy, hwSign(Gear^.dX), aangle);
       
   634 				amShotgun: DrawRotated(sprHandShotgun, hx, hy, hwSign(Gear^.dX), aangle);
       
   635 				amDEagle: DrawRotated(sprHandDEagle, hx, hy, hwSign(Gear^.dX), aangle);
       
   636 				amBlowTorch: DrawRotated(sprHandBlowTorch, hx, hy, hwSign(Gear^.dX), aangle);
       
   637 			end;
       
   638 
       
   639 			case amt of
       
   640 				amAirAttack,
       
   641 				amMineStrike: DrawRotated(sprHandAirAttack, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) + WorldDy, hwSign(Gear^.dX), 0);
       
   642 				amPickHammer: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   643 							hwSign(Gear^.dX),
       
   644 							1,
       
   645 							2,
       
   646 							0);
       
   647 				amBlowTorch: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   648 							hwSign(Gear^.dX),
       
   649 							1,
       
   650 							3,
       
   651 							0);
       
   652 				amTeleport: DrawRotatedF(sprTeleport, hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy, 0, hwSign(Gear^.dX), 0);
       
   653 				amKamikaze: DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   654 							hwSign(Gear^.dX),
       
   655 							1,
       
   656 							5,
       
   657 							0);
       
   658 			else
       
   659 				DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   660 					hwSign(Gear^.dX),
       
   661 					0,
       
   662 					4,
       
   663 					0);
       
   664 			end;
       
   665 
       
   666 			case amt of
       
   667 				amBaseballBat: DrawRotated(sprHandBaseball,
       
   668 						hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
       
   669 						hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
       
   670 			end;
       
   671 
       
   672 			defaultPos:= false
       
   673 		end
       
   674 	end else // not gstHHDriven
       
   675 		if ((Gear^.State and gstHHJumping) <> 0) then
       
   676 		begin
       
   677 		if ((Gear^.State and gstHHHJump) <> 0) then
       
   678 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   679 				- hwSign(Gear^.dX),
       
   680 				1,
       
   681 				1,
       
   682 				0)
       
   683 			else
       
   684 			DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   685 				hwSign(Gear^.dX),
       
   686 				1,
       
   687 				1,
       
   688 				0);
       
   689 			defaultPos:= false
       
   690 		end;
   675 		end;
       
   676 
       
   677 		case amt of
       
   678 			amBaseballBat: DrawRotated(sprHandBaseball,
       
   679 					hwRound(Gear^.X) + 1 - 4 * hwSign(Gear^.dX) + WorldDx,
       
   680 					hwRound(Gear^.Y) + 6 + WorldDy, hwSign(Gear^.dX), aangle);
       
   681 		end;
       
   682 
       
   683 		defaultPos:= false
       
   684 	end
       
   685 end else // not gstHHDriven
       
   686 if ((Gear^.State and gstHHJumping) <> 0) then
       
   687 begin
       
   688 if ((Gear^.State and gstHHHJump) <> 0) then
       
   689 	DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   690 		- hwSign(Gear^.dX),
       
   691 		1,
       
   692 		1,
       
   693 		0)
       
   694 	else
       
   695 	DrawHedgehog(hwRound(Gear^.X) + 1 + WorldDx, hwRound(Gear^.Y) - 3 + WorldDy,
       
   696 		hwSign(Gear^.dX),
       
   697 		1,
       
   698 		1,
       
   699 		0);
       
   700 	defaultPos:= false
       
   701 end;
   691 
   702 
   692 
   703 
   693 if defaultPos then
   704 if defaultPos then
   694 	begin
   705 	begin
   695 	DrawRotatedF(sprHHIdle,
   706 	DrawRotatedF(sprHHIdle,