DEADSOFTWARE

added player handicap
authorfgsfds <pvt.fgsfds@gmail.com>
Mon, 6 May 2019 15:50:22 +0000 (18:50 +0300)
committerfgsfds <pvt.fgsfds@gmail.com>
Mon, 6 May 2019 15:50:22 +0000 (18:50 +0300)
can only specify it for bots for now

src/game/g_game.pas
src/game/g_player.pas

index 4282e66642f47be224e827ff0cefef9c2f894a3e..7a70840b33b47db24b85276e7d1d63f77f1f26e1 100644 (file)
@@ -6408,7 +6408,9 @@ begin
   else if (cmd = 'addbot') or
      (cmd = 'bot_add') then
   begin
   else if (cmd = 'addbot') or
      (cmd = 'bot_add') then
   begin
-    if Length(P) > 1 then
+    if Length(P) > 2 then
+      g_Bot_Add(TEAM_NONE, StrToIntDef(P[1], 2), StrToIntDef(P[2], 100))
+    else if Length(P) > 1 then
       g_Bot_Add(TEAM_NONE, StrToIntDef(P[1], 2))
     else
       g_Bot_Add(TEAM_NONE, 2);
       g_Bot_Add(TEAM_NONE, StrToIntDef(P[1], 2))
     else
       g_Bot_Add(TEAM_NONE, 2);
@@ -6416,10 +6418,14 @@ begin
   else if cmd = 'bot_addlist' then
   begin
     if Length(P) > 1 then
   else if cmd = 'bot_addlist' then
   begin
     if Length(P) > 1 then
+    begin
       if Length(P) = 2 then
         g_Bot_AddList(TEAM_NONE, P[1], StrToIntDef(P[1], -1))
       if Length(P) = 2 then
         g_Bot_AddList(TEAM_NONE, P[1], StrToIntDef(P[1], -1))
+      else if Length(P) = 3 then
+        g_Bot_AddList(TEAM_NONE, P[1], StrToIntDef(P[1], -1), StrToIntDef(P[2], 100))
       else
         g_Bot_AddList(IfThen(P[2] = 'red', TEAM_RED, TEAM_BLUE), P[1], StrToIntDef(P[1], -1));
       else
         g_Bot_AddList(IfThen(P[2] = 'red', TEAM_RED, TEAM_BLUE), P[1], StrToIntDef(P[1], -1));
+    end;
   end
   else if cmd = 'bot_removeall' then
     g_Bot_RemoveAll()
   end
   else if cmd = 'bot_removeall' then
     g_Bot_RemoveAll()
index da4c43a84e12561afef525e41c84ce7eb8e04d4a..88070c61c04866a6c79bcea7dc8d39f88545fa12 100644 (file)
@@ -266,6 +266,7 @@ type
     FReady:     Boolean;
     FDummy:     Boolean;
     FFireTime:  Integer;
     FReady:     Boolean;
     FDummy:     Boolean;
     FFireTime:  Integer;
+    FHandicap:  Integer;
 
     // debug: viewport offset
     viewPortX, viewPortY, viewPortW, viewPortH: Integer;
 
     // debug: viewport offset
     viewPortX, viewPortY, viewPortW, viewPortH: Integer;
@@ -595,8 +596,8 @@ procedure g_Player_RemoveAllCorpses();
 procedure g_Player_Corpses_SaveState (st: TStream);
 procedure g_Player_Corpses_LoadState (st: TStream);
 procedure g_Player_ResetReady();
 procedure g_Player_Corpses_SaveState (st: TStream);
 procedure g_Player_Corpses_LoadState (st: TStream);
 procedure g_Player_ResetReady();
-procedure g_Bot_Add(Team, Difficult: Byte);
-procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1);
+procedure g_Bot_Add(Team, Difficult: Byte; Handicap: Integer = 100);
+procedure g_Bot_AddList(Team: Byte; lname: ShortString; num: Integer = -1; Handicap: Integer = 100);
 procedure g_Bot_MixNames();
 procedure g_Bot_RemoveAll();
 
 procedure g_Bot_MixNames();
 procedure g_Bot_RemoveAll();
 
@@ -885,6 +886,8 @@ begin
   if b = 1 then gPlayers[a].FDirection := TDirection.D_LEFT else gPlayers[a].FDirection := TDirection.D_RIGHT; // b = 2
   // Çäîðîâüå
   gPlayers[a].FHealth := utils.readLongInt(st);
   if b = 1 then gPlayers[a].FDirection := TDirection.D_LEFT else gPlayers[a].FDirection := TDirection.D_RIGHT; // b = 2
   // Çäîðîâüå
   gPlayers[a].FHealth := utils.readLongInt(st);
+  // Ôîðà
+  gPlayers[a].FHandicap := utils.readLongInt(st);
   // Æèçíè
   gPlayers[a].FLives := utils.readByte(st);
   // Áðîíÿ
   // Æèçíè
   gPlayers[a].FLives := utils.readByte(st);
   // Áðîíÿ
@@ -1006,7 +1009,7 @@ begin
       end;
 end;
 
       end;
 end;
 
-procedure g_Bot_Add(Team, Difficult: Byte);
+procedure g_Bot_Add(Team, Difficult: Byte; Handicap: Integer = 100);
 var
   m: SSArray;
   _name, _model: String;
 var
   m: SSArray;
   _name, _model: String;
@@ -1095,6 +1098,8 @@ begin
       //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
     end;
 
       //FDifficult.SafeWeaponPrior[a] := WEAPON_PRIOR3[a];
     end;
 
+    FHandicap := Handicap;
+
     g_Console_Add(Format(_lc[I_PLAYER_JOIN], [Name]), True);
 
     if g_Game_IsNet then MH_SEND_PlayerCreate(UID);
     g_Console_Add(Format(_lc[I_PLAYER_JOIN], [Name]), True);
 
     if g_Game_IsNet then MH_SEND_PlayerCreate(UID);
@@ -1103,7 +1108,7 @@ begin
   end;
 end;
 
   end;
 end;
 
-procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1);
+procedure g_Bot_AddList(Team: Byte; lName: ShortString; num: Integer = -1; Handicap: Integer = 100);
 var
   m: SSArray;
   _name, _model: String;
 var
   m: SSArray;
   _name, _model: String;
@@ -1166,6 +1171,8 @@ begin
     FDifficult.Cover := BotList[num].cover;
     FDifficult.CloseJump := BotList[num].close_jump;
 
     FDifficult.Cover := BotList[num].cover;
     FDifficult.CloseJump := BotList[num].close_jump;
 
+    FHandicap := Handicap;
+
     for a := WP_FIRST to WP_LAST do
     begin
       FDifficult.WeaponPrior[a] := BotList[num].w_prior1[a];
     for a := WP_FIRST to WP_LAST do
     begin
       FDifficult.WeaponPrior[a] := BotList[num].w_prior1[a];
@@ -2152,6 +2159,7 @@ begin
   FFireTime := 0;
   FFirePainTime := 0;
   FFireAttacker := 0;
   FFireTime := 0;
   FFirePainTime := 0;
   FFireAttacker := 0;
+  FHandicap := 100;
 
   FActualModelName := 'doomer';
 
 
   FActualModelName := 'doomer';
 
@@ -4526,7 +4534,7 @@ begin
 // Âîñêðåøåíèå áåç îðóæèÿ:
   if not FAlive then
   begin
 // Âîñêðåøåíèå áåç îðóæèÿ:
   if not FAlive then
   begin
-    FHealth := PLAYER_HP_SOFT;
+    FHealth := Round(PLAYER_HP_SOFT * (FHandicap / 100));
     FArmor := 0;
     FAlive := True;
     FAir := AIR_DEF;
     FArmor := 0;
     FAlive := True;
     FAir := AIR_DEF;
@@ -5924,6 +5932,8 @@ begin
   utils.writeInt(st, Byte(b));
   // Çäîðîâüå
   utils.writeInt(st, LongInt(FHealth));
   utils.writeInt(st, Byte(b));
   // Çäîðîâüå
   utils.writeInt(st, LongInt(FHealth));
+  // Êîýôôèöèåíò èíâàëèäíîñòè
+  utils.writeInt(st, LongInt(FHandicap));
   // Æèçíè
   utils.writeInt(st, Byte(FLives));
   // Áðîíÿ
   // Æèçíè
   utils.writeInt(st, Byte(FLives));
   // Áðîíÿ
@@ -6026,6 +6036,8 @@ begin
   if b = 1 then FDirection := TDirection.D_LEFT else FDirection := TDirection.D_RIGHT; // b = 2
   // Çäîðîâüå
   FHealth := utils.readLongInt(st);
   if b = 1 then FDirection := TDirection.D_LEFT else FDirection := TDirection.D_RIGHT; // b = 2
   // Çäîðîâüå
   FHealth := utils.readLongInt(st);
+  // Êîýôôèöèåíò èíâàëèäíîñòè
+  FHandicap := utils.readLongInt(st);
   // Æèçíè
   FLives := utils.readByte(st);
   // Áðîíÿ
   // Æèçíè
   FLives := utils.readByte(st);
   // Áðîíÿ