Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
0 registered members (), 18,767 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
is the an example for using random #288665
09/07/09 23:06
09/07/09 23:06
Joined: Aug 2007
Posts: 157
England
DeD Offline OP
Member
DeD  Offline OP
Member

Joined: Aug 2007
Posts: 157
England
hi is the any examples on making things be random.
so when a obeject is collected, the item thats givien to the player is random, like armor health, wepons, ammo.

ive been reading the aum files but cant find anything.


D.E.D

I use lite c
Re: is the an example for using random [Re: DeD] #288669
09/07/09 23:18
09/07/09 23:18
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
You can use random(x) on a variable, and then compare that variable with a set list...
Code:
var random_item = 0;

random_item = integer(random(5)); // 5 possibilities
switch(random_item)
{
case 0 : GivePlayerAmmo(); break;
case 1 : GivePlayerArmor(); break;
case 2 : GivePlayerHealth(); break;
case 3 : GivePlayerWeapon(); break;
case 4 : GivePlayerLife(); break;
}


So you would test the random value returned and for a certain value, perform a certain task.

Last edited by DJBMASTER; 09/07/09 23:18.
Re: is the an example for using random [Re: DJBMASTER] #288672
09/07/09 23:29
09/07/09 23:29
Joined: Aug 2007
Posts: 157
England
DeD Offline OP
Member
DeD  Offline OP
Member

Joined: Aug 2007
Posts: 157
England
how dose this work in a action?


D.E.D

I use lite c
Re: is the an example for using random [Re: DeD] #288679
09/08/09 02:31
09/08/09 02:31
Joined: Jul 2008
Posts: 553
Singapore
delinkx Offline
User
delinkx  Offline
User

Joined: Jul 2008
Posts: 553
Singapore
u can just use the code DJMASTER put above within an action. using the case statements, it will do random selection. maybe u may want to trigger this during an event/input. or u can time the randomization.


A7 commercial Team / VC++ 2008 Pro
homepage | twitter | facebook
Re: is the an example for using random [Re: delinkx] #288859
09/09/09 06:21
09/09/09 06:21
Joined: Jun 2008
Posts: 428
Rasch Offline
Senior Member
Rasch  Offline
Senior Member

Joined: Jun 2008
Posts: 428
There´s a important thing.

if you don´t want to to have the range between 0 and 4 but in 1 and 5 use this code and for action it´s in c_script:

Code:
function random_one()
{
        var random_value_one;

	random_value_one = int(random(5)+1);
	
	if(random_value_one == 1)
	{
		give_weapon();
	}
	if(random_value_one == 2)
	{
		give_armor();
	}
	if(random_value_one == 3)
	{
		give_powerup();
	}
	if(random_value_one == 4)
	{
		give_crap();
	}
	if(random_value_one == 5)
	{
		give_nothing();
	}
}



for lite_c i think you can use this.

Code:
function random_one()
{
	var random_item = 0;

	random_item = integer(random(5)+1); // 5 possibilities
	switch(random_item)
	{
		case 1 : GivePlayerAmmo(); break;
		case 2 : GivePlayerArmor(); break;
		case 3 : GivePlayerHealth(); break;
		case 4 : GivePlayerWeapon(); break;
		case 5 : GivePlayerLife(); break;
	}
}



Don´t forget to set "random_seed(0)" or "randomize()" in older versions before the level_load instruction.

This will bring you absolute random values otherwise they would always be the same.

greets laugh

Last edited by Rasch; 09/09/09 06:46.

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1