Browse Source

Protocol 10.76, fixed death window & death packet

TheSumm 5 years ago
parent
commit
83dc129f03

+ 3
- 2
modules/game_playerdeath/deathwindow.otui View File

@@ -1,10 +1,11 @@
1 1
 DeathWindow < MainWindow
2 2
   id: deathWindow
3 3
   !text: tr('You are dead')
4
-  size: 350 155
4
+  &baseWidth: 350
5
+  &baseHeight: 15
5 6
 
6 7
   Label
7
-    !text: tr('Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!')
8
+    id: labelText
8 9
     width: 550
9 10
     height: 140
10 11
     anchors.left: parent.left

+ 28
- 3
modules/game_playerdeath/playerdeath.lua View File

@@ -1,5 +1,11 @@
1 1
 deathWindow = nil
2 2
 
3
+local deathTexts = {
4
+  regular = {text = 'Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nSimply click on Ok to resume your journeys!', height = 140, width = 0},
5
+  unfair = {text = 'Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back\ninto this world in exchange for a small sacrifice\n\nThis death penalty has been reduced by %i%%\nbecause it was an unfair fight.\n\nSimply click on Ok to resume your journeys!', height = 185, width = 0},
6
+  blessed = {text = 'Alas! Brave adventurer, you have met a sad fate.\nBut do not despair, for the gods will bring you back into this world\n\nThis death penalty has been reduced by 100%\nbecause you are blessed with the Adventurer\'s Blessing\n\nSimply click on Ok to resume your journeys!', height = 170, width = 90}
7
+}
8
+
3 9
 function init()
4 10
   g_ui.importStyle('deathwindow')
5 11
 
@@ -21,9 +27,9 @@ function reset()
21 27
   end
22 28
 end
23 29
 
24
-function display()
30
+function display(deathType, penalty)
25 31
   displayDeadMessage()
26
-  openWindow()
32
+  openWindow(deathType, penalty)
27 33
 end
28 34
 
29 35
 function displayDeadMessage()
@@ -33,12 +39,31 @@ function displayDeadMessage()
33 39
   modules.game_textmessage.displayGameMessage(tr('You are dead.'))
34 40
 end
35 41
 
36
-function openWindow()
42
+function openWindow(deathType, penalty)
37 43
   if deathWindow then
38 44
     deathWindow:destroy()
39 45
     return
40 46
   end
47
+
41 48
   deathWindow = g_ui.createWidget('DeathWindow', rootWidget)
49
+
50
+  local textLabel = deathWindow:getChildById('labelText')
51
+  if deathType == DeathType.Regular then
52
+    if penalty == 100 then
53
+      textLabel:setText(deathTexts.regular.text)
54
+      deathWindow:setHeight(deathWindow.baseHeight + deathTexts.regular.height)
55
+      deathWindow:setWidth(deathWindow.baseWidth + deathTexts.regular.width)
56
+    else
57
+      textLabel:setText(string.format(deathTexts.unfair.text, 100 - penalty))
58
+      deathWindow:setHeight(deathWindow.baseHeight + deathTexts.unfair.height)
59
+      deathWindow:setWidth(deathWindow.baseWidth + deathTexts.unfair.width)
60
+    end
61
+  elseif deathType == DeathType.Blessed then
62
+    textLabel:setText(deathTexts.blessed.text)
63
+    deathWindow:setHeight(deathWindow.baseHeight + deathTexts.blessed.height)
64
+    deathWindow:setWidth(deathWindow.baseWidth + deathTexts.blessed.width)
65
+  end
66
+
42 67
   local okButton = deathWindow:getChildById('buttonOk')
43 68
   local cancelButton = deathWindow:getChildById('buttonCancel')
44 69
 

+ 6
- 0
modules/gamelib/const.lua View File

@@ -130,6 +130,7 @@ GameExperienceBonus = 66
130 130
 GameAuthenticator = 67
131 131
 GameUnjustifiedPoints = 68
132 132
 GameSessionKey = 69
133
+GameDeathType = 70
133 134
 
134 135
 TextColors = {
135 136
   red       = '#f55e5e', --'#c83200'
@@ -270,4 +271,9 @@ Blessings = {
270 271
   SparkOfPhoenix = 32
271 272
 }
272 273
 
274
+DeathType = {
275
+  Regular = 0,
276
+  Blessed = 1
277
+}
278
+
273 279
 -- @}

+ 1
- 1
modules/gamelib/game.lua View File

@@ -73,7 +73,7 @@ function g_game.getSupportedClients()
73 73
     1053, 1054, 1055, 1056, 1057,
74 74
     1058, 1059, 1060, 1061, 1062,
75 75
     1063, 1064, 1070, 1071, 1072,
76
-    1073, 1074, 1075
76
+    1073, 1074, 1075, 1076
77 77
   }
78 78
 end
79 79
 

+ 6
- 0
src/client/const.h View File

@@ -402,6 +402,7 @@ namespace Otc
402 402
         GameAuthenticator = 67,
403 403
         GameUnjustifiedPoints = 68,
404 404
         GameSessionKey = 69,
405
+        GameDeathType = 70,
405 406
 
406 407
         LastGameFeature = 101
407 408
     };
@@ -466,6 +467,11 @@ namespace Otc
466 467
         BlessingWisdomOfSolitude = 1 << 4,
467 468
         BlessingSparkOfPhoenix = 1 << 5
468 469
     };
470
+
471
+    enum DeathType {
472
+        DeathRegular = 0,
473
+        DeathBlessed = 1
474
+    };
469 475
 }
470 476
 
471 477
 #endif

+ 8
- 4
src/client/game.cpp View File

@@ -228,12 +228,12 @@ void Game::processGameEnd()
228 228
     g_map.cleanDynamicThings();
229 229
 }
230 230
 
231
-void Game::processDeath(int penality)
231
+void Game::processDeath(int deathType, int penality)
232 232
 {
233 233
     m_dead = true;
234 234
     m_localPlayer->stopWalk();
235 235
 
236
-    g_lua.callGlobalField("g_game", "onDeath", penality);
236
+    g_lua.callGlobalField("g_game", "onDeath", deathType, penality);
237 237
 }
238 238
 
239 239
 void Game::processGMActions(const std::vector<uint8>& actions)
@@ -1450,7 +1450,7 @@ void Game::setProtocolVersion(int version)
1450 1450
     if(isOnline())
1451 1451
         stdext::throw_exception("Unable to change protocol version while online");
1452 1452
 
1453
-    if(version != 0 && (version < 740 || version > 1075))
1453
+    if(version != 0 && (version < 740 || version > 1076))
1454 1454
         stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
1455 1455
 
1456 1456
     m_protocolVersion = version;
@@ -1468,7 +1468,7 @@ void Game::setClientVersion(int version)
1468 1468
     if(isOnline())
1469 1469
         stdext::throw_exception("Unable to change client version while online");
1470 1470
 
1471
-    if(version != 0 && (version < 740 || version > 1075))
1471
+    if(version != 0 && (version < 740 || version > 1076))
1472 1472
         stdext::throw_exception(stdext::format("Client version %d not supported", version));
1473 1473
 
1474 1474
     m_features.reset();
@@ -1596,6 +1596,10 @@ void Game::setClientVersion(int version)
1596 1596
         enableFeature(Otc::GameExperienceBonus);
1597 1597
     }
1598 1598
 
1599
+    if(version >= 1055) {
1600
+        enableFeature(Otc::GameDeathType);
1601
+    }
1602
+
1599 1603
     if(version >= 1061) {
1600 1604
         enableFeature(Otc::GameOGLInformation);
1601 1605
     }

+ 1
- 1
src/client/game.h View File

@@ -86,7 +86,7 @@ protected:
86 86
 
87 87
     void processGameStart();
88 88
     void processGameEnd();
89
-    void processDeath(int penality);
89
+    void processDeath(int deathType, int penality);
90 90
 
91 91
     void processGMActions(const std::vector<uint8>& actions);
92 92
     void processInventoryChange(int slot, const ItemPtr& item);

+ 8
- 2
src/client/protocolgameparse.cpp View File

@@ -537,9 +537,15 @@ void ProtocolGame::parseChallenge(const InputMessagePtr& msg)
537 537
 void ProtocolGame::parseDeath(const InputMessagePtr& msg)
538 538
 {
539 539
     int penality = 100;
540
-    if(g_game.getFeature(Otc::GamePenalityOnDeath))
540
+    int deathType = Otc::DeathRegular;
541
+
542
+    if(g_game.getFeature(Otc::GameDeathType))
543
+        deathType = msg->getU8();
544
+
545
+    if(g_game.getFeature(Otc::GamePenalityOnDeath) && deathType == Otc::DeathRegular)
541 546
         penality = msg->getU8();
542
-    g_game.processDeath(penality);
547
+
548
+    g_game.processDeath(deathType, penality);
543 549
 }
544 550
 
545 551
 void ProtocolGame::parseMapDescription(const InputMessagePtr& msg)

Loading…
Cancel
Save