Added: Player can now ask a pet (zig) to enter/leave from his bag (an icon is displayed when pet is on the bag)

--HG--
branch : patches-from-atys
hg/hotfix/patches-from-atys
ulukyn 6 years ago
parent cad47321a3
commit 9780decca0

@ -334,12 +334,12 @@ void CLog::displayNL (const char *format, ...)
}
char *str;
NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
NLMISC_CONVERT_VARGS (str, format, 1024/*NLMISC::MaxCStringSize*/);
if (strlen(str)<256/*NLMISC::MaxCStringSize*/-1)
if (strlen(str)<1024/*NLMISC::MaxCStringSize*/-1)
strcat (str, "\n");
else
str[256/*NLMISC::MaxCStringSize*/-2] = '\n';
str[1024/*NLMISC::MaxCStringSize*/-2] = '\n';
displayString (str);
}
@ -359,7 +359,7 @@ void CLog::display (const char *format, ...)
}
char *str;
NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
NLMISC_CONVERT_VARGS (str, format, 1024/*NLMISC::MaxCStringSize*/);
displayString (str);
}
@ -453,12 +453,12 @@ void CLog::displayRawNL( const char *format, ... )
}
char *str;
NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
NLMISC_CONVERT_VARGS (str, format, 1024/*NLMISC::MaxCStringSize*/);
if (strlen(str)<256/*NLMISC::MaxCStringSize*/-1)
if (strlen(str)<1024/*NLMISC::MaxCStringSize*/-1)
strcat (str, "\n");
else
str[256/*NLMISC::MaxCStringSize*/-2] = '\n';
str[1024/*NLMISC::MaxCStringSize*/-2] = '\n';
displayRawString(str);
}
@ -478,7 +478,7 @@ void CLog::displayRaw( const char *format, ... )
}
char *str;
NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
NLMISC_CONVERT_VARGS (str, format, 1024/*NLMISC::MaxCStringSize*/);
displayRawString(str);
}
@ -496,7 +496,7 @@ void CLog::forceDisplayRaw (const char *format, ...)
}
char *str;
NLMISC_CONVERT_VARGS (str, format, 256/*NLMISC::MaxCStringSize*/);
NLMISC_CONVERT_VARGS (str, format, 1024/*NLMISC::MaxCStringSize*/);
TDisplayInfo args;
CDisplayers::iterator idi;

@ -190,6 +190,7 @@ void CGameContextMenu::init(const std::string &srcMenuId)
_TextPAStop= "ui:interface:" + menuId + ":pa_stop";
_TextPAFree= "ui:interface:" + menuId + ":pa_free";
_TextPAEnterStable= "ui:interface:" + menuId + ":pa_enter_stable";
_TextPAEnterBag= "ui:interface:" + menuId + ":pa_enter_bag";
// Forage source
_TextExtractRM= "ui:interface:" + menuId + ":extract_rm";
@ -557,7 +558,7 @@ void CGameContextMenu::update()
// Enable/disable various menu items
bool ok = testMenuOptionForPackAnimal( selection, animalIndex, true, _TextPAFollow, _TextPAStop, _TextPAFree,
_TextPAEnterStable, NULL /*no 'leave stable' in context menu*/, pTextMount,
NULL /*unmount always active in context menu when the character is riding*/);
NULL /*unmount always active in context menu when the character is riding*/, _TextPAEnterBag, NULL);
// Follow & assist special case
if ( _TextFollow )
@ -581,12 +582,17 @@ void CGameContextMenu::update()
_TextPAFollow->setActive(false);
if (_TextPAStop)
_TextPAStop->setActive(false);
if (_TextPAFree)
_TextPAFree->setActive(false);
if (_TextPAEnterStable)
_TextPAEnterStable->setActive(false);
if (_TextPAEnterBag)
_TextPAEnterStable->setActive(false);
}
// Remove Free option to prevent miss click
if (_TextPAFree)
_TextPAFree->setActive(false);
// build spire
if(_TextBuildTotem)
{
@ -940,7 +946,8 @@ void CGameContextMenu::applyTextTalk()
bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index, bool clearAll,
CViewTextMenu *pFollow, CViewTextMenu *pStop, CViewTextMenu *pFree,
CViewTextMenu *pEnterStable, CViewTextMenu *pLeaveStable,
CViewTextMenu *pMount, CViewTextMenu *pUnmount )
CViewTextMenu *pMount, CViewTextMenu *pUnmount,
CViewTextMenu *pEnterBag, CViewTextMenu *pLeaveBag)
{
if ( clearAll )
{
@ -950,6 +957,8 @@ bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index,
if(pFree) { pFree->setActive(false); pFree->setGrayed(true); }
if(pEnterStable) { pEnterStable->setActive(false); pEnterStable->setGrayed(true); }
if(pLeaveStable) { pLeaveStable->setActive(false); pLeaveStable->setGrayed(true); }
if(pEnterBag) { pEnterBag->setActive(false); pEnterBag->setGrayed(true); }
if(pLeaveBag) { pLeaveBag->setActive(false); pLeaveBag->setGrayed(false); }
if(pMount) { pMount->setActive(false); pMount->setGrayed(true); }
if(pUnmount) { pUnmount->setActive(false); pUnmount->setGrayed(true); }
}
@ -986,6 +995,7 @@ bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index,
distanceSquare = pow(vect1.x-vect2.x,2) + pow(vect1.y-vect2.y,2);
}
bool onBag = ANIMAL_STATUS::isInBag(status);
// Enable option only if pack animal present
if(ANIMAL_STATUS::isSpawned(status))
@ -1017,7 +1027,15 @@ bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index,
if(pFollow) pFollow->setGrayed(false);
if(pStop) pStop->setGrayed(false);
if(pEnterStable) pEnterStable->setGrayed(false);
if (pEnterBag && !onBag)
pEnterBag->setGrayed(false);
}
if (pLeaveBag && onBag)
pLeaveBag->setActive(true);
if (pEnterBag && !onBag && anitype == ANIMAL_TYPE::Pet)
pEnterBag->setActive(true);
if(pLeaveStable) pLeaveStable->setGrayed(false);
}
}

@ -128,6 +128,7 @@ private:
CViewTextMenuPtr _TextPAStop;
CViewTextMenuPtr _TextPAFree;
CViewTextMenuPtr _TextPAEnterStable;
CViewTextMenuPtr _TextPAEnterBag;
// BotChat and player talk
CViewTextMenuPtr _TextNews;
@ -199,7 +200,8 @@ class CEntityCL;
bool testMenuOptionForPackAnimal( CEntityCL* selectedAnimalInVision, uint index, bool clearAll,
CViewTextMenu *pFollow, CViewTextMenu *pStop, CViewTextMenu *pFree,
CViewTextMenu *pEnterStable, CViewTextMenu *pLeaveStable,
CViewTextMenu *pMount, CViewTextMenu *pUnmount );
CViewTextMenu *pMount, CViewTextMenu *pUnmount,
CViewTextMenu *pEnterBag, CViewTextMenu *pLeaveBag );
#endif // NL_GAME_CONTEXT_MENU_H

@ -1555,6 +1555,8 @@ public:
CViewTextMenu *pFree = dynamic_cast<CViewTextMenu*>(pMenu->getView("free"));
CViewTextMenu *pEnterStable = dynamic_cast<CViewTextMenu*>(pMenu->getView("enter_stable"));
CViewTextMenu *pLeaveStable = dynamic_cast<CViewTextMenu*>(pMenu->getView("leave_stable"));
CViewTextMenu *pEnterBag = dynamic_cast<CViewTextMenu*>(pMenu->getView("enter_bag"));
CViewTextMenu *pLeaveBag = dynamic_cast<CViewTextMenu*>(pMenu->getView("leave_bag"));
CViewTextMenu *pMount = dynamic_cast<CViewTextMenu*>(pMenu->getView("mount"));
CViewTextMenu *pUnseat = dynamic_cast<CViewTextMenu*>(pMenu->getView("unseat"));
@ -1581,7 +1583,7 @@ public:
// Enable menu items
testMenuOptionForPackAnimal(selectedAnimalInVision, i, (i==0),
pFollow, pStop, pFree, pEnterStable, pLeaveStable, pMount, pUnseat);
pFollow, pStop, pFree, pEnterStable, pLeaveStable, pMount, pUnseat, pEnterBag, pLeaveBag);
}
}
else if(selected>=1 && selected<=MAX_INVENTORY_ANIMAL)
@ -1597,7 +1599,7 @@ public:
// Enable menu items
testMenuOptionForPackAnimal(selectedAnimalInVision, selected-1, true,
pFollow, pStop, pFree, pEnterStable, pLeaveStable, pMount, pUnseat);
pFollow, pStop, pFree, pEnterStable, pLeaveStable, pMount, pUnseat, pEnterBag, pLeaveBag);
}
}
};

@ -878,6 +878,23 @@ static DECLARE_INTERFACE_USER_FCT(isAnimalStatusInStable)
}
REGISTER_INTERFACE_USER_FCT("isAnimalStatusInStable", isAnimalStatusInStable)
// ***************************************************************************
static DECLARE_INTERFACE_USER_FCT(isAnimalStatusInBag)
{
if (args.size() != 1)
{
nlwarning("<isAnimalStatusInStable> Expecting 1 args.");
return false;
}
// According to server status, change the inventory text
uint status= (uint)args[0].getInteger();
result.setBool(ANIMAL_STATUS::isInBag(status));
return true;
}
REGISTER_INTERFACE_USER_FCT("isAnimalStatusInBag", isAnimalStatusInBag)
// ***************************************************************************
static DECLARE_INTERFACE_USER_FCT(isSkillAtMax)
{

@ -31,10 +31,11 @@ namespace ANIMAL_STATUS
/* There is no PresentFlag: the animal is not present if AliveFlag and InLandscapeFlag are not set (cause an animal cannot be dead in a stable!)
"Present" is tested if not all 0!
*/
AliveFlag= 0x0001, // if set, the animal is alive
InLandscapeFlag= 0x0002, // if set, the animal is in Landscape. not set: in Stable
InventoryAvailableFlag= 0x0004, // if set, the animal inventory is available
CanEnterLeaveStableFlag= 0x0008, // if set, an order "Leave" or "Enter Stable" can be issued
AliveFlag= 1, // if set, the animal is alive
InLandscapeFlag= 2, // if set, the animal is in Landscape. not set: in Stable
InventoryAvailableFlag= 4, // if set, the animal inventory is available
CanEnterLeaveStableFlag= 8, // if set, an order "Leave" or "Enter Stable" can be issued
InBagFlag= 16, // if set, an order "Enter Bag" or "Leave Bag" can be issued (only for pets)
};
// true if the animal is present and spawned
@ -67,6 +68,12 @@ namespace ANIMAL_STATUS
return isSpawned(e) && (e&InLandscapeFlag)!=0;
}
// true if the animal is present, spawned, and in bag (dead or not, and whatever the inventory state)
inline bool isInBag(EAnimalStatus e)
{
return isSpawned(e) && (e&InBagFlag)!=0;
}
// true if the animal is present, spawned, and in a stable
inline bool isInStable(EAnimalStatus e)
{

@ -26,7 +26,7 @@ namespace ANIMAL_TYPE
{
enum EAnimalType
{
All = 0,
All, Pet = 0,
Mount,
Packer,
Demon,

@ -35,6 +35,8 @@ const std::string BeastOrders[] =
"attack",
"mount",
"unmount",
"enter_bag",
"leave_bag"
};
//-----------------------------------------------

@ -38,6 +38,8 @@ namespace ANIMALS_ORDERS
ATTACK,
MOUNT, // For animal of type : Mount
UNMOUNT, // For animal of type : Mount
ENTER_BAG, // For animal of type : Creature (pet)
LEAVE_BAG, // For animal of type : Creature (pet)
// the number of size existing
BEAST_ORDERS_SIZE,

Loading…
Cancel
Save