R1der Posted October 31, 2006 Share Posted October 31, 2006 Ok i am making a PHP rpgi am kinda stuck on the attack system thoi want the attack system to run from the users statsSpeed , strength and HPDoes anyone have any ideas for how i can do this?Edit:To be honest i dont have a clue where to start with it :S Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/ Share on other sites More sharing options...
Perad Posted October 31, 2006 Share Posted October 31, 2006 Have you created the stats system?Once the stats system is made its a simple formula to work out who wins an attack. Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117245 Share on other sites More sharing options...
R1der Posted October 31, 2006 Author Share Posted October 31, 2006 How ya mean stat system?i have the stats in the databaseStrength , speed and hpI have never made anything like this b4 so i dont know what i am doing to this pointEven if you can point me in the right direction of a site that explains it. Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117247 Share on other sites More sharing options...
Perad Posted October 31, 2006 Share Posted October 31, 2006 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 BSo 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. Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117254 Share on other sites More sharing options...
R1der Posted October 31, 2006 Author Share Posted October 31, 2006 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.e1. 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" Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117260 Share on other sites More sharing options...
Perad Posted October 31, 2006 Share Posted October 31, 2006 In this case you need 3 functions.The first being the combat systemThe 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 Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117281 Share on other sites More sharing options...
Cep Posted October 31, 2006 Share Posted October 31, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117284 Share on other sites More sharing options...
R1der Posted October 31, 2006 Author Share Posted October 31, 2006 [quote]In this case you need 3 functions.The first being the combat systemThe 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 systemThe 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 lefti know this attack system is not going to be a easy task. i just hope i can manage it :s Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117293 Share on other sites More sharing options...
obsidian Posted October 31, 2006 Share Posted October 31, 2006 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. Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117303 Share on other sites More sharing options...
KevinM1 Posted October 31, 2006 Share Posted October 31, 2006 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 HPCharacter B has 14 Strength and 67 HPEach 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. :) Quote Link to comment https://forums.phpfreaks.com/topic/25691-attack-system/#findComment-117309 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.