1. ## Number Gen

Code:
```int RandomNum(int lowest, int highest)
{
int random_integer;
int range=(highest-lowest)+1;
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
return random_integer;
}```
Idk what this can be used for but i guess you can use it for "Speed Surprise".
You never know how fast you will go in ca

How to use
Code:
`Lucky = RandomNum(1,100000);`

Credits:
Me for function

2. ## The Following 3 Users Say Thank You to flameswor10 For This Useful Post:

3. Code:
```int GetRandomNumber(int MAXNUM)
{
srand((DWORD)time(0));
return rand() % MAXNUM;
}```

4. Originally Posted by kotentopf
Code:
```srand((DWORD)time(0);

int Number = rand % <highestnumber>;```

Don't be soo mean LOL

5. Originally Posted by flameswor10

Don't be soo mean LOL
its much easier and need not so much code

6. Originally Posted by kotentopf
its much easier and need not so much code
To them it's just C+P so theres not much difference

7. ## The Following User Says Thank You to flameswor10 For This Useful Post:

kotentopf (02-02-2011)

8. i know....

9. damn, ty i was searching for something about how to get a random number... i know the rand() function (not so good), but i have some problems... ty for this!

10. Originally Posted by flameswor10
Code:
```int RandomNum(int lowest, int highest)
{
int random_integer;
int range=(highest-lowest)+1;
random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
return random_integer;
}```
How to use
Code:
`Lucky = RandomNum(1,100000);`
Credits:
Me for function
I found similar post by Raygoe in 2007, honestly you didnt create the function.

[Highlight=C++]#include "input.h"
#include "OgreStringConverter.h"
#include "simulation.h"

#include "Ogre.h"
#include <string>
#include <sstream>

#include <iostream>
#include <ctime>
#include <cstdlib>

#include "OgreWindowEventUtilities.h"

int randomNum (int lowest, int highest) {
int random_integer;
int range = (highest-lowest)+1;

random_integer = lowest+int(range*rand()/(RAND_MAX + 1.0));
return random_integer;
}

InputHandler::InputHandler(Simulation *sim, unsigned long hWnd, Ogre::Root* ogre, Ogre::RenderWindow* window, Ogre::SceneManager* sceneMgr, Ogre::Camera* camera, Ogre::SceneNode* buildnode, Ogre::SceneNode* cameraNode) {

root_ogre = ogre;
rWindow = window;
sMan = sceneMgr;
cam = camera;
bNode = buildnode;

robotI = 0;

OIS::ParamList pl;
pl.insert(OIS::ParamList::value_type("WINDOW", Ogre::StringConverter::toString(hWnd)));
//SHOW MOUSE
pl.insert(std::make_pair(std::string("w32_mouse"), std::string("DISCL_FOREGROUND")));
pl.insert( std::make_pair( std::string( "w32_mouse" ), std::string("DISCL_NONEXCLUSIVE") ) );

m_hWnd = hWnd;
m_ois = OIS::InputManager::createInputSystem( pl );
mMouse = static_cast<OIS::Mouse*>(m_ois->createInputObject( OIS::OISMouse, true ));
mKeyboard = static_cast<OIS::Keyboard*>(m_ois->createInputObject( OIS::OISKeyboard, true));
mMouse->setEventCallback(this);
mKeyboard->setEventCallback(this);

mRotate = 0.13;
mMove = 0;

mContinue = true;
m_simulation = sim;

mDirection = cam->getPosition();

camNode = cameraNode;

srand((unsigned)time(0));
targetNode = sMan->getSceneNode("playerRob");
}

InputHandler::~InputHandler() {
if (mMouse)
delete mMouse;
if (mKeyboard)
delete mKeyboard;
OIS::InputManager::destroyInputSystem(m_ois);
}

void InputHandler::capture() {
mMouse->capture();
mKeyboard->capture();
}

bool InputHandler::movePlayerCam(float ft) {
frameTime = (ft);

if (mKeyboard->isKeyDown(OIS::KC_UP) || mKeyboard->isKeyDown(OIS::KC_W) || mKeyboard->isKeyDown(OIS::KC_DOWN) || mKeyboard->isKeyDown(OIS::KC_S)) {
mDirection = (0,0,mMove);
didMove = true;
}

if (mKeyboard->isKeyDown(OIS::KC_LEFT) || mKeyboard->isKeyDown(OIS::KC_A)) {
targetNode->yaw(Ogre:egree(2*frameTime),Ogre::Node::TS_WORLD);
camNode->yaw(Ogre:egree(2*frameTime),Ogre::Node::TS_WORLD);
didMove = true;
}
else if (mKeyboard->isKeyDown(OIS::KC_RIGHT) || mKeyboard->isKeyDown(OIS::KC_D)) {
targetNode->yaw(Ogre:egree(-2*frameTime),Ogre::Node::TS_WORLD);
camNode->yaw(Ogre:egree(-2*frameTime),Ogre::Node::TS_WORLD);
didMove = true;
}

if (didMove != true) {
return false;
} else {
didMove = false;
}

mMoveTo = (targetNode->getOrientation() * ((mDirection * frameTime) - targetNode->getPosition()));
//mDirection.x = 0;
//mDirection.y = 0;
//mDirection.z = 0;
targetNode->translate(mMoveTo);
cam->lookAt(targetNode->getPosition());
//cam->setPosition();

std::cout << mMoveTo << "\n" << targetNode->getPosition() << "\n";
return true;
}

void InputHandler::setWindowExtents(int width, int height){
//Set Mouse Region.. if window resizes, we should alter this to reflect as well
const OIS::MouseState &ms = mMouse->getMouseState();
ms.width = width;
ms.height = height;
}

/*bool InputHandler::frameStarted(const Ogre::FrameEvent &evt) {
camNode->translate(mDirection * evt.timeSinceLastFrame, Ogre::Node::TS_LOCAL);
return true;
}*/

// MouseListener
bool InputHandler::mouseMoved(const OIS::MouseEvent &evt) {
if (evt.state.buttonDown(OIS::MB_Right)) {
camNode->pitch(Ogre:egree(-mRotate * evt.state.Y.rel), Ogre::Node::TS_LOCAL);
camNode->yaw(Ogre:egree(-mRotate * evt.state.X.rel), Ogre::Node::TS_WORLD);
cam->lookAt(targetNode->getPosition());
}
return true;
}

bool InputHandler::mousePressed(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
return true;
}

bool InputHandler::mouseReleased(const OIS::MouseEvent &evt, OIS::MouseButtonID btn) {
return true;
}

// KeyListener
bool InputHandler::keyPressed(const OIS::KeyEvent &evt) {
if (evt.key == OIS::KC_UP || evt.key == OIS::KC_W) {
mMove = 100;
}
if (evt.key == OIS::KC_DOWN || evt.key == OIS::KC_S) {
mMove = -50;
}
return true;
}

bool InputHandler::keyReleased(const OIS::KeyEvent &evt) {
if (evt.key == OIS::KC_ESCAPE)
m_simulation->requestStateChange(SHUTDOWN);
if (evt.key == OIS::KC_F5) {
robotI++;
std::stringstream stream;
stream << "robot" << robotI;
std::string robotID = stream.str();

Ogre::Entity* ent1 = sMan->createEntity( robotID, "robot.mesh" );
Ogre::SceneNode* secondary = bNode->createChildSceneNode( robotID, Ogre::Vector3( randomNum(0,20), randomNum(0,20), (randomNum(0,20) - 500) ) );
std:: cout << robotID << "\n";
secondary->attachObject( ent1 );
}
if (evt.key == OIS::KC_F6) {
camNode->setOrientation(Ogre::Quaternion(-1,0,-.5,0));
}
if (evt.key == OIS::KC_UP || evt.key == OIS::KC_W) {
mMove = 0;
}
if (evt.key == OIS::KC_DOWN || evt.key == OIS::KC_S) {
mMove = 0;
}
return true;
}

// JoyStickListener
bool InputHandler::buttonPressed(const OIS::JoyStickEvent &evt, int index) {
return true;
}

bool InputHandler::buttonReleased(const OIS::JoyStickEvent &evt, int index) {
return true;
}

bool InputHandler::axisMoved(const OIS::JoyStickEvent &evt, int index) {
return true;
}

bool InputHandler:ovMoved(const OIS::JoyStickEvent &evt, int index) {
return true;
}[/Highlight]

11. Using Class.

Code:
```   int IRandom(int min, int max){       // output random integer
// get integer random number in desired interval
int iinterval = max - min + 1;
if (iinterval <= 0) return 0x80000000; // error
int r = int(iinterval * Random()); // truncate
if (r >= iinterval) r = iinterval-1;
return min + r;
}
};```

12. Originally Posted by xChocolatex
I found similar post by Raygoe in 2007, honestly you didnt create the function.
You didnt Make your pro hacks
So STFU

13. ## The Following 3 Users Say Thank You to whit+ For This Useful Post:

DannyIzHere (02-02-2011),flameswor10 (02-02-2011),GodHack2 (02-02-2011)

14. Originally Posted by whit+
You didnt Make your pro hacks
So STFU
Take it easy, he actually gives credit to Gellin now...

15. Originally Posted by whit+
You didnt Make your pro hacks
So STFU
Same thing Goes to you
So STFU

16. Originally Posted by xChocolatex
Same thing Goes to you
So STFU
Sorry i dont think i released any hacks lately...
Sorry if i use my Knowledge for coding thing other than hacks

17. ## The Following User Says Thank You to whit+ For This Useful Post:

Jason (02-02-2011)

18. Originally Posted by whit+
Sorry i dont think i released any hacks lately...
Sorry if i use my Knowledge for coding thing other than hacks
Feel so pro? Your last release used gellin's base so what's different between you and me, huh? If you jealous just release better hack than mine.

19. Originally Posted by xChocolatex
Feel so pro? Your last release used gellin's base so what's different between you and me, huh? If you jealous just release better hack than mine.
Yea like a year ago..Who cares tho i changed the menu around and added groups to it..Thats was when i just start coding dumbass

Atleast i dont use it now.. Unlike you i dont compile and release hacks off a VIP base..
Do us all a favor and get the hell out..

20. ## The Following User Says Thank You to whit+ For This Useful Post:

Jason (02-02-2011)

Page 1 of 3 123 Last