introduce extra def and extra atk and inq several items

This commit is contained in:
ErikasKontenis
2022-04-16 11:56:43 +03:00
parent c7c4a194c1
commit 0ca1c4013c
18 changed files with 130 additions and 37 deletions

View File

@@ -1035,6 +1035,9 @@ bool Combat::rangeAttack(Creature* attacker, Creature* target, fightMode_t fight
specialEffect = weapon->getWeaponSpecialEffect();
attackStrength = weapon->getAttackStrength();
attackVariation = weapon->getAttackVariation();
hitChance += Item::items.getItemType(weapon->getID()).extraHitChance;
if (weapon->getFragility()) {
if (normal_random(0, 99) <= weapon->getFragility()) {
uint16_t count = weapon->getItemCount();
@@ -1054,6 +1057,9 @@ bool Combat::rangeAttack(Creature* attacker, Creature* target, fightMode_t fight
specialEffect = ammunition->getWeaponSpecialEffect();
attackStrength = ammunition->getAttackStrength();
attackVariation = ammunition->getAttackVariation();
hitChance += Item::items.getItemType(ammunition->getID()).extraHitChance;
if (normal_random(0, 100) <= ammunition->getFragility()) {
uint16_t count = ammunition->getItemCount();
if (count > 1) {
@@ -1233,27 +1239,27 @@ void Combat::getAttackValue(Creature* creature, uint32_t& attackValue, uint32_t&
switch (weapon->getWeaponType()) {
case WEAPON_AXE: {
skill = SKILL_AXE;
attackValue = weapon->getAttack();
attackValue = weapon->getAttack() + Item::items.getItemType(weapon->getID()).extraAttack;
break;
}
case WEAPON_SWORD: {
skill = SKILL_SWORD;
attackValue = weapon->getAttack();
attackValue = weapon->getAttack() + Item::items.getItemType(weapon->getID()).extraAttack;
break;
}
case WEAPON_CLUB: {
skill = SKILL_CLUB;
attackValue = weapon->getAttack();
attackValue = weapon->getAttack() + Item::items.getItemType(weapon->getID()).extraAttack;
break;
}
case WEAPON_DISTANCE: {
skill = SKILL_DISTANCE;
attackValue = weapon->getAttack();
attackValue = weapon->getAttack() + Item::items.getItemType(weapon->getID()).extraAttack;
if (weapon->getAmmoType() != AMMO_NONE) {
Item* ammunition = player->getAmmunition();
if (ammunition && ammunition->getAmmoType() == weapon->getAmmoType()) {
attackValue += ammunition->getAttack();
attackValue += ammunition->getAttack() + Item::items.getItemType(ammunition->getID()).extraAttack;
}
}
break;

View File

@@ -283,7 +283,7 @@ enum item_t : uint16_t {
ITEM_DEPOT = 3502,
ITEM_LOCKER1 = 3497,
ITEM_MARKET = 7477,
ITEM_MARKET = 12903,
ITEM_MALE_CORPSE = 4240,
ITEM_FEMALE_CORPSE = 4247,

View File

@@ -881,9 +881,26 @@ std::string Item::getDescription(const ItemType& it, int32_t lookDistance,
}
else if (it.weaponType != WEAPON_NONE) {
if (it.weaponType == WEAPON_DISTANCE && it.ammoType != AMMO_NONE) {
if (item->getAttack() != 0) {
s << ", Atk" << std::showpos << item->getAttack() << std::noshowpos;
s << " (";
if (item->getShootRange() != 0) {
s << "Range:" << static_cast<int>(item->getShootRange());
}
if (item->getAttack() != 0) {
if (item->getShootRange() != 0)
s << ", ";
s << "Atk" << std::showpos << item->getAttack() << std::noshowpos;
}
if (item->getExtraHitChance() != 0) {
if (item->getAttack() != 0 || item->getShootRange() != 0)
s << ", ";
s << "Hit%+" << static_cast<int>(item->getExtraHitChance());
}
s << ")";
}
else if (it.weaponType != WEAPON_WAND && (item->getAttack() != 0 || item->getDefense() != 0)) {
s << " (";

View File

@@ -605,6 +605,9 @@ class Item : virtual public Thing
}
return items[id].shootRange;
}
uint8_t getExtraHitChance() const {
return items[id].extraHitChance;
}
uint8_t getMissileType() const {
return items[id].shootType;
}

View File

@@ -421,6 +421,10 @@ bool Items::loadItems()
items[id].lightLevel = script.readNumber();
} else if (identifier == "lightcolor") {
items[id].lightColor = script.readNumber();
} else if (identifier == "extrahitchance") {
items[id].extraHitChance = script.readNumber();
} else if (identifier == "extraattack") {
items[id].extraAttack = script.readNumber();
} else if (identifier == "totalexpiretime") {
items[id].decayTime = script.readNumber();
} else if (identifier == "expiretarget") {

View File

@@ -252,6 +252,8 @@ class ItemType
uint8_t lightColor = 0;
uint8_t shootRange = 1;
uint8_t weaponSpecialEffect = 0;
uint8_t extraHitChance = 0;
uint8_t extraAttack = 0;
bool collisionEvent = false;
bool separationEvent = false;

View File

@@ -1052,6 +1052,15 @@ void LuaScriptInterface::registerFunctions()
registerEnum(ACCOUNT_TYPE_GAMEMASTER)
registerEnum(ACCOUNT_TYPE_GOD)
registerEnum(AMMO_NONE)
registerEnum(AMMO_BOLT)
registerEnum(AMMO_ARROW)
registerEnum(AMMO_SPEAR)
registerEnum(AMMO_THROWINGSTAR)
registerEnum(AMMO_THROWINGKNIFE)
registerEnum(AMMO_STONE)
registerEnum(AMMO_SNOWBALL)
registerEnum(CALLBACK_PARAM_LEVELMAGICVALUE)
registerEnum(CALLBACK_PARAM_SKILLVALUE)
registerEnum(CALLBACK_PARAM_TARGETTILE)
@@ -2291,6 +2300,7 @@ void LuaScriptInterface::registerFunctions()
registerMethod("ItemType", "getCapacity", LuaScriptInterface::luaItemTypeGetCapacity);
registerMethod("ItemType", "getWeight", LuaScriptInterface::luaItemTypeGetWeight);
registerMethod("ItemType", "getHitChance", LuaScriptInterface::luaItemTypeGetHitChance);
registerMethod("ItemType", "getShootRange", LuaScriptInterface::luaItemTypeGetShootRange);
registerMethod("ItemType", "getAttack", LuaScriptInterface::luaItemTypeGetAttack);
@@ -10540,6 +10550,19 @@ int LuaScriptInterface::luaItemTypeGetWeight(lua_State* L)
return 1;
}
int LuaScriptInterface::luaItemTypeGetHitChance(lua_State* L)
{
// itemType:getHitChance()
const ItemType* itemType = getUserdata<const ItemType>(L, 1);
if (itemType) {
lua_pushnumber(L, itemType->extraHitChance);
}
else {
lua_pushnil(L);
}
return 1;
}
int LuaScriptInterface::luaItemTypeGetShootRange(lua_State* L)
{
// itemType:getShootRange()

View File

@@ -1097,6 +1097,7 @@ class LuaScriptInterface
static int luaItemTypeGetCapacity(lua_State* L);
static int luaItemTypeGetWeight(lua_State* L);
static int luaItemTypeGetHitChance(lua_State* L);
static int luaItemTypeGetShootRange(lua_State* L);
static int luaItemTypeGetAttack(lua_State* L);
static int luaItemTypeGetDefense(lua_State* L);