A combat system I've been interested in implementing, but haven't had the time, goes kind-of like this:

Weapons have an attack statCreatures have a base defence stat.Armour etc. adds to the defence.Whenever a creature is attacked, you use random.nextInt(defence-attack) (obviously if attack >= defence you don't do that check)If the result is 0, or attack >= defence, target creature is killed/unconscious/whatever.

Yeah, recreating variables is a good way to clog your memory up and make your program slower... plus their scope is only within that for loop, so you cannot use them outside of it. I wonder, how did you not know this before now?

Yeah, recreating variables is a good way to clog your memory up and make your program slower... plus their scope is only within that for loop, so you cannot use them outside of it. I wonder, how did you not know this before now?

You could have a system like this:Creatures have base defense, attack, dodge, accuracy, health, luckWeapons add to attackArmour adds to defenceif accuracy + random number between 1 and luck is larger than dodge:if attack + weapons is larger than defence + armour:damage done = combined attack - combined defencedamage done is deducted from health.If health is 0, creature dies/whatever

java-gaming.org is not responsible for the content posted by its members, including references to external websites,
and other references that may or may not have a relation with our primarily
gaming and game production oriented community.
inquiries and complaints can be sent via email to the info‑account of the
company managing the website of java‑gaming.org