Norin Posted May 4, 2007 Share Posted May 4, 2007 Greetings everybody, first of all, I am sorry for posting multiple questions in one topic, but I thought it'd be better to make one topic rather than having many topics. I am actually working on a php-based game and I've encoutered some problems. First of all, I've got some problem while trying to make a function that would allow me to get a random item as a drop from a monster. The problem is, each item has a % chance to be dropped. I made a function that allowed me to do this: function randomPrc($itemSQL) { $drop = array(); foreach($itemSQL as $item) { for($i=0;$i<($item['prc']*10);$i++) { array_push($drop, $item['item']); } } $randDrop = rand(0,count($drop)); $currDrop = $drop[$randDrop]; echo $currDrop; } But as you can see, the 'No drop' is impossible with this function and it has to make an array of around 1000 values which is actually really big. So I was wondering if there was a way to do this in a way that'd be more effective. Table & Session: Another problem I have is more a "Which is the best way to go" problem. Let's say for exemple that a player go fight a monster. I have the base information concerning that monster in a table. Should I create a table which would contain temporary informations like, how much HP/MP that monster have left or should I try to get my way through SESSION array containing those informations? When the player dies, he can go to the hospital. So I was thinking to use tables with a date, then compare the date where he went to the hospital with now [saying he cant go to the hospital more than once by 10minutes] But it would require lot of information in my player table... Anyone know a more effective way to get this done? Finally, my last question, which way would be the best. If for exemple my player has parts (Head, right/left arms...) where he can use some items. Should all my items be in one big table, or should I separate all of them? Actually, most items have the same stats but the armors gives def and weapons gives attack. Sorry if it was long, Thanks in advance Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.