ond
Veteran OT User
Hello! I have a problem...
I want, when shooting runes or using vials, the text that appears, to say
When runes: Using one of 100 spell runes
And when Vials (Mana fluids) Using one of 100 vials
Now I'm not able to fix this myself so I'm turning to you otfans community. Please help me!
In actions.cpp, the function:
And full function (if needed):
Thanks!
I want, when shooting runes or using vials, the text that appears, to say
When runes: Using one of 100 spell runes
And when Vials (Mana fluids) Using one of 100 vials
Now I'm not able to fix this myself so I'm turning to you otfans community. Please help me!
In actions.cpp, the function:
PHP:
void Actions::showUseHotkeyMessage(Player* player, Item* item, uint32_t itemCount, uint8_t subType /*=-1*/)
{
std::stringstream ss;
std::string itemName;
const ItemType& it = Item::items[item->getID()];
if(it.isRune()){
itemName = it.runeName;
}
else if(it.isFluidContainer()){
if(subType != 0){
if(itemCount == 1){
itemName = it.name + " of " + Item::items[subType].name;
}
else{
itemName = it.name + "s of " + Item::items[subType].name;
}
}
else{
itemName = "empty vial";
}
}
else{
itemName = it.name;
}
toLowerCaseString(itemName);
if(itemCount != 1){
if(it.isFluidContainer()){
ss << "Using one of " << itemCount << " " << itemName << "...";
}
else{
ss << "Using one of " << itemCount << " " << itemName << "s...";
}
}
else{
ss << "Using the last " << itemName << "...";
}
player->sendTextMessage(MSG_INFO_DESCR, ss.str());
}
And full function (if needed):
PHP:
bool Actions::useItemEx(Player* player, const Position& fromPos, const Position& toPos,
const unsigned char toStackPos, Item* item, bool isHotkey)
{
if(OTSYS_TIME() - player->getLastAction() < g_config.getNumber(ConfigManager::MIN_ACTIONTIME)){
return false;
}
Action* action = getAction(item);
if(!action){
player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
return false;
}
ReturnValue ret = action->canExecuteAction(player, toPos);
if(ret != RET_NOERROR){
player->sendCancelMessage(ret);
return false;
}
int32_t fromStackPos = item->getParent()->__getIndexOfThing(item);
PositionEx fromPosEx(fromPos, fromStackPos);
PositionEx toPosEx(toPos, toStackPos);
if(isHotkey){
int32_t subType = -1;
if(item->hasSubType() && !item->isRune()){
subType = item->getSubType();
}
uint32_t itemCount = player->__getItemTypeCount(item->getID(), subType, false);
if(!action->executeUse(player, item, fromPosEx, toPosEx, true)){
player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
return false;
}
showUseHotkeyMessage(player, item, itemCount, subType);
}
else{
if(!action->executeUse(player, item, fromPosEx, toPosEx, true)){
player->sendCancelMessage(RET_CANNOTUSETHISOBJECT);
return false;
}
}
player->setLastAction(OTSYS_TIME());
return true;
}
void Actions::showUseHotkeyMessage(Player* player, Item* item, uint32_t itemCount, uint8_t subType /*=-1*/)
{
std::stringstream ss;
std::string itemName;
const ItemType& it = Item::items[item->getID()];
if(it.isRune()){
itemName = it.runeName;
}
else if(it.isFluidContainer()){
if(subType != 0){
if(itemCount == 1){
itemName = it.name + " of " + Item::items[subType].name;
}
else{
itemName = it.name + "s of " + Item::items[subType].name;
}
}
else{
itemName = "empty vial";
}
}
else{
itemName = it.name;
}
toLowerCaseString(itemName);
if(itemCount != 1){
if(it.isFluidContainer()){
ss << "Using one of " << itemCount << " " << itemName << "...";
}
else{
ss << "Using one of " << itemCount << " " << itemName << "s...";
}
}
else{
ss << "Using the last " << itemName << "...";
}
player->sendTextMessage(MSG_INFO_DESCR, ss.str());
}
Thanks!