hedgewars/GSHandlers.inc
changeset 2428 6800f8aa0184
parent 2425 a4af95e6382c
child 2429 f97bac89f0c5
equal deleted inserted replaced
2427:241e3bb6a146 2428:6800f8aa0184
  2128 	trueAngle: Longword;
  2128 	trueAngle: Longword;
  2129 	t: PGear;
  2129 	t: PGear;
  2130 begin
  2130 begin
  2131 AllInactive:= false;
  2131 AllInactive:= false;
  2132 
  2132 
  2133 if Gear^.Timer > 0 then dec(Gear^.Timer);
  2133 if ((TrainingFlags and tfRCPlane) = 0) and (Gear^.Timer > 0) then dec(Gear^.Timer);
       
  2134 
       
  2135 if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStartTime = 0) then TimeTrialStartTime:= RealTicks;
  2134 
  2136 
  2135 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
  2137 HHGear:= PHedgehog(Gear^.Hedgehog)^.Gear;
  2136 FollowGear:= Gear;
  2138 FollowGear:= Gear;
  2137 
  2139 
  2138 fChanged:= false;
  2140 fChanged:= false;
  2170 	end;
  2172 	end;
  2171 
  2173 
  2172 Gear^.X:= Gear^.X + Gear^.dX;
  2174 Gear^.X:= Gear^.X + Gear^.dX;
  2173 Gear^.Y:= Gear^.Y + Gear^.dY;
  2175 Gear^.Y:= Gear^.Y + Gear^.dY;
  2174 
  2176 
  2175 if (GameTicks and $FF) = 0 then
  2177 if (TrainingFlags and tfRCPlane) = 0 then
  2176 	if Gear^.Timer < 3500 then
  2178 	begin
  2177 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0)
  2179 	if (GameTicks and $FF) = 0 then
       
  2180 		if Gear^.Timer < 3500 then
       
  2181 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0)
       
  2182 		else
       
  2183 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
       
  2184 
       
  2185 	if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then
       
  2186 		begin
       
  2187 		HHGear^.Message := HHGear^.Message and not gm_Attack;
       
  2188 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0);
       
  2189 		dec(Gear^.Health)
       
  2190 		end;
       
  2191 
       
  2192 	if ((HHGear^.Message and gm_LJump) <> 0)
       
  2193 		and ((Gear^.State and gsttmpFlag) = 0) then
       
  2194 		begin
       
  2195 		Gear^.State:= Gear^.State or gsttmpFlag;
       
  2196 		PauseMusic;
       
  2197 		playSound(sndRideOfTheValkyries, false, nil);
       
  2198 		end;
       
  2199 
       
  2200 	// pickup bonuses
       
  2201 	t:= CheckGearNear(Gear, gtCase, 36, 36);
       
  2202 	if t <> nil then
       
  2203 		PickUp(HHGear, t);
       
  2204 	end
       
  2205 else
       
  2206 	begin
       
  2207 	if (GameTicks and $FF) = 0 then
       
  2208 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
       
  2209 
       
  2210 	// pickup targets
       
  2211 	t:= CheckGearNear(Gear, gtTarget, 36, 36);
       
  2212 	if t <> nil then
       
  2213 		begin;
       
  2214 		// TODO: Sound!
       
  2215 		PlaySound(sndGraveImpact, false, nil);
       
  2216 		DeleteGear(t);
       
  2217 		TrainingTargetGear:= AddGear(0, 0, gtTarget, 0, _0, _0, 0);
       
  2218 		FindPlace(TrainingTargetGear, false, 0, LAND_WIDTH);
       
  2219 		inc(TurnTimeLeft, TrainingTimeInc);
       
  2220 		
       
  2221 		if TrainingTimeInc > TrainingTimeInM then
       
  2222 			dec(TrainingTimeInc, TrainingTimeInD);
       
  2223 		if TurnTimeLeft > TrainingTimeMax then TurnTimeLeft:= TrainingTimeMax;
       
  2224 		end;
       
  2225 
       
  2226 	if (TurnTimeLeft > 0) then 
       
  2227 		dec(TurnTimeLeft)
  2178 	else
  2228 	else
  2179 		AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
  2229 		begin
  2180 
  2230 		if ((TrainingFlags and tfTimeTrial) <>0) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks;
  2181 if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then
  2231 		StopSound(sndRCPlane);
  2182 	begin
  2232 		ResumeMusic;
  2183 	HHGear^.Message := HHGear^.Message and not gm_Attack;
  2233 		doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 25, EXPLAutoSound);
  2184 	AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0);
  2234 		for i:= 0 to 32 do
  2185 	dec(Gear^.Health)
  2235 			begin
  2186     end;
  2236 			dX:= AngleCos(i * 64) * _0_5 * (GetRandom + _1);
  2187 
  2237 			dY:= AngleSin(i * 64) * _0_5 * (GetRandom + _1);
  2188 if ((HHGear^.Message and gm_LJump) <> 0)
  2238 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, dY, 0);
  2189 	and ((Gear^.State and gsttmpFlag) = 0) then
  2239 			AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtFlame, 0, dX, -dY, 0);
  2190     begin
  2240 			end;
  2191     Gear^.State:= Gear^.State or gsttmpFlag;
  2241 		DeleteGear(Gear);
  2192     PauseMusic;
  2242 		AfterAttack;
  2193     playSound(sndRideOfTheValkyries, false, nil);
  2243 		TurnTimeLeft:= 0;
  2194     end;
  2244 		CurAmmoGear:= nil;
  2195 
  2245 		HHGear^.Message:= 0;
  2196 // pickup bonuses
  2246 		ParseCommand('/taunt '#1, true);
  2197 t:= CheckGearNear(Gear, gtCase, 36, 36);
  2247 		exit;
  2198 if t <> nil then
  2248 		end;
  2199 	PickUp(HHGear, t);
  2249 
  2200 
  2250 	end;
       
  2251 		
  2201 CheckCollision(Gear);
  2252 CheckCollision(Gear);
  2202 
  2253 
  2203 if ((Gear^.State and gstCollision) <> 0)
  2254 if ((Gear^.State and gstCollision) <> 0)
  2204 	or CheckGearDrowning(Gear) then
  2255 	or CheckGearDrowning(Gear) then
  2205 	begin
  2256 	begin
       
  2257 	if ((TrainingFlags and tfRCPlane) <> 0) and ((TrainingFlags and tfTimeTrial) <> 0 ) and (TimeTrialStopTime = 0) then TimeTrialStopTime:= RealTicks;
  2206 	StopSound(sndRCPlane);
  2258 	StopSound(sndRCPlane);
  2207 	StopSound(sndRideOfTheValkyries);
  2259 	StopSound(sndRideOfTheValkyries);
  2208 	ResumeMusic;
  2260 	ResumeMusic;
  2209 
  2261 
  2210 	if ((Gear^.State and gstCollision) <> 0) then
  2262 	if ((Gear^.State and gstCollision) <> 0) then