mercredi 28 janvier 2015

Math.Random() giving properties to objects based on chance

I'm making an rpg, I want weapons in-game to have mods sort of Diablo 2 style. So far I want mods to be randomly generated based on percent chance, but I also want them to be selectable (when crafting). So I need 2 overloaded methods, one that doesnt require input and another that should take input to access the desired mod. Example:



Public class CopperSword extends Weapon{
private int coldDamage = 0;
private int physicalDamage = 2;

//- Available Mods only for this type of weapon
private String[] mods = {"Fiery" , "ColdSteel", "Raging"}
//Fiery has 10% chance to be given to a weapon, Coldsteel 10%, Raging 80%
//A weapon cannot have more than one mod added.

private int modLevel;
private String modSelected;
private String itemName;
private String baseItemName = " Copper Sword";

//In here the mod should be selected randomly and then set the String
//modSelected to one of the array of mods so it shows in the name.

private void modRandomSelection(){
//Stuff goes in here that selects the mod
modSelected = mods[i];
itemName = modSelected + baseItemName;
}

private void modCraftSelection(int mod){
//mod Int input is to select the mod from the array
}

}


I know I'm asking a lot here, but I would appreciate it a lot, I've spent most of the day figuring out how to draw items from my inventory to the screen and now Im a bit tired to figure out this one, but I would love if you guys gimme a hand D: I'm a total noob but trying my best. I'll give a big choco-cookie and a super-sized glass of milk to whoever helps me n.n


EDIT: Why is people downvoting? come on at least type in a comment what is wrong with the question I made. If not it just seems like griefing.





Aucun commentaire:

Enregistrer un commentaire