Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
0 registered members (), 1,382 guests, and 6 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 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 | chip programmers | 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