Getting Random Mover

Results 1 to 2 of 2
  1. #1
    Owner raventh1984 is offline
    MemberRank
    May 2011 Join Date
    NetherlandsLocation
    1,499Posts

    Getting Random Mover

    Hi ragezoners,

    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 and 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


  2. #2
    Member Eastrall is offline
    MemberRank
    Nov 2016 Join Date
    4Posts

    Re: Getting Random Mover

    Quote Originally Posted by raventh1984 View Post
    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?
    Hi,

    I guess it's the way to go. Create an array and insert your mover ids, then do you random stuff :)



Advertisement