In this guide functions are created to add a monster to a table and to decrease the health of a monster from the table.
You can easily use the two functons like this from a lua script:
monster = objectMgr:CreateObject("HotMamma",5);
monster:Hurt( 1 ) --decrease health by 1
--or
objectMgr:CreateObject("HotMamma",5);
monster = objectMgr:GetObject(0)
monster:Hurt( 1 )
But how can I call these functions from the C++ side?
I mean the original ones: ObjectMgr::CreateObejct()
, ObjectMgr::GetObjectByIndex()
and Monster::Hurt()
I spend more than 8 hours on trying to figure this out! But nothing did work. :/
My best try was probably this:
// CreateObject modified to return pMonster and accept normal arguments
MonsterPtr monster = objectMgr.CreateObject(pState, "HotMamma", 5);
monster.Hurt( 1 );
This gives me the following error:
class "std::tr1::shared_ptr" has no member "Hurt"