hedgewars/uGears.pas
branchwebgl
changeset 8099 a7f02b902b6f
parent 8096 453917e94e55
child 8330 aaefa587e277
equal deleted inserted replaced
8096:453917e94e55 8099:a7f02b902b6f
    96     if (Gear^.Kind = gtHedgehog) and (((GameFlags and gfInfAttack) = 0) or ((Gear^.dX.QWordValue < _0_000004.QWordValue)
    96     if (Gear^.Kind = gtHedgehog) and (((GameFlags and gfInfAttack) = 0) or ((Gear^.dX.QWordValue < _0_000004.QWordValue)
    97     and (Gear^.dY.QWordValue < _0_000004.QWordValue))) then
    97     and (Gear^.dY.QWordValue < _0_000004.QWordValue))) then
    98         begin
    98         begin
    99         if (not isInMultiShoot) then
    99         if (not isInMultiShoot) then
   100             inc(Gear^.Damage, Gear^.Karma);
   100             inc(Gear^.Damage, Gear^.Karma);
   101         if (Gear^.Damage <> 0) and (not Gear^.Invulnerable) then
   101         if ((Gear^.Damage <> 0) and (not Gear^.Invulnerable)) then
   102             begin
   102             begin
   103             CheckNoDamage:= false;
   103             CheckNoDamage:= false;
   104 
   104 
   105             dmg:= Gear^.Damage;
   105             dmg:= Gear^.Damage;
   106             if Gear^.Health < dmg then
   106             if Gear^.Health < dmg then
   163                 team:= Gear^.Hedgehog^.Team;
   163                 team:= Gear^.Hedgehog^.Team;
   164                 for i:= 0 to Pred(team^.HedgehogsNumber) do
   164                 for i:= 0 to Pred(team^.HedgehogsNumber) do
   165                     if (team^.Hedgehogs[i].Gear <> nil) and (not team^.Hedgehogs[i].King)
   165                     if (team^.Hedgehogs[i].Gear <> nil) and (not team^.Hedgehogs[i].King)
   166                     and (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) then
   166                     and (team^.Hedgehogs[i].Gear^.Health > team^.Hedgehogs[i].Gear^.Damage) then
   167                         flag:= true;
   167                         flag:= true;
   168                 if not flag then
   168                 if (not flag) then
   169                     begin
   169                     begin
   170                     inc(tmp, 5);
   170                     inc(tmp, 5);
   171                     if (GameFlags and gfResetHealth) <> 0 then
   171                     if (GameFlags and gfResetHealth) <> 0 then
   172                         dec(Gear^.Hedgehog^.InitialHealth, 5)
   172                         dec(Gear^.Hedgehog^.InitialHealth, 5)
   173                     end
   173                     end
   215         if curHandledGear^.Message and gmRemoveFromList <> 0 then 
   215         if curHandledGear^.Message and gmRemoveFromList <> 0 then 
   216             begin
   216             begin
   217             RemoveGearFromList(curHandledGear);
   217             RemoveGearFromList(curHandledGear);
   218             // 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
   218             // 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
   219             if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
   219             if curHandledGear^.Message and gmAddToList <> 0 then InsertGearToList(curHandledGear);
   220             curHandledGear^.Message:= curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList))
   220             curHandledGear^.Message:= (curHandledGear^.Message and (not (gmRemoveFromList or gmAddToList)))
   221             end;
   221             end;
   222         if curHandledGear^.Active then
   222         if curHandledGear^.Active then
   223             begin
   223             begin
   224             if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then
   224             if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then
   225                 begin
   225                 begin
   330                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   330                 AddCaption(trmsg[sidSuddenDeath], cWhiteColor, capgrpGameState);
   331                 playSound(sndSuddenDeath);
   331                 playSound(sndSuddenDeath);
   332                 StopMusic //No SDMusic for now
   332                 StopMusic //No SDMusic for now
   333                     //ChangeMusic(SDMusic)
   333                     //ChangeMusic(SDMusic)
   334                     end
   334                     end
   335                 else if (TotalRounds < cSuddenDTurns) and (not isInMultiShoot) then
   335                 else if ((TotalRounds < cSuddenDTurns) and (not isInMultiShoot)) then
   336                     begin
   336                     begin
   337                     i:= cSuddenDTurns - TotalRounds;
   337                     i:= cSuddenDTurns - TotalRounds;
   338                     s:= inttostr(i);
   338                     s:= inttostr(i);
   339                     if i = 1 then
   339                     if i = 1 then
   340                         AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
   340                         AddCaption(trmsg[sidRoundSD], cWhiteColor, capgrpGameState)
   353                 step:= stChDmg
   353                 step:= stChDmg
   354                 end
   354                 end
   355             end;
   355             end;
   356     stSpawn:
   356     stSpawn:
   357         begin
   357         begin
   358         if not isInMultiShoot then
   358         if (not isInMultiShoot) then
   359             SpawnBoxOfSmth;
   359             SpawnBoxOfSmth;
   360         inc(step)
   360         inc(step)
   361         end;
   361         end;
   362     stNTurn:
   362     stNTurn:
   363         begin
   363         begin
   402             and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
   402             and (Ammoz[CurrentHedgehog^.CurAmmoType].Ammo.Propz and ammoprop_NeedTarget <> 0) then
   403                 begin
   403                 begin
   404                 CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstHHChooseTarget;
   404                 CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstHHChooseTarget;
   405                 isCursorVisible := true
   405                 isCursorVisible := true
   406                 end;
   406                 end;
   407             CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State and (not gstAttacked);
   407             CurrentHedgehog^.Gear^.State:= (CurrentHedgehog^.Gear^.State and (not gstAttacked));
   408             end;
   408             end;
   409         if delay2 = 0 then
   409         if delay2 = 0 then
   410             begin
   410             begin
   411             if (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.State and gstAttacked = 0)
   411             if (CurrentHedgehog^.Gear <> nil) and (CurrentHedgehog^.Gear^.State and gstAttacked = 0)
   412             and (CurAmmoGear = nil) then
   412             and (CurAmmoGear = nil) then
   700 
   700 
   701                         DeleteCI(t);
   701                         DeleteCI(t);
   702                         t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX);
   702                         t^.dX:= t^.dX + Gear^.dX * dmg * _0_01 + SignAs(cHHKick, Gear^.dX);
   703                         t^.dY:= t^.dY + Gear^.dY * dmg * _0_01;
   703                         t^.dY:= t^.dY + Gear^.dY * dmg * _0_01;
   704                         t^.State:= t^.State or gstMoving;
   704                         t^.State:= t^.State or gstMoving;
   705                         if t^.Kind = gtKnife then t^.State:= t^.State and (not gstCollision);
   705                         if t^.Kind = gtKnife then t^.State:= (t^.State and (not gstCollision));
   706                         t^.Active:= true;
   706                         t^.Active:= true;
   707                         FollowGear:= t
   707                         FollowGear:= t
   708                         end
   708                         end
   709                     end;
   709                     end;
   710             gtGrave: begin
   710             gtGrave: begin
   811             else
   811             else
   812                 Gear^.State:= Gear^.State or gstWinner;
   812                 Gear^.State:= Gear^.State or gstWinner;
   813             if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then 
   813             if (Gear^.Kind = gtExplosives) and (Ammo^.Kind = gtBlowtorch) then 
   814                 begin
   814                 begin
   815                 if (Ammo^.Hedgehog^.Gear <> nil) then
   815                 if (Ammo^.Hedgehog^.Gear <> nil) then
   816                     Ammo^.Hedgehog^.Gear^.State:= Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable);
   816                     Ammo^.Hedgehog^.Gear^.State:= (Ammo^.Hedgehog^.Gear^.State and (not gstNotKickable));
   817                 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
   817                 ApplyDamage(Gear, Ammo^.Hedgehog, tmpDmg * 100, dsUnknown); // crank up damage for explosives + blowtorch
   818                 end;
   818                 end;
   819 
   819 
   820             if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then
   820             if (Gear^.Kind = gtHedgehog) and Gear^.Hedgehog^.King then
   821                 begin
   821                 begin
   831             if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
   831             if (not isZero(Gear^.dX)) or (not isZero(Gear^.dY)) then
   832                 begin
   832                 begin
   833                 Gear^.Active:= true;
   833                 Gear^.Active:= true;
   834                 DeleteCI(Gear);
   834                 DeleteCI(Gear);
   835                 Gear^.State:= Gear^.State or gstMoving;
   835                 Gear^.State:= Gear^.State or gstMoving;
   836                 if Gear^.Kind = gtKnife then Gear^.State:= Gear^.State and (not gstCollision);
   836                 if Gear^.Kind = gtKnife then Gear^.State:= (Gear^.State and (not gstCollision));
   837                 // move the gear upwards a bit to throw it over tiny obstacles at start
   837                 // move the gear upwards a bit to throw it over tiny obstacles at start
   838                 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   838                 if TestCollisionXwithGear(Gear, hwSign(Gear^.dX)) then
   839                     begin
   839                     begin
   840                     if not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX))
   840                     if (not (TestCollisionXwithXYShift(Gear, _0, -3, hwSign(Gear^.dX)))
   841                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   841                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   842                         Gear^.Y:= Gear^.Y - _1;
   842                         Gear^.Y:= Gear^.Y - _1;
   843                     if not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX))
   843                     if (not (TestCollisionXwithXYShift(Gear, _0, -2, hwSign(Gear^.dX)))
   844                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   844                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   845                         Gear^.Y:= Gear^.Y - _1;
   845                         Gear^.Y:= Gear^.Y - _1;
   846                     if not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX))
   846                     if (not (TestCollisionXwithXYShift(Gear, _0, -1, hwSign(Gear^.dX)))
   847                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   847                     or (TestCollisionYwithGear(Gear, -1) <> 0)) then
   848                         Gear^.Y:= Gear^.Y - _1;
   848                         Gear^.Y:= Gear^.Y - _1;
   849                     end
   849                     end
   850                 end;
   850                 end;
   851 
   851 
   959 begin
   959 begin
   960 t:= GearsList;
   960 t:= GearsList;
   961 while t <> nil do
   961 while t <> nil do
   962     begin
   962     begin
   963     if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then
   963     if (t^.Kind = gtHedgehog) and (t^.Y < Ammo^.Y) then
   964         if not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2) then
   964         if (not (hwSqr(Ammo^.X - t^.X) + hwSqr(Ammo^.Y - t^.Y - int2hwFloat(cHHRadius)) * 2 > _2)) then
   965             begin
   965             begin
   966             ApplyDamage(t, 5);
   966             ApplyDamage(t, 5);
   967             t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02;
   967             t^.dX:= t^.dX + (t^.X - Ammo^.X) * _0_02;
   968             t^.dY:= - _0_25;
   968             t^.dY:= - _0_25;
   969             t^.Active:= true;
   969             t^.Active:= true;
  1224 
  1224 
  1225 
  1225 
  1226 procedure chSkip(var s: shortstring);
  1226 procedure chSkip(var s: shortstring);
  1227 begin
  1227 begin
  1228 s:= s; // avoid compiler hint
  1228 s:= s; // avoid compiler hint
  1229 if not isExternalSource then
  1229 if (not isExternalSource) then
  1230     SendIPC(_S',');
  1230     SendIPC(_S',');
  1231 uStats.Skipped;
  1231 uStats.Skipped;
  1232 skipFlag:= true
  1232 skipFlag:= true
  1233 end;
  1233 end;
  1234 
  1234