Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
Chance?
Old
Watsamax1
Senior Member
 
Watsamax1's Avatar
 
Status: Offline
Posts: 155
Join Date: Aug 2009
Default Chance? - 06-10-2010, 08:08 PM

Is it possible to like have a chance at something like you kill something and it drops loot. Not just have a set number a possibility.
Not if killed 5 times drop this. have it a possibility like 10% possibility nothing or 40% a weapon, 20% coins.


___________________________________________________

Watsamax Industries
Games Produced for Watsamax Industries Inc. 2010
Watsamax Industries: New York
Watsamax@gmail.com
http://www.facebook.com/profile.php?id=100001253371874#!/profile.php?id=100001253371874&v=wall
http://www.youtube.com/user/Watsamax
___________________________________________________
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 06-11-2010, 06:04 PM

Well you could always do the random number. Create a number variable in the method called "randomNum", and then set "randomNum" to a random number min: 1, Max: 100. Then you have have if/else statements saying "if(both(randomNum > 0 and randomNum <= 50), then itemDropped == coin" and then have another one except it would be randomNum > 50 and randomNum <= 100. You can add other quantities by just adding more of these, just make sure that the numbers are ranged to 100, or you will be able to drop more than one item at a time, or drop nothing at all sometimes.

Also, an easier way would be to make nested if/else, where you have "if(random <= 25), drop coin; [b]else[b] if(randomNum < 50), drop weapon; [b]else[b] if(randomNum < 100), give double experience". You would have every if statement within the else of the previous if/else statement. This would make it a 25% chance of getting coin, 25% chance of weapon, and 50% change of bonus XP. This second method better programming and it would actually be easier to do, so just do it this way.

Need an example world? Just ask


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Old
DensetsuNoKaboom
Senior Member
 
DensetsuNoKaboom's Avatar
 
Status: Offline
Posts: 1,188
Join Date: May 2010
Location: e4eaf2
Default 06-11-2010, 06:53 PM

Or you could use the chooseProbabilityOfTrue function. "When enemy = hit, do if chooseProbabilityOfTrue=40%, then drop weapon, else if chooseProbabilityOfTrue=20%, then drop coin..."
And so on.


Thank you for taking the time to read this signature. This signature loves you.
   
Reply With Quote
Old
Watsamax1
Senior Member
 
Watsamax1's Avatar
 
Status: Offline
Posts: 155
Join Date: Aug 2009
Default 06-11-2010, 07:06 PM

how do i use if statements cuz i must of forgot because i say if knight is within 10 meters of a boar, boar point at knight it does nothing.


___________________________________________________

Watsamax Industries
Games Produced for Watsamax Industries Inc. 2010
Watsamax Industries: New York
Watsamax@gmail.com
http://www.facebook.com/profile.php?id=100001253371874#!/profile.php?id=100001253371874&v=wall
http://www.youtube.com/user/Watsamax
___________________________________________________
   
Reply With Quote
Old
DensetsuNoKaboom
Senior Member
 
DensetsuNoKaboom's Avatar
 
Status: Offline
Posts: 1,188
Join Date: May 2010
Location: e4eaf2
Default 06-11-2010, 07:07 PM

I didn't understand a word of that, could you repost it with correct spelling and grammar?


Thank you for taking the time to read this signature. This signature loves you.
   
Reply With Quote
Old
Watsamax1
Senior Member
 
Watsamax1's Avatar
 
Status: Offline
Posts: 155
Join Date: Aug 2009
Default 06-11-2010, 07:25 PM

I make a method called like idk attack. i say when world starts (attack) in the method i have it if knight is within idk 15 meters of boar. boar point at knight and move to knight. but it only works if i make it exactly like 23 meters. even if i move to it it doesn't work.


___________________________________________________

Watsamax Industries
Games Produced for Watsamax Industries Inc. 2010
Watsamax Industries: New York
Watsamax@gmail.com
http://www.facebook.com/profile.php?id=100001253371874#!/profile.php?id=100001253371874&v=wall
http://www.youtube.com/user/Watsamax
___________________________________________________
   
Reply With Quote
Old
Dameria
Senior Member
 
Dameria's Avatar
 
Status: Offline
Posts: 976
Join Date: Sep 2009
Location: United States
Default 06-11-2010, 10:00 PM

Inside the if statement you have to have a "a < b" statement (found in world.functions). Then for "a" you put distance between knight and boar (found in knight.functions) and for "b" you put the distance in meters (in this case 15). That should work as long as you put it in the correct place in the code (think out the steps in your head from when you press the button and what will happen in each code of the method, and place it in the correct order for it work properly for what you want it to do).


Check out my best projects so far and please comment:

Tic-Tac-Toe 2.0 ................... http://www.alice.org/community/showthread.php?t=3548
Alice Paint ........................... http://www.alice.org/community/showthread.php?p=23408
Real-Time Clock .................. http://www.alice.org/community/showthread.php?p=12725
Maze Game ......................... http://www.alice.org/community/showthread.php?t=4301
   
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.