fix debug caused by SendIcons. Fix max stamina. Fix character say. Fully finish 7.81 basic implementation.

This commit is contained in:
ErikasKontenis 2019-11-13 17:06:13 +02:00
parent 527debe319
commit 05af593814
6 changed files with 64 additions and 63 deletions

View File

@ -52,7 +52,7 @@ timeBetweenExActions = 1000
-- Map
-- NOTE: set mapName WITHOUT .otbm at the end
mapName = "mymap"
mapName = "map"
mapAuthor = "CipSoft"
-- MySQL

View File

@ -1125,6 +1125,7 @@ CREATE TABLE `players` (
`lookhead` int(11) NOT NULL DEFAULT '0',
`looklegs` int(11) NOT NULL DEFAULT '0',
`looktype` int(11) NOT NULL DEFAULT '136',
`lookaddons` int(11) NOT NULL DEFAULT '0',
`maglevel` int(11) NOT NULL DEFAULT '0',
`mana` int(11) NOT NULL DEFAULT '0',
`manamax` int(11) NOT NULL DEFAULT '0',
@ -1147,6 +1148,7 @@ CREATE TABLE `players` (
`onlinetime` int(11) NOT NULL DEFAULT '0',
`deletion` bigint(15) NOT NULL DEFAULT '0',
`balance` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`stamina` smallint(5) NOT NULL DEFAULT '3360',
`skill_fist` int(10) UNSIGNED NOT NULL DEFAULT '10',
`skill_fist_tries` bigint(20) UNSIGNED NOT NULL DEFAULT '0',
`skill_club` int(10) UNSIGNED NOT NULL DEFAULT '10',

View File

@ -7783,7 +7783,7 @@ int LuaScriptInterface::luaPlayerSetStamina(lua_State* L)
uint16_t stamina = getNumber<uint16_t>(L, 2);
Player* player = getUserdata<Player>(L, 1);
if (player) {
player->staminaMinutes = std::min<uint16_t>(2520, stamina);
player->staminaMinutes = std::min<uint16_t>(3360, stamina);
player->sendStats();
pushBoolean(L, true);
}

View File

@ -1046,7 +1046,7 @@ class Player final : public Creature, public Cylinder
int32_t shieldBlockCount = 0;
int32_t idleTime = 0;
uint16_t staminaMinutes = 2520;
uint16_t staminaMinutes = 3360;
uint16_t maxWriteLen = 0;
uint8_t soul = 0;

View File

@ -1168,11 +1168,12 @@ void ProtocolGame::sendChannel(uint16_t channelId, const std::string& channelNam
writeToOutputBuffer(msg);
}
void ProtocolGame::sendIcons(uint16_t icons)
{
NetworkMessage msg;
msg.addByte(0xA2);
msg.addByte(static_cast<uint8_t>(icons));
msg.add<uint16_t>(icons);
writeToOutputBuffer(msg);
}
@ -1204,6 +1205,8 @@ void ProtocolGame::sendContainer(uint8_t cid, const Container* container, bool h
writeToOutputBuffer(msg);
}
void ProtocolGame::sendTradeItemRequest(const std::string& traderName, const Item* item, bool ack)
{
NetworkMessage msg;
@ -1277,14 +1280,61 @@ void ProtocolGame::sendCreatureTurn(const Creature* creature, uint32_t stackPos)
void ProtocolGame::sendCreatureSay(const Creature* creature, SpeakClasses type, const std::string& text, const Position* pos/* = nullptr*/)
{
NetworkMessage msg;
AddCreatureSpeak(msg, creature, type, text, 0, pos);
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
msg.addString(creature->getName());
//Add level only for players
if (const Player* speaker = creature->getPlayer()) {
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint16_t>(0x00);
}
msg.addByte(type);
if (pos) {
msg.addPosition(*pos);
}
else {
msg.addPosition(creature->getPosition());
}
msg.addString(text);
writeToOutputBuffer(msg);
}
void ProtocolGame::sendToChannel(const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId)
{
NetworkMessage msg;
AddCreatureSpeak(msg, creature, type, text, channelId);
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
if (!creature) {
msg.add<uint32_t>(0x00);
}
else if (type == TALKTYPE_CHANNEL_R2) {
msg.add<uint32_t>(0x00);
type = TALKTYPE_CHANNEL_R1;
}
else {
msg.addString(creature->getName());
//Add level only for players
if (const Player* speaker = creature->getPlayer()) {
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint16_t>(0x00);
}
}
msg.addByte(type);
msg.add<uint16_t>(channelId);
msg.addString(text);
writeToOutputBuffer(msg);
}
@ -1294,16 +1344,13 @@ void ProtocolGame::sendPrivateMessage(const Player* speaker, SpeakClasses type,
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
if (type == TALKTYPE_RVR_ANSWER) {
msg.addString("Gamemaster");
} else {
if (speaker) {
msg.addString(speaker->getName());
} else {
msg.add<uint32_t>(0x00);
}
if (speaker) {
msg.addString(speaker->getName());
msg.add<uint16_t>(speaker->getLevel());
}
else {
msg.add<uint32_t>(0x00);
}
msg.addByte(type);
msg.addString(text);
writeToOutputBuffer(msg);
@ -1890,53 +1937,6 @@ void ProtocolGame::AddCreatureLight(NetworkMessage& msg, const Creature* creatur
msg.addByte(lightInfo.color);
}
void ProtocolGame::AddCreatureSpeak(NetworkMessage& msg, const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, const Position* pos /*= nullptr*/)
{
msg.addByte(0xAA);
static uint32_t statementId = 0;
msg.add<uint32_t>(++statementId);
if (type != TALKTYPE_RVR_ANSWER) {
if (type != TALKTYPE_CHANNEL_R2) {
if (creature) {
msg.addString(creature->getName());
} else {
msg.add<uint16_t>(0);
}
} else {
msg.add<uint16_t>(0);
}
}
msg.addByte(type);
switch (type) {
case TALKTYPE_SAY:
case TALKTYPE_WHISPER:
case TALKTYPE_YELL:
case TALKTYPE_MONSTER_SAY:
case TALKTYPE_MONSTER_YELL:
if (!pos) {
msg.addPosition(creature->getPosition());
} else {
msg.addPosition(*pos);
}
break;
case TALKTYPE_CHANNEL_Y:
case TALKTYPE_CHANNEL_R1:
case TALKTYPE_CHANNEL_R2:
case TALKTYPE_CHANNEL_O:
msg.add<uint16_t>(channelId);
break;
case TALKTYPE_RVR_CHANNEL:
msg.add<uint32_t>(0);
break;
default:
break;
}
msg.addString(text);
}
//tile
void ProtocolGame::RemoveTileThing(NetworkMessage& msg, const Position& pos, uint32_t stackpos)
{

View File

@ -234,7 +234,6 @@ class ProtocolGame final : public Protocol
void AddPlayerSkills(NetworkMessage& msg);
void AddWorldLight(NetworkMessage& msg, const LightInfo& lightInfo);
void AddCreatureLight(NetworkMessage& msg, const Creature* creature);
void AddCreatureSpeak(NetworkMessage& msg, const Creature* creature, SpeakClasses type, const std::string& text, uint16_t channelId, const Position* pos = nullptr);
//tiles
static void RemoveTileThing(NetworkMessage& msg, const Position& pos, uint32_t stackpos);