Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Flyff > Flyff Private Server
You last visited: Today at 19:02

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Getting Random Mover

Discussion on Getting Random Mover within the Flyff Private Server forum part of the Flyff category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Getting Random Mover

Hi Elitepvpers,

I am working on an system but i am stuck atm.

What i am trying to do is to get Random Mover Id's

So it needs to randomly select an ID from MoverProp

currently i have this
Code:
for (int i = 0; i < prj.m_nMoverPropSize; i++)
	{
		MoverProp* pMoverProp = prj.m_pPropMover + i;
		switch(pMoverProp->dwClass)
		{
			case RANK_LOW:
				OUTPUTDEBUGSTRING("\n LowRank Mobs: %d", pMoverProp->dwID);
				break;
		}
	}
first its looping true all the movers then it only outputs the movers who has the class RANK_LOW
so as an example i have this

20
25
112
200
210

so far its good.
What i now need is this

I want to have 5 movers created with an Random id.
so i thought well i do this
Code:
for(int i = 0; i <= 5; i++)
{
        int nRandMover = rand() % pMoverProp->dwID;
}
however it wont work since the output is this
Rand between 0 and 20 will output example 2

But there is no MoverID with number 2. So it will give me an error.

Do i need to put them into an array and then loop true it? or is it something else i am not seeing at this moment?

With kind regards
raventh1984 is offline  
Old 12/24/2016, 20:07   #2
 
elite*gold: 0
Join Date: Mar 2008
Posts: 665
Received Thanks: 230
Code:
vector<MoverProp*> m_monsters;

for (int i = 0; i < prj.m_nMoverPropSize; i++)
{
	MoverProp* pMoverProp = prj.m_pPropMover + i;
	switch(pMoverProp->dwClass)
	{
		case RANK_LOW:
			OUTPUTDEBUGSTRING("\n LowRank Mobs: %d", pMoverProp->dwID);
			m_monsters.push_back(pMoverProp);
			break;
	}
}

for(int i = 0; i <= 5; i++)
{
        int nRandMover = rand() % m_monsters.size();
	m_monsters[nRandMover]->dwID; //Example on how to access the structure.
}
First you need to store the values you want in any container.
On first part add only the needed values to the vector and second part is self explained.
Note that rand() % number returns a random number between 0 and number.
rand() % 20 -> 0, 1, 2, 3, ... 20

If you have more cases in your switch, change for a std::map or std::vector:air
alfredico is offline  
Thanks
3 Users
Old 12/24/2016, 20:09   #3
 
elite*gold: 0
Join Date: Oct 2012
Posts: 948
Received Thanks: 157
Thank you alfredico i will check it out to see if that is what i need. Nicly explained.

Verstuurd vanaf mijn SM-A500FU met Tapatalk
raventh1984 is offline  
Old 12/25/2016, 01:13   #4
 
elite*gold: 0
Join Date: Mar 2008
Posts: 333
Received Thanks: 284
Quote:
Originally Posted by alfredico
Note that rand() % number returns a random number between 0 and number.
rand() % 20 -> 0, 1, 2, 3, ... 20
20 is not an element of coset 20
Nortix is offline  
Reply


Similar Threads Similar Threads
[Released] Monster legends (Random Gold) (Random Food) (Random Exp)
02/03/2015 - Facebook - 6 Replies
Monster legends New Tools !! *1 - Random Gold *2 - Random Food *3 - Random Exp All Tested And Working 100% Without Any Problem :handsdown: !!! Link
[Release] Monster legends (Random Gold) (Random Food) (Random Exp)
02/03/2015 - Dragon City - 5 Replies
Monster legends New Tools !! *1 - Random Gold *2 - Random Food *3 - Random Exp All Tested And Working 100% Without Any Problem :handsdown: !!! Link
DC Random 8 -> 100 Gems + Random 3M --> 18 M Food + Random 3M --> 18M Gold
01/24/2015 - Dragon City - 25 Replies
DC Random 8 -> 100 Gems + Random 3M --> 18 M Food + Random 3M --> 18M Gold Dragon City Gem + Gold + Food +Exp



All times are GMT +1. The time now is 19:03.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.