Jump to content

C++ get Hp from a mob/npc, is possible?


Go to solution Solved by newja,

Recommended Posts

//currently hp
int npc_get_hp(lua_State * L)
{
	CQuestManager& q = CQuestManager::instance();
	LPCHARACTER npc = q.GetCurrentNPCCharacterPtr();
		
	lua_pushnumber(L, npc->GetHP());
}		

//maximum hp
int npc_get_max_hp(lua_State * L)
{
	CQuestManager& q = CQuestManager::instance();
	LPCHARACTER npc = q.GetCurrentNPCCharacterPtr();
		
	lua_pushnumber(L, npc->GetMaxHP());
}		
  • Love 2
Link to comment
Share on other sites

//currently hp
int npc_get_hp(lua_State * L)
{
	DWORD vid = (DWORD) lua_tonumber(L, 1);

	LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid);

	lua_pushnumber(L, npc->GetHP());
}      
 
//maximum hp
int npc_get_max_hp(lua_State * L)
{
	DWORD vid = (DWORD) lua_tonumber(L, 1);
	LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid);
	
	lua_pushnumber(L, npc->GetMaxHP());
}       		

  • Love 2
Link to comment
Share on other sites

  • Solution
    int npc_get_hp_by_vid(lua_State* L)
    {
        lua_Number vid = lua_tonumber(L, 1);
        LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid);
        if(npc)
        {
            lua_pushnumber(L, npc->GetHP());
        }
        else
        {
            lua_pushnumber(L, 0);
        }
        return 1;
    }
 
    int npc_get_max_hp_by_vid(lua_State* L)
    {
        lua_Number vid = lua_tonumber(L, 1);
        LPCHARACTER npc = CHARACTER_MANAGER::instance().Find(vid);
        if(npc)
        {
            lua_pushnumber(L, npc->GetMaxHP());
        }
        else
        {
            lua_pushnumber(L, 0);
        }
        return 1;
    }

MbmhhGO.gif

 

+ Quest

 

R6X3I9H.png

 

Regards,

newja

Edited by Metin2 Dev
Core X - External 2 Internal
  • Metin2 Dev 1
  • Love 1
Link to comment
Share on other sites

sema / newja, did your quest are release or not ? Or how to put the pet level before his name please ?

What do you mean by saying

 

your quest are released

 

which one?  :huh:

##############################

To see pet level you must go to PetSystem.cpp

find

void CPetActor::SetName(const char* name)

and replace whole function with this

void CPetActor::SetName(const char* name)
{
    std::string petName = "";
 
    if (0 != m_pkOwner && 
        0 == name && 
        0 != m_pkOwner->GetName())
    {
        petName += "";
    }
    else
        petName += name;
 
    if (true == IsSummoned())
        m_pkChar->SetName(petName);
 
    m_name = petName;
}

If you want to know how to set pet name, look into this

quest pet begin
state start begin
    when seal_id.use begin
        level = 99 -- here, you can insert a variable or anything you want
        vnum = 53008 -- pet ID
        name = "Petty-chan" -- pet Name
        pet.summon(vnum, "[Lv."..level.."] - "..name, false)
    end
end
end

Regards,

newja

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.