hedgewars/uGears.pas
changeset 14572 34e810295d08
parent 14564 599f136d4f32
child 14656 db05d9bf7466
equal deleted inserted replaced
14571:1d3dc553829c 14572:34e810295d08
    65     step: (stInit, stDelay1, stChDmg, stSweep, stTurnStats, stChWin1,
    65     step: (stInit, stDelay1, stChDmg, stSweep, stTurnStats, stChWin1,
    66     stTurnReact, stDelay2, stChWin2, stWater, stChWin3,
    66     stTurnReact, stDelay2, stChWin2, stWater, stChWin3,
    67     stChKing, stSuddenDeath, stDelay3, stHealth, stSpawn, stDelay4,
    67     stChKing, stSuddenDeath, stDelay3, stHealth, stSpawn, stDelay4,
    68     stNTurn);
    68     stNTurn);
    69     NewTurnTick: LongWord;
    69     NewTurnTick: LongWord;
    70     //SDMusic: shortstring;
       
    71 
    70 
    72 const delaySDStart = 1600;
    71 const delaySDStart = 1600;
    73       delaySDWarning = 1000;
    72       delaySDWarning = 1000;
    74       delayDamageTagFull = 1500;
    73       delayDamageTagFull = 1500;
    75       delayDamageTagShort = 500;
    74       delayDamageTagShort = 500;
   279                 begin
   278                 begin
   280                 FreeAndNilTexture(curHandledGear^.Tex);
   279                 FreeAndNilTexture(curHandledGear^.Tex);
   281                 curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(curHandledGear^.Timer div 1000)), cWhiteColor, fntSmall);
   280                 curHandledGear^.Tex:= RenderStringTex(ansistring(inttostr(curHandledGear^.Timer div 1000)), cWhiteColor, fntSmall);
   282                 end;
   281                 end;
   283             curHandledGear^.doStep(curHandledGear);
   282             curHandledGear^.doStep(curHandledGear);
   284             // might be useful later
       
   285             //ScriptCall('onGearStep', Gear^.uid);
       
   286             end
   283             end
   287         end
   284         end
   288     end;
   285     end;
   289 if stirFallers then
   286 if stirFallers then
   290     begin
   287     begin
   538         end
   535         end
   539     end;
   536     end;
   540 
   537 
   541 if TurnTimeLeft > 0 then
   538 if TurnTimeLeft > 0 then
   542     if IsClockRunning() then
   539     if IsClockRunning() then
   543         //(CurrentHedgehog^.CurAmmoType in [amShotgun, amDEagle, amSniperRifle])
       
   544         begin
   540         begin
   545         if (cHedgehogTurnTime > TurnTimeLeft)
   541         if (cHedgehogTurnTime > TurnTimeLeft)
   546         and (CurrentHedgehog^.Gear <> nil)
   542         and (CurrentHedgehog^.Gear <> nil)
   547         and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0)
   543         and ((CurrentHedgehog^.Gear^.State and gstAttacked) = 0)
   548         and (not isGetAwayTime) and (ReadyTimeLeft = 0) then
   544         and (not isGetAwayTime) and (ReadyTimeLeft = 0) then
   626     if (CurrentTeam <> nil) then
   622     if (CurrentTeam <> nil) then
   627         with CurrentTeam^ do
   623         with CurrentTeam^ do
   628             for i:= 0 to cMaxHHIndex do
   624             for i:= 0 to cMaxHHIndex do
   629                 with Hedgehogs[i] do
   625                 with Hedgehogs[i] do
   630                     begin
   626                     begin
   631 (*
       
   632                     if (SpeechGear <> nil) then
       
   633                         begin
       
   634                         DeleteVisualGear(SpeechGear);  // remove to restore persisting beyond end of turn. Tiy says was too much of a gameplay issue
       
   635                         SpeechGear:= nil
       
   636                         end;
       
   637 *)
       
   638 
   627 
   639                     if (Gear <> nil) then
   628                     if (Gear <> nil) then
   640                         begin
   629                         begin
   641                         if (GameFlags and gfInvulnerable) = 0 then
   630                         if (GameFlags and gfInvulnerable) = 0 then
   642                             Gear^.Hedgehog^.Effects[heInvulnerable]:= 0;
   631                             Gear^.Hedgehog^.Effects[heInvulnerable]:= 0;
   796                             rdy:=Gear^.Y-Hedgehogs[h].Gear^.Y;
   785                             rdy:=Gear^.Y-Hedgehogs[h].Gear^.Y;
   797                             if (Gear^.Angle < $FFFFFFFF) and
   786                             if (Gear^.Angle < $FFFFFFFF) and
   798                                 ((rdx.Round+rdy.Round < Gear^.Angle) and
   787                                 ((rdx.Round+rdy.Round < Gear^.Angle) and
   799                                 (hwRound(hwSqr(rdx) + hwSqr(rdy)) < sqr(Gear^.Angle))) then
   788                                 (hwRound(hwSqr(rdx) + hwSqr(rdy)) < sqr(Gear^.Angle))) then
   800                                 begin
   789                                 begin
   801     // Debug line. Remove later
       
   802     // AddFileLog('Too Close to Hog @ (' + inttostr(rx) + ',' + inttostr(ry) + ')');
       
   803 
       
   804                                 p:= 1
   790                                 p:= 1
   805                                 end
   791                                 end
   806                             end;
   792                             end;
   807                         inc(h)
   793                         inc(h)
   808                         end;
   794                         end;
   848     rx:= GetRandom(rightX-leftX)+leftX;
   834     rx:= GetRandom(rightX-leftX)+leftX;
   849     ry:= GetRandom(LAND_HEIGHT-topY)+topY;
   835     ry:= GetRandom(LAND_HEIGHT-topY)+topY;
   850     rdx:= _90-(GetRandomf*_360);
   836     rdx:= _90-(GetRandomf*_360);
   851     rdy:= _90-(GetRandomf*_360);
   837     rdy:= _90-(GetRandomf*_360);
   852     Gear:= AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF);
   838     Gear:= AddGear(rx, ry, gtGenericFaller, gstInvisible, rdx, rdy, $FFFFFFFF);
   853     // Tag=1: This allows this generic faller to be displaced randomly by events
   839     // This allows this generic faller to be displaced randomly by events
   854     Gear^.Tag:= 1;
   840     Gear^.Tag:= 1;
   855     end;
   841     end;
   856 
   842 
   857 snowRight:= max(LAND_WIDTH,4096)+512;
   843 snowRight:= max(LAND_WIDTH,4096)+512;
   858 snowLeft:= -(snowRight-LAND_WIDTH);
   844 snowLeft:= -(snowRight-LAND_WIDTH);
   981                                     Unplaced:= true
   967                                     Unplaced:= true
   982                                 else
   968                                 else
   983                                     FindPlace(Gear, false, t, t + playWidth div ClansCount, true);// could make Gear == nil;
   969                                     FindPlace(Gear, false, t, t + playWidth div ClansCount, true);// could make Gear == nil;
   984                                 if Gear <> nil then
   970                                 if Gear <> nil then
   985                                     begin
   971                                     begin
   986                                     //AddCI(Gear);  uncomment if new hogs should be able to spawn on top of old ones.
       
   987                                     Gear^.Pos:= GetRandom(49);
   972                                     Gear^.Pos:= GetRandom(49);
   988                                     // unless the world is wrapping, make outter teams face to map center
   973                                     // unless the world is wrapping, make outter teams face to map center
   989                                     if (WorldEdge <> weWrap) and ((p = 0) or (p = ClansCount - 1)) then
   974                                     if (WorldEdge <> weWrap) and ((p = 0) or (p = ClansCount - 1)) then
   990                                         Gear^.dX.isNegative:= (p <> 0)
   975                                         Gear^.dX.isNegative:= (p <> 0)
   991                                     else
   976                                     else
  1016             ar[i]^.Unplaced:= true
  1001             ar[i]^.Unplaced:= true
  1017         else
  1002         else
  1018             FindPlace(ar[i]^.Gear, false, leftX, rightX, true);
  1003             FindPlace(ar[i]^.Gear, false, leftX, rightX, true);
  1019         if ar[i]^.Gear <> nil then
  1004         if ar[i]^.Gear <> nil then
  1020             begin
  1005             begin
  1021             //AddCI(ar[i]^.Gear); uncomment if new hogs should be able to spawn on top of old ones
       
  1022             ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > leftX + playWidth div 2;
  1006             ar[i]^.Gear^.dX.isNegative:= hwRound(ar[i]^.Gear^.X) > leftX + playWidth div 2;
  1023             ar[i]^.Gear^.Pos:= GetRandom(19)
  1007             ar[i]^.Gear^.Pos:= GetRandom(19)
  1024             end;
  1008             end;
  1025         ar[i]:= ar[Count - 1];
  1009         ar[i]:= ar[Count - 1];
  1026         dec(Count)
  1010         dec(Count)
  1275     else if x < 4 then
  1259     else if x < 4 then
  1276         text:= copy(s, 3, Length(s) - 1)
  1260         text:= copy(s, 3, Length(s) - 1)
  1277     else text:= copy(s, 2, Length(s) - 1);
  1261     else text:= copy(s, 2, Length(s) - 1);
  1278 
  1262 
  1279     if text = '' then text:= '...';
  1263     if text = '' then text:= '...';
  1280 
       
  1281     (*
       
  1282     if CheckNoTeamOrHH then
       
  1283         begin
       
  1284         ParseCommand('say ' + text, true);
       
  1285         exit
       
  1286         end;
       
  1287     *)
       
  1288 
  1264 
  1289     if (x < 4) and (TeamsArray[t] <> nil) then
  1265     if (x < 4) and (TeamsArray[t] <> nil) then
  1290         begin
  1266         begin
  1291             // if team matches current hedgehog team, default to current hedgehog
  1267             // if team matches current hedgehog team, default to current hedgehog
  1292             if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then
  1268             if (i = 0) and (CurrentHedgehog <> nil) and (CurrentHedgehog^.Team = TeamsArray[t]) then
  1420     delay:= 0;
  1396     delay:= 0;
  1421     delay2:= 0;
  1397     delay2:= 0;
  1422     step:= stDelay1;
  1398     step:= stDelay1;
  1423     upd:= 0;
  1399     upd:= 0;
  1424 
  1400 
  1425     //SDMusic:= 'hell.ogg';
       
  1426     NewTurnTick:= $FFFFFFFF;
  1401     NewTurnTick:= $FFFFFFFF;
  1427 end;
  1402 end;
  1428 
  1403 
  1429 procedure freeModule;
  1404 procedure freeModule;
  1430 begin
  1405 begin