hedgewars/uGears.pas
branchwebgl
changeset 8444 75db7bb8dce8
parent 8330 aaefa587e277
parent 8425 4f226963faef
child 8833 c13ebed437cb
equal deleted inserted replaced
8340:46a9fde631f4 8444:75db7bb8dce8
    53 procedure AssignHHCoords;
    53 procedure AssignHHCoords;
    54 function  GearByUID(uid : Longword) : PGear;
    54 function  GearByUID(uid : Longword) : PGear;
    55 procedure doStepDrowningGear(Gear: PGear);
    55 procedure doStepDrowningGear(Gear: PGear);
    56 
    56 
    57 implementation
    57 implementation
    58 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
    58 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics, {$IFDEF SDL13}uTouch,{$ENDIF}
    59     uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uVariables,
    59     uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uVariables,
    60     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture,
    60     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug, uLandTexture,
    61     uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope;
    61     uGearsHedgehog, uGearsUtils, uGearsList, uGearsHandlers, uGearsHandlersRope;
    62 
    62 
    63 var skipFlag: boolean;
    63 var skipFlag: boolean;
    75     step: (stDelay, stChDmg, stSweep, stTurnReact,
    75     step: (stDelay, stChDmg, stSweep, stTurnReact,
    76     stAfterDelay, stChWin, stWater, stChWin2, stHealth,
    76     stAfterDelay, stChWin, stWater, stChWin2, stHealth,
    77     stSpawn, stNTurn);
    77     stSpawn, stNTurn);
    78     upd: Longword;
    78     upd: Longword;
    79     snowLeft,snowRight: LongInt;
    79     snowLeft,snowRight: LongInt;
       
    80     NewTurnTick: LongWord;
    80     //SDMusic: shortstring;
    81     //SDMusic: shortstring;
    81 
    82 
    82 // For better maintainability the step handlers of gears are stored in
    83 // For better maintainability the step handlers of gears are stored in
    83 // separate files.
    84 // separate files.
    84 // Note: step handlers of gears that are hedgehogs are in a different file
    85 // Note: step handlers of gears that are hedgehogs are in a different file
   186 procedure ProcessGears;
   187 procedure ProcessGears;
   187 var t: PGear;
   188 var t: PGear;
   188     i, AliveCount: LongInt;
   189     i, AliveCount: LongInt;
   189     s: shortstring;
   190     s: shortstring;
   190 begin
   191 begin
       
   192 ScriptCall('onGameTick');
       
   193 if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
       
   194 if GameTicks = NewTurnTick then
       
   195     begin
       
   196     ScriptCall('onNewTurn');
       
   197 {$IFDEF SDL13}
       
   198     uTouch.NewTurnBeginning();
       
   199 {$ENDIF}
       
   200     end;
       
   201 
   191 PrvInactive:= AllInactive;
   202 PrvInactive:= AllInactive;
   192 AllInactive:= true;
   203 AllInactive:= true;
   193 
   204 
   194 if (StepSoundTimer > 0) and (StepSoundChannel < 0) then
   205 if (StepSoundTimer > 0) and (StepSoundChannel < 0) then
   195     StepSoundChannel:= LoopSound(sndSteps)
   206     StepSoundChannel:= LoopSound(sndSteps)
   380 
   391 
   381                 ParseCommand('/nextturn', true);
   392                 ParseCommand('/nextturn', true);
   382                 SwitchHedgehog;
   393                 SwitchHedgehog;
   383 
   394 
   384                 AfterSwitchHedgehog;
   395                 AfterSwitchHedgehog;
   385                 bBetweenTurns:= false
   396                 bBetweenTurns:= false;
       
   397                 NewTurnTick:= GameTicks + 1
   386                 end;
   398                 end;
   387             step:= Low(step)
   399             step:= Low(step)
   388             end;
   400             end;
   389     end
   401     end
   390 else if ((GameFlags and gfInfAttack) <> 0) then
   402 else if ((GameFlags and gfInfAttack) <> 0) then
   467 
   479 
   468     if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then
   480     if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then
   469         inc(hiTicks) // we do not recieve a message for this
   481         inc(hiTicks) // we do not recieve a message for this
   470     end;
   482     end;
   471 AddRandomness(CheckSum);
   483 AddRandomness(CheckSum);
   472 ScriptCall('onGameTick');
       
   473 if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
       
   474 
   484 
   475 inc(GameTicks)
   485 inc(GameTicks)
   476 end;
   486 end;
   477 
   487 
   478 //Purpose, to reset all transient attributes toggled by a utility and clean up various gears and effects at end of turn
   488 //Purpose, to reset all transient attributes toggled by a utility and clean up various gears and effects at end of turn
  1394     delay2:= 0;
  1404     delay2:= 0;
  1395     step:= stDelay;
  1405     step:= stDelay;
  1396     upd:= 0;
  1406     upd:= 0;
  1397 
  1407 
  1398     //SDMusic:= 'hell.ogg';
  1408     //SDMusic:= 'hell.ogg';
       
  1409     NewTurnTick:= $FFFFFFFF;
  1399 end;
  1410 end;
  1400 
  1411 
  1401 procedure freeModule;
  1412 procedure freeModule;
  1402 begin
  1413 begin
  1403     FreeGearsList();
  1414     FreeGearsList();