Jump to content

Recommended Posts

Think about it logically, then you can start programming it.

You will have 2 users. User A and User B.

User A will Attack user B

So the first thing you will need to do is get this information out of your database.

----

Once you have these values you then need to make a formula. How do these stats relate to the battle?

Create a formula, it might be something like (($strength+$hp)*$speed)) work out what it is exactly the make it.

When you have that much done post again, after this you go onto comparing the 2 values based on the players. Then what happens after the battle is done.
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117254
Share on other sites

this is the main part i dont understand in the attack system

[quote]Once you have these values you then need to make a formula. How do these stats relate to the battle?

Create a formula, it might be something like (($strength+$hp)*$speed)) work out what it is exactly the make it.[/quote]


as you can guess strength makes the user attack for more damage - where as speed makes the user atatck more times in a row.

i.e

1. You attack $user with your $weapon doing $damage (hp left)
2. You attack $user with your $weapon doing $damage (hp left)
3. You attack $user with your $weapon doing $damage (hp left)
4. $user attacks you with there $weapon doing $damage (hp left)
5. You attack $user with your $weapon doing $damage (hp left)

then a message "You won you gained $gold and $exp" or "You lost the battle"
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117260
Share on other sites

RPG systems need rules as mentioend by others here to determine a lot of things.

A formula as mentioned above is good to work out who will win but to add a little spice to a good battle system trying setting a randomised value.

So for example if your forumla works out that the player can do 50 points of damage to someone, get PHP to randomise the number between -10 and +10 of that value so that the player may do damage anywhere between 40 points to 60 at any given time.
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117284
Share on other sites

[quote]In this case you need 3 functions.

The first being the combat system
The second for the money. (How much does the winner get?)
The third being exp.
[/quote]

i have a row for money/exp the amount of money/exp will be determined by what level there enemy was

[quote author=Perad link=topic=113340.msg460524#msg460524 date=1162305088]
In this case you need 3 functions.

The first being the combat system
The second for the money. (How much does the winner get?)
The third being exp.

As for your problem, do they fight to the death or attack a set amount of times?


[/quote]

Thay fight till one of em has "0" hp left

i know this attack system is not going to be a easy task. i just hope i can manage it :s
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117293
Share on other sites

You'll be much better off creating a [i]Character[/i] or [i]User[/i] class that you can then use to attack the opponent. If you write it well, you can handle all your functions and all within one class, and you can simply instantiate a class for each opponent and do something like this for your implementation:
[code]
<?php
$player1 = new Character();
$player2 = new Character();

$player1->attach(&$player2);
?>
[/code]

If you're using PHP5, your objects will be passed by reference by default, so you wouldn't have to use the ampersand.
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117303
Share on other sites

I think it all depends on how complex you want your attack system to be.  Something simple would to have it merely retrieve the stats from the database and use them without any kind of formula.  Example:

Character A has 20 Strength and 85 HP
Character B has 14 Strength and 67 HP

Each attack every other second, with the first character to attack determined randomly.  Damage is just the target's HP - the attacker's strength.  In a case like this one, Character A will always win.  Not very exciting.

The reason why the people above me kept asking about what formula you've developed is because RPGs take a lot into account when it comes to combat.  Is anyone wearing armor?  Any stat bonuses?  Any status effects (poison, blindness, mute)?  Does positioning matter?  Who has a greater chance to hit the other?  Are they even in melee range?  Or is one using a ranged weapon (bow, gun, crossbow, sling, etc)?  Or magic?  Every turn in combat in every RPG requires the manipulation of this kind of data in a specific way.  It is up to you to create that specific way, either by liberally using the combat system of your favorite tabletop RPG or by creating one by yourself.

Good luck. :)
Link to comment
https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117309
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.