hedgewars/GSHandlers.inc
changeset 3440 dee31c5149e0
parent 3431 e36dffdf7b82
child 3454 a9bef74bd6e0
equal deleted inserted replaced
3439:a98984e4f458 3440:dee31c5149e0
   341         PlaySound(sndHellish);
   341         PlaySound(sndHellish);
   342         end;
   342         end;
   343 
   343 
   344     if (GameTicks and $3F) = 0 then
   344     if (GameTicks and $3F) = 0 then
   345         if (Gear^.State and gstCollision) = 0 then
   345         if (Gear^.State and gstCollision) = 0 then
   346             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0);
   346             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace);
   347     end;
   347     end;
   348 end;
   348 end;
   349 ////////////////////////////////////////////////////////////////////////////////
   349 ////////////////////////////////////////////////////////////////////////////////
   350 procedure doStepMolotov(Gear: PGear);
   350 procedure doStepMolotov(Gear: PGear);
   351 var i, gX, gY: LongInt;
   351 var i, gX, gY: LongInt;
   398 
   398 
   399 if (Gear^.Kind = gtMelonPiece) or (Gear^.Kind = gtBall) then
   399 if (Gear^.Kind = gtMelonPiece) or (Gear^.Kind = gtBall) then
   400     CalcRotationDirAngle(Gear)
   400     CalcRotationDirAngle(Gear)
   401 else
   401 else
   402     if (GameTicks and $1F) = 0 then
   402     if (GameTicks and $1F) = 0 then
   403         AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
   403         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
   404 end;
   404 end;
   405 
   405 
   406 ////////////////////////////////////////////////////////////////////////////////
   406 ////////////////////////////////////////////////////////////////////////////////
   407 procedure doStepGrenade(Gear: PGear);
   407 procedure doStepGrenade(Gear: PGear);
   408 begin
   408 begin
   414     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   414     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 50, EXPLAutoSound);
   415     DeleteGear(Gear);
   415     DeleteGear(Gear);
   416     exit
   416     exit
   417     end;
   417     end;
   418 if (GameTicks and $3F) = 0 then
   418 if (GameTicks and $3F) = 0 then
   419     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
   419     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
   420 end;
       
   421 
       
   422 ////////////////////////////////////////////////////////////////////////////////
       
   423 procedure doStepHealthTagWork(Gear: PGear);
       
   424 begin
       
   425 if Gear^.Kind = gtHealthTag then
       
   426     AllInactive:= false;
       
   427 
       
   428 dec(Gear^.Timer);
       
   429 Gear^.Y:= Gear^.Y + Gear^.dY;
       
   430 
       
   431 if Gear^.Timer = 0 then
       
   432     begin
       
   433     if (Gear^.Kind = gtHealthTag) and (PHedgehog(Gear^.Hedgehog)^.Gear <> nil) then
       
   434         PHedgehog(Gear^.Hedgehog)^.Gear^.Active:= true; // to let current hh die
       
   435     DeleteGear(Gear)
       
   436     end
       
   437 end;
       
   438 
       
   439 procedure doStepHealthTagWorkUnderWater(Gear: PGear);
       
   440 begin
       
   441 AllInactive:= false;
       
   442 
       
   443 Gear^.Y:= Gear^.Y - _0_08;
       
   444 
       
   445 if hwRound(Gear^.Y) < cWaterLine + 10 then
       
   446     DeleteGear(Gear)
       
   447 end;
       
   448 
       
   449 procedure doStepHealthTag(Gear: PGear);
       
   450 var s: shortstring;
       
   451 begin
       
   452 AllInactive:= false;
       
   453 Gear^.dY:= -_0_08;
       
   454 
       
   455 str(Gear^.State, s);
       
   456 Gear^.Tex:= RenderStringTex(s, PHedgehog(Gear^.Hedgehog)^.Team^.Clan^.Color, fnt16);
       
   457 
       
   458 if hwRound(Gear^.Y) < cWaterLine then
       
   459     Gear^.doStep:= @doStepHealthTagWork
       
   460 else
       
   461     Gear^.doStep:= @doStepHealthTagWorkUnderWater;
       
   462 
       
   463 Gear^.Y:= Gear^.Y - int2hwFloat(Gear^.Tex^.h)
       
   464 end;
   420 end;
   465 
   421 
   466 ////////////////////////////////////////////////////////////////////////////////
   422 ////////////////////////////////////////////////////////////////////////////////
   467 procedure doStepGrave(Gear: PGear);
   423 procedure doStepGrave(Gear: PGear);
   468 begin
   424 begin
  1287 begin
  1243 begin
  1288 Gear^.dX:= - Gear^.dX;
  1244 Gear^.dX:= - Gear^.dX;
  1289 Gear^.dY:= - Gear^.dY;
  1245 Gear^.dY:= - Gear^.dY;
  1290 Gear^.doStep:= @doStepRopeAttach;
  1246 Gear^.doStep:= @doStepRopeAttach;
  1291 PlaySound(sndRopeShot)
  1247 PlaySound(sndRopeShot)
  1292 end;
       
  1293 
       
  1294 ////////////////////////////////////////////////////////////////////////////////
       
  1295 procedure doStepSmokeTrace(Gear: PGear);
       
  1296 begin
       
  1297 inc(Gear^.Timer);
       
  1298 if Gear^.Timer > 64 then
       
  1299     begin
       
  1300     Gear^.Timer:= 0;
       
  1301     dec(Gear^.State)
       
  1302     end;
       
  1303 Gear^.dX:= Gear^.dX + cWindSpeed;
       
  1304 Gear^.X:= Gear^.X + Gear^.dX;
       
  1305 if Gear^.State = 0 then DeleteGear(Gear)
       
  1306 end;
       
  1307 
       
  1308 ////////////////////////////////////////////////////////////////////////////////
       
  1309 procedure doStepExplosionWork(Gear: PGear);
       
  1310 begin
       
  1311 inc(Gear^.Timer);
       
  1312 if Gear^.Timer > 75 then
       
  1313     begin
       
  1314     inc(Gear^.State);
       
  1315     Gear^.Timer:= 0;
       
  1316     if Gear^.State > 5 then DeleteGear(Gear)
       
  1317     end;
       
  1318 end;
       
  1319 
       
  1320 procedure doStepExplosion(Gear: PGear);
       
  1321 var i: LongWord;
       
  1322 begin
       
  1323 for i:= 0 to 31 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtFire);
       
  1324 for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart);
       
  1325 for i:= 0 to 8 do AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtExplPart2);
       
  1326 Gear^.doStep:= @doStepExplosionWork
       
  1327 end;
  1248 end;
  1328 
  1249 
  1329 ////////////////////////////////////////////////////////////////////////////////
  1250 ////////////////////////////////////////////////////////////////////////////////
  1330 procedure doStepMine(Gear: PGear);
  1251 procedure doStepMine(Gear: PGear);
  1331 begin
  1252 begin
  1860             end;
  1781             end;
  1861     Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag)
  1782     Gear^.dX:= Gear^.dX + int2hwFloat(30 * Gear^.Tag)
  1862     end;
  1783     end;
  1863 
  1784 
  1864 if (GameTicks and $3F) = 0 then
  1785 if (GameTicks and $3F) = 0 then
  1865     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
  1786     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  1866 
  1787 
  1867 if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear)
  1788 if (hwRound(Gear^.X) > (LAND_WIDTH+1024)) or (hwRound(Gear^.X) < -1024) then DeleteGear(Gear)
  1868 end;
  1789 end;
  1869 
  1790 
  1870 procedure doStepAirAttack(Gear: PGear);
  1791 procedure doStepAirAttack(Gear: PGear);
  1903     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
  1824     doMakeExplosion(hwRound(Gear^.X), hwRound(Gear^.Y), 30, EXPLAutoSound);
  1904     DeleteGear(Gear);
  1825     DeleteGear(Gear);
  1905     exit
  1826     exit
  1906     end;
  1827     end;
  1907 if (GameTicks and $3F) = 0 then
  1828 if (GameTicks and $3F) = 0 then
  1908     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
  1829     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
  1909 end;
  1830 end;
  1910 
  1831 
  1911 ////////////////////////////////////////////////////////////////////////////////
  1832 ////////////////////////////////////////////////////////////////////////////////
  1912 
  1833 
  1913 procedure doStepGirder(Gear: PGear);
  1834 procedure doStepGirder(Gear: PGear);
  2101     DeleteGear(Gear);
  2022     DeleteGear(Gear);
  2102     exit
  2023     exit
  2103     end;
  2024     end;
  2104 
  2025 
  2105 if (GameTicks and $3F) = 0 then
  2026 if (GameTicks and $3F) = 0 then
  2106     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0)
  2027     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace)
  2107 end;
  2028 end;
  2108 
  2029 
  2109 ////////////////////////////////////////////////////////////////////////////////
  2030 ////////////////////////////////////////////////////////////////////////////////
  2110 procedure doStepKamikazeWork(Gear: PGear);
  2031 procedure doStepKamikazeWork(Gear: PGear);
  2111 const upd: Longword = 0;
  2032 const upd: Longword = 0;
  2490 oldDy:= Gear^.dY;
  2411 oldDy:= Gear^.dY;
  2491 
  2412 
  2492 doStepFallingGear(Gear);
  2413 doStepFallingGear(Gear);
  2493 
  2414 
  2494 if (GameTicks and $3F) = 0 then
  2415 if (GameTicks and $3F) = 0 then
  2495     AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
  2416     AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  2496 
  2417 
  2497 if ((Gear^.State and gstCollision) <> 0) then begin //hit
  2418 if ((Gear^.State and gstCollision) <> 0) then begin //hit
  2498     Gear^.dX:= oldDx;
  2419     Gear^.dX:= oldDx;
  2499     Gear^.dY:= oldDy;
  2420     Gear^.dY:= oldDy;
  2500 
  2421 
  2614 
  2535 
  2615 if (TrainingFlags and tfRCPlane) = 0 then
  2536 if (TrainingFlags and tfRCPlane) = 0 then
  2616     begin
  2537     begin
  2617     if (GameTicks and $FF) = 0 then
  2538     if (GameTicks and $FF) = 0 then
  2618         if Gear^.Timer < 3500 then
  2539         if Gear^.Timer < 3500 then
  2619             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtEvilTrace, 0, _0, _0, 0)
  2540             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtEvilTrace)
  2620         else
  2541         else
  2621             AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
  2542             AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  2622 
  2543 
  2623     if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then
  2544     if ((HHGear^.Message and gm_Attack) <> 0) and (Gear^.Health <> 0) then
  2624         begin
  2545         begin
  2625         HHGear^.Message := HHGear^.Message and not gm_Attack;
  2546         HHGear^.Message := HHGear^.Message and not gm_Attack;
  2626         AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0);
  2547         AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtAirBomb, 0, Gear^.dX * _0_5, Gear^.dY * _0_5, 0);
  2641         PickUp(HHGear, t);
  2562         PickUp(HHGear, t);
  2642     end
  2563     end
  2643 else
  2564 else
  2644     begin
  2565     begin
  2645     if (GameTicks and $FF) = 0 then
  2566     if (GameTicks and $FF) = 0 then
  2646         AddGear(hwRound(Gear^.X), hwRound(Gear^.Y), gtSmokeTrace, 0, _0, _0, 0);
  2567         AddVisualGear(hwRound(Gear^.X), hwRound(Gear^.Y), vgtSmokeTrace);
  2647 
  2568 
  2648     // pickup targets
  2569     // pickup targets
  2649     t:= CheckGearNear(Gear, gtTarget, 36, 36);
  2570     t:= CheckGearNear(Gear, gtTarget, 36, 36);
  2650     if t <> nil then
  2571     if t <> nil then
  2651         begin
  2572         begin
  2983     Message:= Message and not (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right)
  2904     Message:= Message and not (gm_Attack or gm_Up or gm_Precise or gm_Left or gm_Right)
  2984     end
  2905     end
  2985 end;
  2906 end;
  2986 
  2907 
  2987 ////////////////////////////////////////////////////////////////////////////////
  2908 ////////////////////////////////////////////////////////////////////////////////
  2988 procedure doStepBigExplosionWork(Gear: PGear);
       
  2989 var maxMovement: LongInt;
       
  2990 begin
       
  2991 inc(Gear^.Timer);
       
  2992 if (Gear^.Timer and 5) = 0 then
       
  2993     begin
       
  2994     maxMovement := max(1, 13 - ((Gear^.Timer * 15) div 250));
       
  2995     ShakeCamera(maxMovement);
       
  2996     end;
       
  2997 if Gear^.Timer > 250 then DeleteGear(Gear);
       
  2998 end;
       
  2999 
       
  3000 procedure doStepBigExplosion(Gear: PGear);
       
  3001 var i: LongWord;
       
  3002 gX,gY: LongInt;
       
  3003 begin
       
  3004 gX:= hwRound(Gear^.X);
       
  3005 gY:= hwRound(Gear^.Y);
       
  3006 AddVisualGear(gX, gY, vgtSmokeRing);
       
  3007 for i:= 0 to 46 do AddVisualGear(gX, gY, vgtFire);
       
  3008 for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart);
       
  3009 for i:= 0 to 15 do AddVisualGear(gX, gY, vgtExplPart2);
       
  3010 Gear^.doStep:= @doStepBigExplosionWork
       
  3011 end;
       
  3012 
       
  3013 ////////////////////////////////////////////////////////////////////////////////
       
  3014 procedure doStepEggWork(Gear: PGear);
  2909 procedure doStepEggWork(Gear: PGear);
  3015 var vg: PVisualGear;
  2910 var vg: PVisualGear;
  3016      i: LongInt;
  2911      i: LongInt;
  3017 begin
  2912 begin
  3018     AllInactive:= false;
  2913     AllInactive:= false;
  3104         if iterator = nil then
  2999         if iterator = nil then
  3105             break; // end of list
  3000             break; // end of list
  3106 
  3001 
  3107         // don't port portals or other gear that wouldn't make sense
  3002         // don't port portals or other gear that wouldn't make sense
  3108         if (iterator^.Kind = gtPortal)
  3003         if (iterator^.Kind = gtPortal)
  3109         or (iterator^.Kind = gtRope)
  3004         or (iterator^.Kind = gtRope) then
  3110         or (iterator^.Kind = gtHealthTag) then
       
  3111             continue;
  3005             continue;
  3112         
  3006         
  3113         // don't port hogs on rope
  3007         // don't port hogs on rope
  3114         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)
  3008         if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)
  3115             and (iterator = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope) then
  3009             and (iterator = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.Kind = gtRope) then
  3459             if getRandom(6) = 0 then
  3353             if getRandom(6) = 0 then
  3460                 AddGear(x - Gear^.Radius + LongInt(getRandom(2 * Gear^.Radius)), y - getRandom(Gear^.Radius + 1), gtFlame, gsttmpFlag, _0, _0, 0);
  3354                 AddGear(x - Gear^.Radius + LongInt(getRandom(2 * Gear^.Radius)), y - getRandom(Gear^.Radius + 1), gtFlame, gsttmpFlag, _0, _0, 0);
  3461             end;
  3355             end;
  3462 
  3356 
  3463         if getRandom(100) = 0 then
  3357         if getRandom(100) = 0 then
  3464             AddGear(x, y, gtSmokeTrace, 0, _0, _0, 0);
  3358             AddVisualGear(x, y, vgtSmokeTrace);
  3465         
  3359         
  3466         end
  3360         end
  3467         // if underwater get additional damage
  3361         // if underwater get additional damage
  3468         else dec(Gear^.Health, 5);
  3362         else dec(Gear^.Health, 5);
  3469     end;
  3363     end;