Jump to content

bahmet

Inactive Member
  • Posts

    1
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by bahmet

  1. Hello everyone, I have a problem with aggreagte monster function and some other things that I couldn't understand why is also happening.
     

     

    As you can see at 0:03 mobs are able to attack me even If they're not around I think something breaks my character's position data. 

    My AggregateMonster Func:

    struct FuncAggregateMonster
    {
    	LPCHARACTER m_ch;
    	FuncAggregateMonster(LPCHARACTER ch)
    	{
    		m_ch = ch;
    	}
    	void operator()(LPENTITY ent)
    	{
    		if (ent->IsType(ENTITY_CHARACTER))
    		{
    			LPCHARACTER ch = (LPCHARACTER) ent;
    			if (ch->IsPC())
    				return;
    			if (!ch->IsMonster())
    				return;
    			if (ch->GetVictim())
    				return;
    
    			if (number(1, 100) <= 100) // 임시로 50% 확률로 적을 끌어온다
    				if (DISTANCE_APPROX(ch->GetX() - m_ch->GetX(), ch->GetY() - m_ch->GetY()) < 5000)
    					if (ch->CanBeginFight())
    						ch->BeginFight(m_ch);
    		}
    	}
    };
    void CHARACTER::AggregateMonster()
    {
    	LPSECTREE pSec = GetSectree();
    	if (pSec)
    	{
    		FuncAggregateMonster f(this);
    		pSec->ForEachAround(f);
    	}
    }
    struct FuncPullMonster
    {
    	LPCHARACTER m_ch;
    	int m_iLength;
    	FuncPullMonster(LPCHARACTER ch, int iLength = 300)
    	{
    		m_ch = ch;
    		m_iLength = iLength;
    	}
    
    	void operator()(LPENTITY ent)
    	{
    		if (ent->IsType(ENTITY_CHARACTER))
    		{
    			LPCHARACTER ch = (LPCHARACTER) ent;
    			if (ch->IsPC())
    				return;
    			if (!ch->IsMonster())
    				return;
    			//if (ch->GetVictim() && ch->GetVictim() != m_ch)
    			//return;
    			float fDist = DISTANCE_APPROX(m_ch->GetX() - ch->GetX(), m_ch->GetY() - ch->GetY());
    			if (fDist > 3000 || fDist < 100)
    				return;
    
    			float fNewDist = fDist - m_iLength;
    			if (fNewDist < 100) 
    				fNewDist = 100;
    
    			float degree = GetDegreeFromPositionXY(ch->GetX(), ch->GetY(), m_ch->GetX(), m_ch->GetY());
    			float fx;
    			float fy;
    
    			GetDeltaByDegree(degree, fDist - fNewDist, &fx, &fy);
    			long tx = (long)(ch->GetX() + fx);
    			long ty = (long)(ch->GetY() + fy);
    
    			ch->Sync(tx, ty);
    			ch->Goto(tx, ty);
    			ch->CalculateMoveDuration();
    
    			ch->SyncPacket();
    		}
    	}
    };

     

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