777 defaultPos:= false |
776 defaultPos:= false |
778 end else |
777 end else |
779 |
778 |
780 if (Gear^.State and gstHHDriven) <> 0 then |
779 if (Gear^.State and gstHHDriven) <> 0 then |
781 begin |
780 begin |
|
781 if ((Gear^.State and gstHHThinking) = 0) and |
|
782 ShowCrosshair and |
|
783 ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
|
784 begin |
|
785 (* These calculations are a little complex for a few reasons: |
|
786 1: I need to draw the laser from weapon origin to nearest land |
|
787 2: I need to start the beam outside the hedgie for attractiveness. |
|
788 3: I need to extend the beam beyond land. |
|
789 This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. |
|
790 *) |
|
791 dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); |
|
792 dy:= - Cos(Gear^.Angle * pi / cMaxAngle); |
|
793 if cLaserSighting then |
|
794 begin |
|
795 lx:= hwRound(Gear^.X); |
|
796 ly:= hwRound(Gear^.Y); |
|
797 lx:= lx + dx * 16; |
|
798 ly:= ly + dy * 16; |
|
799 |
|
800 ax:= dx * 4; |
|
801 ay:= dy * 4; |
|
802 |
|
803 tx:= round(lx); |
|
804 ty:= round(ly); |
|
805 hx:= tx; |
|
806 hy:= ty; |
|
807 while ((ty and LAND_HEIGHT_MASK) = 0) and |
|
808 ((tx and LAND_WIDTH_MASK) = 0) and |
|
809 (Land[ty, tx] = 0) do |
|
810 begin |
|
811 lx:= lx + ax; |
|
812 ly:= ly + ay; |
|
813 tx:= round(lx); |
|
814 ty:= round(ly) |
|
815 end; |
|
816 // reached edge of land. assume infinite beam. Extend it way out past camera |
|
817 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
|
818 begin |
|
819 tx:= round(lx + ax * (LAND_WIDTH div 4)); |
|
820 ty:= round(ly + ay * (LAND_WIDTH div 4)); |
|
821 end; |
|
822 |
|
823 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
|
824 begin |
|
825 glDisable(GL_TEXTURE_2D); |
|
826 glEnable(GL_LINE_SMOOTH); |
|
827 |
|
828 glColor4ub($FF, $00, $00, $C0); |
|
829 VertexBuffer[0].X:= hx + WorldDx; |
|
830 VertexBuffer[0].Y:= hy + WorldDy; |
|
831 VertexBuffer[1].X:= tx + WorldDx; |
|
832 VertexBuffer[1].Y:= ty + WorldDy; |
|
833 |
|
834 glEnableClientState(GL_VERTEX_ARRAY); |
|
835 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
836 glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
|
837 glColor4f(1, 1, 1, 1); |
|
838 glEnable(GL_TEXTURE_2D); |
|
839 glDisable(GL_LINE_SMOOTH); |
|
840 end; |
|
841 end; |
|
842 // draw crosshair |
|
843 cx:= Round(hwRound(Gear^.X) + dx * 80); |
|
844 cy:= Round(hwRound(Gear^.Y) + dy * 80); |
|
845 DrawRotatedTex(PHedgehog(Gear^.Hedgehog)^.Team^.CrosshairTex, |
|
846 12, 12, cx + WorldDx, cy + WorldDy, 0, |
|
847 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle); |
|
848 end; |
782 hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
849 hx:= hwRound(Gear^.X) + 1 + 8 * hwSign(Gear^.dX) + WorldDx; |
783 hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
850 hy:= hwRound(Gear^.Y) - 2 + WorldDy; |
784 aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
851 aangle:= Gear^.Angle * 180 / cMaxAngle - 90; |
785 |
852 |
786 if CurAmmoGear <> nil then |
853 if CurAmmoGear <> nil then |
1122 GameTicks div 32 mod 16); |
1186 GameTicks div 32 mod 16); |
1123 |
1187 |
1124 if (Gear^.State and gstDrowning) = 0 then |
1188 if (Gear^.State and gstDrowning) = 0 then |
1125 if (Gear^.State and gstHHThinking) <> 0 then |
1189 if (Gear^.State and gstHHThinking) <> 0 then |
1126 DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
1190 DrawSprite(sprQuestion, hwRound(Gear^.X) - 10 + WorldDx, hwRound(Gear^.Y) - cHHRadius - 34 + WorldDy, 0) |
1127 else |
1191 end |
1128 if ShowCrosshair and ((Gear^.State and (gstAttacked or gstAnimation)) = 0) then |
|
1129 begin |
|
1130 (* These calculations are a little complex for a few reasons: |
|
1131 1: I need to draw the laser from weapon origin to nearest land |
|
1132 2: I need to start the beam outside the hedgie for attractiveness. |
|
1133 3: I need to extend the beam beyond land. |
|
1134 This routine perhaps should be pushed into uStore or somesuch instead of continuuing the increase in size of this function. |
|
1135 *) |
|
1136 dx:= hwSign(Gear^.dX) * m * Sin(Gear^.Angle * pi / cMaxAngle); |
|
1137 dy:= - Cos(Gear^.Angle * pi / cMaxAngle); |
|
1138 if cLaserSighting then |
|
1139 begin |
|
1140 lx:= hwRound(Gear^.X); |
|
1141 ly:= hwRound(Gear^.Y); |
|
1142 lx:= lx + dx * 16; |
|
1143 ly:= ly + dy * 16; |
|
1144 |
|
1145 ax:= dx * 4; |
|
1146 ay:= dy * 4; |
|
1147 |
|
1148 tx:= round(lx); |
|
1149 ty:= round(ly); |
|
1150 hx:= tx; |
|
1151 hy:= ty; |
|
1152 while ((ty and LAND_HEIGHT_MASK) = 0) and |
|
1153 ((tx and LAND_WIDTH_MASK) = 0) and |
|
1154 (Land[ty, tx] = 0) do |
|
1155 begin |
|
1156 lx:= lx + ax; |
|
1157 ly:= ly + ay; |
|
1158 tx:= round(lx); |
|
1159 ty:= round(ly) |
|
1160 end; |
|
1161 // reached edge of land. assume infinite beam. Extend it way out past camera |
|
1162 if ((ty and LAND_HEIGHT_MASK) <> 0) or ((tx and LAND_WIDTH_MASK) <> 0) then |
|
1163 begin |
|
1164 tx:= round(lx + ax * (LAND_WIDTH div 4)); |
|
1165 ty:= round(ly + ay * (LAND_WIDTH div 4)); |
|
1166 end; |
|
1167 |
|
1168 //if (abs(lx-tx)>8) or (abs(ly-ty)>8) then |
|
1169 begin |
|
1170 glDisable(GL_TEXTURE_2D); |
|
1171 glEnable(GL_LINE_SMOOTH); |
|
1172 |
|
1173 glColor4ub($FF, $00, $00, $C0); |
|
1174 VertexBuffer[0].X:= hx + WorldDx; |
|
1175 VertexBuffer[0].Y:= hy + WorldDy; |
|
1176 VertexBuffer[1].X:= tx + WorldDx; |
|
1177 VertexBuffer[1].Y:= ty + WorldDy; |
|
1178 |
|
1179 glEnableClientState(GL_VERTEX_ARRAY); |
|
1180 glVertexPointer(2, GL_FLOAT, 0, @VertexBuffer[0]); |
|
1181 glDrawArrays(GL_LINES, 0, Length(VertexBuffer)); |
|
1182 glColor4f(1, 1, 1, 1); |
|
1183 glEnable(GL_TEXTURE_2D); |
|
1184 glDisable(GL_LINE_SMOOTH); |
|
1185 end; |
|
1186 end; |
|
1187 // draw crosshair |
|
1188 cx:= Round(hwRound(Gear^.X) + dx * 80); |
|
1189 cy:= Round(hwRound(Gear^.Y) + dy * 80); |
|
1190 DrawRotatedTex(Team^.CrosshairTex, |
|
1191 12, 12, cx + WorldDx, cy + WorldDy, 0, |
|
1192 hwSign(Gear^.dX) * (Gear^.Angle * 180.0) / cMaxAngle); |
|
1193 end |
|
1194 end |
|
1195 end; |
1192 end; |
1196 |
1193 |
1197 if Gear^.Invulnerable then |
1194 if Gear^.Invulnerable then |
1198 begin |
1195 begin |
1199 DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0); |
1196 DrawSprite(sprInvulnerable, sx - 24, sy - 24, 0); |