Jump to content
  • 0

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


ѕeмa™

Question

13 answers to this question

Recommended Posts

  • 0
    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

  • Love 1
Link to comment
  • 0
//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
  • 0
//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
  • 0

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • 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.