[AKCore] Monster spawned, but disappear after ~5s

Results 1 to 8 of 8
  1. #1
    Member suppychan is offline
    MemberRank
    Apr 2010 Join Date
    74Posts

    [AKCore] Monster spawned, but disappear after ~5s

    I'm coded new method for GM Command: @Addmob, it's work but monster disappear after ~5s
    Code:
    void		MobActivity::CreateMonsterById(unsigned int uiMobId, CNtlPacket * pPacket, CClientSession * pSession)
    {
    	CGameServer * app = (CGameServer*) NtlSfxGetApp();
    	sVECTOR3 curpos = pSession->plr->GetPosition();
    	CreatureData * creaturelist;
    
    	for (MONSTERLISTIT it = m_monsterList.begin(); it != m_monsterList.end(); ++it )
    	{
    		creaturelist = (*it);
    		if(creaturelist->IsDead == false)
    		{
    			if(creaturelist->MonsterID != uiMobId)
    			{
    				continue;
    			}
    
    			CNtlPacket packet(sizeof(sGU_OBJECT_CREATE));
    			sGU_OBJECT_CREATE * res = (sGU_OBJECT_CREATE *)packet.GetPacketData();
    
    			res->wOpCode = GU_OBJECT_CREATE;
    			res->sObjectInfo.objType = OBJTYPE_MOB;
    			res->handle = creaturelist->MonsterSpawnID;
    			res->sObjectInfo.mobState.sCharStateBase.vCurLoc.x = curpos.x;
    			res->sObjectInfo.mobState.sCharStateBase.vCurLoc.y = curpos.y;
    			res->sObjectInfo.mobState.sCharStateBase.vCurLoc.z = curpos.z;
    			res->sObjectInfo.mobState.sCharStateBase.vCurDir.x = creaturelist->Spawn_Dir.x + rand() % 360;
    			res->sObjectInfo.mobState.sCharStateBase.vCurDir.y = creaturelist->Spawn_Dir.y;
    			res->sObjectInfo.mobState.sCharStateBase.vCurDir.z = creaturelist->Spawn_Dir.z;
    			res->sObjectInfo.mobState.sCharStateBase.byStateID = CHARSTATE_SPAWNING;
    			res->sObjectInfo.mobState.sCharStateBase.bFightMode = creaturelist->FightMode;
    			res->sObjectInfo.mobBrief.tblidx = creaturelist->MonsterID;
    			res->sObjectInfo.mobBrief.wCurEP = creaturelist->CurEP;
    			res->sObjectInfo.mobBrief.wMaxEP = creaturelist->MaxEP;
    			res->sObjectInfo.mobBrief.wCurLP = creaturelist->CurLP;
    			res->sObjectInfo.mobBrief.wMaxLP = creaturelist->MaxLP;
    			res->sObjectInfo.mobBrief.fLastRunningSpeed =  creaturelist->Run_Speed;
    			res->sObjectInfo.mobBrief.fLastWalkingSpeed = creaturelist->Walk_Speed;
    			creaturelist->isAggro = false;
    			creaturelist->isSpawned = true;
    			pSession->InsertIntoMyMonsterList(creaturelist->MonsterSpawnID, creaturelist->Spawn_Loc, creaturelist->MonsterID);
    
    			packet.SetPacketLen( sizeof(sGU_OBJECT_CREATE) );
    			g_pApp->Send( pSession->GetHandle(), &packet );
    		}
    
    		break;
    	}
    }


  2. #2
    Connoisseur of Fine Code SanGawku is offline
    ModeratorRank
    Oct 2006 Join Date
    CyberSpanksLocation
    643Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    It is because even though you insert it into your list. the spawn/despawn command searches through the spawn lists. you would have to modify it to ignore your mob, simply don't insert it into your list should get you around that temporarily.

    Please send me a PM with your skype name. its rare to find people in this section that can even half-ass code.

  3. #3
    Member suppychan is offline
    MemberRank
    Apr 2010 Join Date
    74Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    Gotcha!
    Just remove 1 line
    Code:
    pSession->InsertIntoMyMonsterList(creaturelist->MonsterSpawnID, creaturelist->Spawn_Loc, creaturelist->MonsterID);
    thanks
    P/S: Your inbox is full

  4. #4
    Connoisseur of Fine Code SanGawku is offline
    ModeratorRank
    Oct 2006 Join Date
    CyberSpanksLocation
    643Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    its empty now.

    - Anxiously awating your reply :)

  5. #5
    Apprentice JottaJr is offline
    MemberRank
    Jul 2014 Join Date
    17Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    Ok , i have a question .
    Based on this command we can create items too ????
    Change the creator for exemple " itemtable->ItemTableID " ... ?

  6. #6
    Member suppychan is offline
    MemberRank
    Apr 2010 Join Date
    74Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    Quote Originally Posted by JottaJr View Post
    Ok , i have a question .
    Based on this command we can create items too ????
    Change the creator for exemple " itemtable->ItemTableID " ... ?
    I was coded this method for "@createitem [item ID]", but you must sure your item ID you was enter is valid or your client can be crash
    Code:
    void CClientSession::CreateItemById(unsigned int uiTblidx)
    {
    	CGameServer * app = (CGameServer*) NtlSfxGetApp();
    	CNtlPacket packet4(sizeof(sGU_ITEM_PICK_RES));
    	sGU_ITEM_PICK_RES * res4 = (sGU_ITEM_PICK_RES*)packet4.GetPacketData();
    	res4->itemTblidx = uiTblidx;
    	res4->wOpCode = GU_ITEM_PICK_RES;
    	res4->wResultCode = GAME_SUCCESS;
    	int ItemPos = 0;
    
    	app->db->prepare("SELECT * FROM items WHERE owner_ID = ? AND place=1 ORDER BY pos ASC");
    	app->db->setInt(1, this->plr->pcProfile->charId);
    	app->db->execute();
    	int k = 0;
    
    	while (app->db->fetch())
    	{
    		if (app->db->getInt("pos") < NTL_MAX_ITEM_SLOT)
    			ItemPos = app->db->getInt("pos") + 1;
    		else
    			ItemPos = app->db->getInt("pos");
    		k++;
    	}
    	app->db->prepare("CALL BuyItemFromShop (?,?,?,?,?,   @Unique_iID)");
    	app->db->setInt(1, uiTblidx);
    	app->db->setInt(2, this->plr->pcProfile->charId);
    	app->db->setInt(3, ItemPos);
    	app->db->setInt(4, 1);
    	app->db->setInt(5, 100);
    	app->db->execute();
    	app->db->execute("SELECT   @Unique_iID");
    	app->db->fetch();
    
    	CNtlPacket packet2(sizeof(sGU_ITEM_CREATE));
    	sGU_ITEM_CREATE * res2 = (sGU_ITEM_CREATE *)packet2.GetPacketData();
    
    	res2->bIsNew = true;
    	res2->wOpCode = GU_ITEM_CREATE;
    	res2->handle = app->db->getInt(   @Unique_iID");
    	res2->sItemData.charId = this->GetavatarHandle();
    	res2->sItemData.itemNo = uiTblidx;
    	res2->sItemData.byStackcount = 1;
    	res2->sItemData.itemId = app->db->getInt(   @Unique_iID");
    	res2->sItemData.byPlace = 1;
    	res2->sItemData.byPosition = ItemPos;
    	res2->sItemData.byCurrentDurability = 100;
    	res2->sItemData.byRank = 1;
    
    	packet2.SetPacketLen(sizeof(sGU_ITEM_CREATE));
    	packet4.SetPacketLen(sizeof(sGU_ITEM_PICK_RES));
    	g_pApp->Send(this->GetHandle(), &packet2);
    	g_pApp->Send(this->GetHandle(), &packet4);
    }

  7. #7
    Connoisseur of Fine Code SanGawku is offline
    ModeratorRank
    Oct 2006 Join Date
    CyberSpanksLocation
    643Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    @suppychan get on skype I want to talk to you.

  8. #8
    Apprentice JottaJr is offline
    MemberRank
    Jul 2014 Join Date
    17Posts

    Re: [AKCore] Monster spawned, but disappear after ~5s

    Quote Originally Posted by suppychan View Post
    I was coded this method for "@createitem [item ID]", but you must sure your item ID you was enter is valid or your client can be crash
    Code:
    void CClientSession::CreateItemById(unsigned int uiTblidx)
    {
        CGameServer * app = (CGameServer*) NtlSfxGetApp();
        CNtlPacket packet4(sizeof(sGU_ITEM_PICK_RES));
        sGU_ITEM_PICK_RES * res4 = (sGU_ITEM_PICK_RES*)packet4.GetPacketData();
        res4->itemTblidx = uiTblidx;
        res4->wOpCode = GU_ITEM_PICK_RES;
        res4->wResultCode = GAME_SUCCESS;
        int ItemPos = 0;
    
        app->db->prepare("SELECT * FROM items WHERE owner_ID = ? AND place=1 ORDER BY pos ASC");
        app->db->setInt(1, this->plr->pcProfile->charId);
        app->db->execute();
        int k = 0;
    
        while (app->db->fetch())
        {
            if (app->db->getInt("pos") < NTL_MAX_ITEM_SLOT)
                ItemPos = app->db->getInt("pos") + 1;
            else
                ItemPos = app->db->getInt("pos");
            k++;
        }
        app->db->prepare("CALL BuyItemFromShop (?,?,?,?,?,   @Unique_iID)");
        app->db->setInt(1, uiTblidx);
        app->db->setInt(2, this->plr->pcProfile->charId);
        app->db->setInt(3, ItemPos);
        app->db->setInt(4, 1);
        app->db->setInt(5, 100);
        app->db->execute();
        app->db->execute("SELECT   @Unique_iID");
        app->db->fetch();
    
        CNtlPacket packet2(sizeof(sGU_ITEM_CREATE));
        sGU_ITEM_CREATE * res2 = (sGU_ITEM_CREATE *)packet2.GetPacketData();
    
        res2->bIsNew = true;
        res2->wOpCode = GU_ITEM_CREATE;
        res2->handle = app->db->getInt(   @Unique_iID");
        res2->sItemData.charId = this->GetavatarHandle();
        res2->sItemData.itemNo = uiTblidx;
        res2->sItemData.byStackcount = 1;
        res2->sItemData.itemId = app->db->getInt(   @Unique_iID");
        res2->sItemData.byPlace = 1;
        res2->sItemData.byPosition = ItemPos;
        res2->sItemData.byCurrentDurability = 100;
        res2->sItemData.byRank = 1;
    
        packet2.SetPacketLen(sizeof(sGU_ITEM_CREATE));
        packet4.SetPacketLen(sizeof(sGU_ITEM_PICK_RES));
        g_pApp->Send(this->GetHandle(), &packet2);
        g_pApp->Send(this->GetHandle(), &packet4);
    }
    Ok ty , i will go test this :D



Advertisement