Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Text based combat system trial (Java)  (Read 1030 times)
0 Members and 1 Guest are viewing this topic.
Offline GabrielBailey74
« Posted 2013-05-15 05:30:12 »

Hey JGO ^_^, haven't been on for a while Cheesy (Few months i believe)
Nice to be back Roll Eyes

I (tonight) decided to try to make a fair combat system which will include:
  • Weapons (Accuracy Modifiers)
  • Level System (Attack, Strength, Defence, Health)
  • Simple Combat System (Melee)

I'll be attempting to add the following to the combat system (this is where I need a little help):
  • A chance to hit formula
  • A chance to block formula
  • A damage formula

To be honest I haven't gotten too far yet lol.

I've slowly been developing on it for the past half our or so, but I figured I'd ask for help before I begin furiously 'tweaking' with the percentages to in some UN-profound way Tongue

The reason why I'm posting this is I'd like to get some information / tips on how to go about calculating the accuracy percentage, the blocking chance and damage dealt etc.

Side information:
Accuracy (Tier/Level 1 weapons) = 1.0
All levels will be level 1 @ first (ATK/STR/DEF) and the health will be 10, all having 99 as maximum.

Any feedback would be great guys thanks ^_^

Offline HeroesGraveDev

JGO Kernel


Medals: 269
Projects: 11
Exp: 2 years


┬─┬ノ(ಠ_ಠノ)(╯°□°)╯︵ ┻━┻


« Reply #1 - Posted 2013-05-15 08:08:43 »

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

Weapons have an attack stat
Creatures 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.

Just an idea.

Offline Danny02
« Reply #2 - Posted 2013-05-15 09:12:22 »

I hope I don't derail you thread with posting random ideas about attack systems, but ... Smiley

While playing Baldursgate a while back I really liked what effect it has that your weapons uses 1 or more dice calculate the attack damage.

The idea is this that you have a weapon which can give betwen x-y damage (i.e. 10-20), but the random distribution can be different.

one weapon can have damage between 20-25 and each valule has the same chance to be picked
and the other weapon has 15 - 30, but a higher chance that a lower value is picked

so in essence I like it when the player has a real choice between different weapons, and there isn't only one correct to choose because it is most effective
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Online Roquen
« Reply #3 - Posted 2013-05-15 09:26:46 »

Probability distributions are interesting (I promise!).  A reasonable accessible overview of some basics is available here: http://www.redblobgames.com/articles/probability/damage-rolls.html
Offline GabrielBailey74
« Reply #4 - Posted 2013-05-15 09:41:09 »

Thanks alot roquen seems like what I need, only skimmed over it as it is 2:40AM Tongue
I'll check it out tomorrow.

In the meantime here's my attempt so far:
Only thing working so far is the accuracy / chance % to hit.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
   public CombatTest() {
      int i = 0;
      double[] accuracyMarks = new double[100];

      while (i < 100) {
         /* Player */
         double combatLevel = 0;
         double attack = 99;
         double defence = 1;
         double strength = 1;
         double health = 10;
         double accuracy = 1;
         double weaponAccuracy = 1.0;
         
         /* Enemy */
         double enemyDefence = 77;
         double enemyHealth = 10;
         
         /* Formulas */
         combatLevel = getCombatLevel(new double[] { attack, defence, strength, health });
         attack = attack * (100 / enemyDefence);
         accuracy += attack * Math.random() ;
   
         if (accuracy > 100) { accuracy = 100; }
         accuracyMarks[i] = Math.floor(accuracy);
         
         int chance = (int) accuracyMarks[i++];

         System.out.println("Accuracy = "+chance+".");
      }
      debug(accuracyMarks);
   }


Snippet from the output:
(99 Attack Vs. 77 Defence)
Quote
Accuracy = 100.
Accuracy = 4.
Accuracy = 93.
Accuracy = 39.
Accuracy = 47.
Accuracy = 47.
Accuracy = 100.
Accuracy = 92.
Accuracy = 98.
Accuracy = 97.
Accuracy = 72.
Accuracy = 100.
Accuracy = 100.
Accuracy = 100.
Accuracy = 100.
Accuracy = 12.
Accuracy = 1.
Accuracy = 16.
Accuracy = 47.
Accuracy = 44.
Accuracy = 26.
Accuracy = 100.
Accuracy = 17.
Accuracy = 48.
Accuracy = 100.
Accuracy = 16.
Accuracy = 31.
Accuracy = 95.
Accuracy = 100.
Accuracy = 100.
Accuracy = 4.
Accuracy = 14.
Accuracy = 68.
Accuracy = 75.
Maximum accuracy: 100.0.
Minimum Accuracy: 1.0.
Most Common Accuracy: 100.0.

And this will be goodnight, looking forward to criticism on the above code ^_^
I know it's coming xD

Offline Quarry
« Reply #5 - Posted 2013-05-15 18:31:18 »

You don't have to recreate the variables, I'd suggest that you do this;

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
public CombatTest() {
      int i = 0;
      double[] accuracyMarks = new double[100];

double combatLevel = 0;
         double attack = 99;
         double defence = 1;
         double strength = 1;
         double health = 10;
         double accuracy = 1;
         double weaponAccuracy = 1.0;
         
         /* Enemy */
         double enemyDefence = 77;
         double enemyHealth = 10;

      while (i < 100) {
         /* Player */
         combatLevel = 0;
         attack = 99;
         defence = 1;
         strength = 1;
         health = 10;
         accuracy = 1;
         weaponAccuracy = 1.0;
         
         /* Enemy */
         enemyDefence = 77;
         enemyHealth = 10;
         
         /* Formulas */
         combatLevel = getCombatLevel(new double[] { attack, defence, strength, health });
         attack = attack * (100 / enemyDefence);
         accuracy += attack * Math.random() ;
   
         if (accuracy > 100) { accuracy = 100; }
         accuracyMarks[i] = Math.floor(accuracy);
         
         int chance = (int) accuracyMarks[i++];

         System.out.println("Accuracy = "+chance+".");
      }
      debug(accuracyMarks);
   }
Offline opiop65

JGO Kernel


Medals: 156
Projects: 7
Exp: 3 years


JumpButton Studios


« Reply #6 - Posted 2013-05-15 18:46:48 »

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?

Offline GabrielBailey74
« Reply #7 - Posted 2013-05-15 18:57:29 »

I wonder, how did you not know this before now?

Lol guys.

"Assume" = Ass + U + Me.

How that happened:
"Hmm, variables aren't being updated, lets just throw them in the while loop during my TRIAL."

This is a 100% random trial that's been scrapped numerous times lol, I really don't need code performance critique regarding a 1 second trial.

(Literally a 1 second test)

Thanks though ^_^

Offline Danny02
« Reply #8 - Posted 2013-05-15 19:00:55 »

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?

not sure if serious Emo
Offline masteryoom

JGO Coder


Medals: 5
Projects: 2


If you look closely, you might see it turning...


« Reply #9 - Posted 2013-05-16 07:40:05 »

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

Smiley
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline 65K
« Reply #10 - Posted 2013-05-16 08:19:25 »

Always give variables the narrowest possible scope.
Have a little faith in compiler and JVM optimizations.
Primitive variables != garbage collectable objects.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (38 views)
2014-10-17 03:59:02

Norakomi (28 views)
2014-10-16 15:22:06

Norakomi (24 views)
2014-10-16 15:20:20

lcass (28 views)
2014-10-15 16:18:58

TehJavaDev (53 views)
2014-10-14 00:39:48

TehJavaDev (54 views)
2014-10-14 00:35:47

TehJavaDev (43 views)
2014-10-14 00:32:37

BurntPizza (64 views)
2014-10-11 23:24:42

BurntPizza (36 views)
2014-10-11 23:10:45

BurntPizza (78 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!