introduce physical damage calculator for paladins and knights

This commit is contained in:
ErikasKontenis
2020-10-15 13:52:34 +03:00
parent b0b93edcb4
commit 6904342e06
9 changed files with 324 additions and 157 deletions

View File

@@ -2267,6 +2267,7 @@ void LuaScriptInterface::registerFunctions()
registerMethod("ItemType", "getDefense", LuaScriptInterface::luaItemTypeGetDefense);
registerMethod("ItemType", "getArmor", LuaScriptInterface::luaItemTypeGetArmor);
registerMethod("ItemType", "getWeaponType", LuaScriptInterface::luaItemTypeGetWeaponType);
registerMethod("ItemType", "getAmmoType", LuaScriptInterface::luaItemTypeGetAmmoType);
registerMethod("ItemType", "getTransformEquipId", LuaScriptInterface::luaItemTypeGetTransformEquipId);
registerMethod("ItemType", "getTransformDeEquipId", LuaScriptInterface::luaItemTypeGetTransformDeEquipId);
@@ -10339,6 +10340,19 @@ int LuaScriptInterface::luaItemTypeGetWeaponType(lua_State* L)
return 1;
}
int LuaScriptInterface::luaItemTypeGetAmmoType(lua_State* L)
{
// itemType:getAmmoType()
const ItemType* itemType = getUserdata<const ItemType>(L, 1);
if (itemType) {
lua_pushnumber(L, itemType->ammoType);
}
else {
lua_pushnil(L);
}
return 1;
}
int LuaScriptInterface::luaItemTypeGetTransformEquipId(lua_State* L)
{
// itemType:getTransformEquipId()

View File

@@ -1084,6 +1084,7 @@ class LuaScriptInterface
static int luaItemTypeGetDefense(lua_State* L);
static int luaItemTypeGetArmor(lua_State* L);
static int luaItemTypeGetWeaponType(lua_State* L);
static int luaItemTypeGetAmmoType(lua_State* L);
static int luaItemTypeGetTransformEquipId(lua_State* L);
static int luaItemTypeGetTransformDeEquipId(lua_State* L);

View File

@@ -95,7 +95,7 @@ void NetworkMessage::addPosition(const Position& pos)
addByte(pos.z);
}
void NetworkMessage::addItem(uint16_t id, uint8_t count)
void NetworkMessage::addItem(uint16_t id, uint8_t count, bool textWindow /* = false*/)
{
const ItemType& it = Item::items[id];
@@ -105,14 +105,17 @@ void NetworkMessage::addItem(uint16_t id, uint8_t count)
add<uint16_t>(it.id);
}
if (it.stackable || it.isRune()) {
addByte(count);
} else if (it.isSplash() || it.isFluidContainer()) {
addByte(getLiquidColor(count));
if (!textWindow) {
if (it.stackable || it.isRune()) {
addByte(count);
}
else if (it.isSplash() || it.isFluidContainer()) {
addByte(getLiquidColor(count));
}
}
}
void NetworkMessage::addItem(const Item* item)
void NetworkMessage::addItem(const Item* item, bool textWindow /* = false*/)
{
const ItemType& it = Item::items[item->getID()];
@@ -122,12 +125,16 @@ void NetworkMessage::addItem(const Item* item)
add<uint16_t>(it.id);
}
if (it.stackable) {
addByte(std::min<uint16_t>(0xFF, item->getItemCount()));
} else if (it.isRune()) {
addByte(std::min<uint16_t>(0xFF, item->getCharges()));
} else if (it.isSplash() || it.isFluidContainer()) {
addByte(getLiquidColor(item->getFluidType()));
if (!textWindow) {
if (it.stackable) {
addByte(std::min<uint16_t>(0xFF, item->getItemCount()));
}
else if (it.isRune()) {
addByte(std::min<uint16_t>(0xFF, item->getCharges()));
}
else if (it.isSplash() || it.isFluidContainer()) {
addByte(getLiquidColor(item->getFluidType()));
}
}
}

View File

@@ -110,8 +110,8 @@ class NetworkMessage
// write functions for complex types
void addPosition(const Position& pos);
void addItem(uint16_t id, uint8_t count);
void addItem(const Item* item);
void addItem(uint16_t id, uint8_t count, bool textWindow = false);
void addItem(const Item* item, bool textWindow = false);
void addItemId(uint16_t itemId);
MsgSize_t getLength() const {

View File

@@ -1755,7 +1755,7 @@ void ProtocolGame::sendTextWindow(uint32_t windowTextId, Item* item, uint16_t ma
NetworkMessage msg;
msg.addByte(0x96);
msg.add<uint32_t>(windowTextId);
msg.addItem(item);
msg.addItem(item, true);
if (canWrite) {
msg.add<uint16_t>(maxlen);
@@ -1791,7 +1791,7 @@ void ProtocolGame::sendTextWindow(uint32_t windowTextId, uint32_t itemId, const
NetworkMessage msg;
msg.addByte(0x96);
msg.add<uint32_t>(windowTextId);
msg.addItem(itemId, 1);
msg.addItem(itemId, 1, true);
msg.add<uint16_t>(text.size());
msg.addString(text);
msg.add<uint16_t>(0x00);