May 02 2025 07:40:01
Navigation
· Home
· Articles
· Downloads
· FAQ
· Discussion Forum
· Web Links
· News Categories
· Contact Me
· Photo Gallery
· Search
· Gameservers
Languages
Users Online
· Guests Online: 18

· Members Online: 0

· Total Members: 1,143
· Newest Member: k4m1n0
Teamspeak 3
Last Seen Users
· Intruder04:22:40
· Homi08:25:08
· The ACE08:55:42
· SGT PEPPER13:53:28
· GONZO13:56:53
· WEZ14:42:45
· Sully 1 day
· Silent Bob 2 days
· desintegrator 3 days
· scottisch 1 week
· xhc 1 week
· Brody 2 weeks
· KostiCZ 2 weeks
· The General 2 weeks
· VictorMyson 3 weeks

View Thread: Randomized vector
Vietcong.Info » Vietcong General Discussion » Maps & Mapping
Who is here? 1 Guest
Current Rating: (Total: 0 ratings)  
 Print Thread
Randomized vector
KostiCZ
Can anybody help me with maybe simple task? I have vector and I need to modify it by random number, each axis by +-5%. But I'm making something wrong - rnd number is still 0. So question is how to define random number generation?

rndpom = (SRV_Random(100) - 50)/50;
vec.x = vec.x * rndpom;

I tried also

vec.x = vec.x + vec.x * rndpom;

After that the vector is not changed. Can somebody help?
Signature________________________________________________

2LT William Theolinus "KostiCZ" Boner Jr.
LRRP Squad Baker, Delta Team
cache.www.gametracker.com/player/KostiCZ/63.143.47.189:2302/b_560x95.png
 
Teamrespawn.cz
Ando
Are you talking about vietcong scripts?
If yes then
random integer number:
int rand(void);
my_random_int = rand() % max_num;


random float number:
float frnd(float max);
my_random_float = frnd(max_num);


EDIT:
here is example code for random +/- 5 degrees
Download source  Code
#define    max_angle   5 // max angle in degrees



vec.x=-DEG_TO_RAD(max_angle)+frnd(DEG_TO_RAD(max_angle*2));


Edited by Ando on 10-03-2012 22:59
  x 1  x 1
 
Jump to Forum:
Login
Username

Password



Not a member yet?
Click here to register.

Forgotten your password?
Request a new one here.
Render time: 0.18 seconds - 50 Queries 5,856,927 unique visits