hedgewars/uGears.pas
changeset 7442 9bb6abdb5675
parent 7426 55b49cc1f33a
child 7477 26706bf32ecf
equal deleted inserted replaced
7392:bc3306c59a08 7442:9bb6abdb5675
   180         Gear:= Gear^.NextGear
   180         Gear:= Gear^.NextGear
   181     end;
   181     end;
   182 end;
   182 end;
   183 
   183 
   184 procedure ProcessGears;
   184 procedure ProcessGears;
   185 var Gear, t: PGear;
   185 var t: PGear;
   186     i, AliveCount: LongInt;
   186     i, AliveCount: LongInt;
   187     s: shortstring;
   187     s: shortstring;
   188 begin
   188 begin
   189 PrvInactive:= AllInactive;
   189 PrvInactive:= AllInactive;
   190 AllInactive:= true;
   190 AllInactive:= true;
   201     dec(StepSoundTimer, 1);
   201     dec(StepSoundTimer, 1);
   202 
   202 
   203 t:= GearsList;
   203 t:= GearsList;
   204 while t <> nil do
   204 while t <> nil do
   205     begin
   205     begin
   206     Gear:= t;
   206     curHandledGear:= t;
   207     t:= Gear^.NextGear;
   207     t:= curHandledGear^.NextGear;
   208 
   208 
   209     if Gear^.Active then
   209     if curHandledGear^.Message and gmRemoveFromList <> 0 then 
   210         begin
   210         begin
   211         if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
   211         RemoveGearFromList(curHandledGear);
   212             begin
   212         // since I can't think of any good reason this would ever be separate from a remove from list, going to keep it inside this block
   213             FreeTexture(Gear^.Tex);
   213         if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
   214             Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), cWhiteColor, fntSmall);
   214         curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))
   215             end;
   215         end;
   216         Gear^.doStep(Gear);
   216     if curHandledGear^.Active then
       
   217         begin
       
   218         if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then
       
   219             begin
       
   220             FreeTexture(curHandledGear^.Tex);
       
   221             curHandledGear^.Tex:= RenderStringTex(inttostr(curHandledGear^.Timer div 1000), cWhiteColor, fntSmall);
       
   222             end;
       
   223         curHandledGear^.doStep(curHandledGear);
   217         // might be useful later
   224         // might be useful later
   218         //ScriptCall('onGearStep', Gear^.uid);
   225         //ScriptCall('onGearStep', Gear^.uid);
   219         end
   226         end
   220     end;
   227     end;
       
   228 curHandledGear:= nil;
   221 
   229 
   222 if AllInactive then
   230 if AllInactive then
   223 case step of
   231 case step of
   224     stDelay:
   232     stDelay:
   225         begin
   233         begin
   451         end;
   459         end;
   452 
   460 
   453     if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then
   461     if (not CurrentTeam^.ExtDriven) or CurrentTeam^.hasGone then
   454         inc(hiTicks) // we do not recieve a message for this
   462         inc(hiTicks) // we do not recieve a message for this
   455     end;
   463     end;
   456 
   464 AddRandomness(CheckSum);
   457 ScriptCall('onGameTick');
   465 ScriptCall('onGameTick');
   458 if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
   466 if GameTicks mod 20 = 0 then ScriptCall('onGameTick20');
   459 inc(GameTicks)
   467 inc(GameTicks)
   460 end;
   468 end;
   461 
   469 
   578         Dispose(t)
   586         Dispose(t)
   579     end;
   587     end;
   580 end;
   588 end;
   581 
   589 
   582 procedure AddMiscGears;
   590 procedure AddMiscGears;
   583 var i: Longword;
   591 var i,rx, ry: Longword;
       
   592     rdx, rdy: hwFloat;
   584     Gear: PGear;
   593     Gear: PGear;
   585 begin
   594 begin
   586 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
   595 AddGear(0, 0, gtATStartGame, 0, _0, _0, 2000);
   587 
   596 
   588 i:= 0;
   597 i:= 0;
   623 if (GameFlags and gfLaserSight) <> 0 then
   632 if (GameFlags and gfLaserSight) <> 0 then
   624     cLaserSighting:= true;
   633     cLaserSighting:= true;
   625 
   634 
   626 if (GameFlags and gfArtillery) <> 0 then
   635 if (GameFlags and gfArtillery) <> 0 then
   627     cArtillery:= true;
   636     cArtillery:= true;
       
   637 for i:= GetRandom(10)+30 downto 0 do
       
   638     begin                                                                                                                                       rx:= GetRandom(rightX-leftX)+leftX;
       
   639     ry:= GetRandom(LAND_HEIGHT-topY)+topY;
       
   640     rdx:= _90-(GetRandomf*_360);
       
   641     rdy:= _90-(GetRandomf*_360);
       
   642     AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF);
       
   643     end;
   628 
   644 
   629 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
   645 if not hasBorder and ((Theme = 'Snow') or (Theme = 'Christmas')) then
   630     for i:= 0 to Pred(vobCount*2) do
   646     for i:= 0 to Pred(vobCount*2) do
   631         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
   647         AddGear(GetRandom(LAND_WIDTH+1024)-512, LAND_HEIGHT - GetRandom(LAND_HEIGHT div 2), gtFlake, 0, _0, _0, 0);
   632 end;
   648 end;
  1311             @doStepSnowball,
  1327             @doStepSnowball,
  1312             @doStepSnowflake,
  1328             @doStepSnowflake,
  1313             @doStepStructure,
  1329             @doStepStructure,
  1314             @doStepLandGun,
  1330             @doStepLandGun,
  1315             @doStepTardis,
  1331             @doStepTardis,
  1316             @doStepIceGun);
  1332             @doStepIceGun,
       
  1333             @doStepAddAmmo,
       
  1334             @doStepGenericFaller);
  1317 begin
  1335 begin
  1318     doStepHandlers:= handlers;
  1336     doStepHandlers:= handlers;
  1319 
  1337 
  1320     RegisterVariable('skip', @chSkip, false);
  1338     RegisterVariable('skip', @chSkip, false);
  1321     RegisterVariable('hogsay', @chHogSay, true );
  1339     RegisterVariable('hogsay', @chHogSay, true );
  1322 
  1340 
  1323     CurAmmoGear:= nil;
  1341     CurAmmoGear:= nil;
  1324     GearsList:= nil;
  1342     GearsList:= nil;
       
  1343     curHandledGear:= nil;
       
  1344 
  1325     KilledHHs:= 0;
  1345     KilledHHs:= 0;
  1326     SuddenDeath:= false;
  1346     SuddenDeath:= false;
  1327     SuddenDeathDmg:= false;
  1347     SuddenDeathDmg:= false;
  1328     SpeechType:= 1;
  1348     SpeechType:= 1;
  1329     skipFlag:= false;
  1349     skipFlag:= false;