Forums

 Programming Contest

 Documentation

 Partner Sites

 View unanswered posts | View active topics It is currently Tue May 22, 2018 4:26 pm

 Page 1 of 1 [ 3 posts ]
 Print view | E-mail friend Previous topic | Next topic
RPG City Search question
Author Message
Junior Member

Joined: Sat Sep 02, 2006 2:48 pm
Posts: 4
RPG City Search question
Has anyone here ever written code for an RPG that invloves some sort of search?

Specifically what I am trying to do is write code that will give a player 250 "search moves" per day and allow them the chance of finding money, an object, or nothing. I would like to randomize the money found to \$5, \$10, \$15, or \$20, and the objects to 1, 2, or 3.

I've been searching for tutorials or examples but keep coming up short. Any guidance is appreciated.

Sat Sep 02, 2006 2:59 pm
Junior Member

Joined: Sun Sep 03, 2006 2:24 am
Posts: 1

uhm, i guess i would do it this way:

[PHP]
function random_search(\$s_moves)
{
if(\$s_moves >= 1)
{
\$rand = round(rand(1,7));

if(\$rand == 1)
{
//Found nothing
}

else if(\$rand == 2)
{
//Found \$5
}

// go on like this, for every number a special event

//Now you gotta decrease the players search moves by one

}
}
[/PHP]

If you want to make some events occur with different chances:

Just change [PHP]\$rand = round(rand(1,7));[/PHP]

to [PHP]\$rand = round(rand(1,100));[/PHP]

and then
[PHP]
if(\$rand <= 50)
{
//50% chance to find nothing
}

else if(\$rand > 50 && =<60)
{
//105 chance to find \$5
}
[/PHP]

hope that helps.

- Sinzygy

Sun Sep 03, 2006 2:38 am
Junior Member

Joined: Sat Sep 02, 2006 2:48 pm
Posts: 4

That looks great, thank you very much!

Sun Sep 03, 2006 6:38 am
Display posts from previous:  Sort by
 Page 1 of 1 [ 3 posts ]

#### Who is online

Users browsing this forum: No registered users and 0 guests

 You cannot post new topics in this forumYou cannot reply to topics in this forumYou cannot edit your posts in this forumYou cannot delete your posts in this forumYou cannot post attachments in this forum

Search for:
 Jump to:  Select a forum ------------------ Editors and Tools    Reviewed Editors - User Comments    PHP Desktop Editors    Other PHP Tools Programming Contests    PHP Programming Contests Programming Help    PHP Programming Help Linux, Apache, MySQL    MySQL Help    Apache Help    Linux Help Web Hosting    Shared Web Hosting    Managed Web Hosting    Dedicated Servers Tutorials    Tutorials & Articles General    Latest News    Announcements    Talk back    PHP Games    Site Users Chat Marketplace    PHP Jobs    Resume    Sell: Scripts and Applications    Buy: Scripts and Applications
 © Copyright 2003-2008 www.php-editors.com. The ultimate PHP Editor and PHP IDE site.