Author Topic: Need help with Player Vs Player Combat System  (Read 929 times)

Offline SYKO

  • Level 4
  • *
  • Posts: 13
  • Reputation: +0/-0
    • View Profile
Need help with Player Vs Player Combat System
« on: December 12, 2009, 07:22:57 AM »
I am new to game development and also new to here.
I want to add Player to Player combat system in my game.
Can someone show me the way?

thanks
SYKO

Offline Glenugie

  • Level 10
  • *
  • Posts: 64
  • Reputation: +0/-0
    • View Profile
    • The Land of Ennui
Re: Need help with Player Vs Player Combat System
« Reply #1 on: December 12, 2009, 07:27:40 AM »
It would depend on how you would want the system to work. If you want it to be a simple turn based system, probably having a database called PVP with fields for Player1, Player2, Player1Action, Player2Action, Player1Health, Player2Health and Round would be sufficient. Simply have the PVP window show a screen with a list of actions, when both players have selected an action, the combat will advance a round, take off health as appropriate, and this can continue until one player has no health left.

~Glenugie~

Offline Nox

  • Level 35
  • **
  • Posts: 738
  • Reputation: +12/-2
    • View Profile
Re: Need help with Player Vs Player Combat System
« Reply #2 on: December 12, 2009, 07:46:46 AM »
Depends if you want it to be immediately calculated or interactive, involving both players, or if both would be possible - the interactive one is of course more complex
... you need to decide if offline player can be attacked, how much time does he have to respond, what happens if he just closes the browser and doesn't fight anymore, if time for round is fixed or is finished when player decided what to do (then you need to frequently check if the player has his turn)...

---
Generally you need things (db table* and php functions&variables or object) to take care about the combat itself and then other things to deal with everything else

If a player chooses to attack then combat table entry is created, players' status is changed to "in combat" and is redirected to combat page. If it's immediate, you load a combat engine (it's advisable to make it universal and independent so you can switch engines or load it somewhere), calculate combat and show and store it's result and change players' status to "idle" or whatever...

if it's interactive then you load the engine and display all info and possible actions...this is also done every time a player goes to this combat page and is currently in combat. The page checks if it's players turn and displays info about recent turns (most importantly the last action of the opponent). The combat table also stores who's turn is now and when it began etc. ... most of the rest I already said

*) it can be db table or of course other storage mean... or you can have db table but create a session (you have to have both 'cause sessions are not permanent) to speed things up

Should you have any more specific question about combat system feel free to ask
Meet us at an IRC irc.freenode.net #bbg as well
Enjoy http://spiritbeacon.noxart.cz/ !

Offline Sagefire135

  • Level 14
  • *
  • Posts: 107
  • Reputation: +2/-0
    • View Profile
Re: Need help with Player Vs Player Combat System
« Reply #3 on: December 12, 2009, 01:45:40 PM »
if your new, start with something simple. then work up to complex if you want to.

it doesnt get much more simple than this:
players have HP, defense, and damage.
load up the players' stats and save em as varables.
attacker goes first, the y's HP is reduced by [x's damage] - [y's defense]
then the defender goes and x's HP is reduced by [y's damage] - [x's defense]
repeat until one player is dead.
update the players HP in a db.

Its not realistic, or complex, or fun...but it works.

Offline saljutin

  • Level 22
  • *
  • Posts: 260
  • Reputation: +6/-0
    • View Profile
Re: Need help with Player Vs Player Combat System
« Reply #4 on: December 12, 2009, 03:46:54 PM »
but this system can lead that stronger more active players would kill other players by attacking them multiple times in a row :)
so I think that author of this topic must tell us more about this...are there going to be pvp areas or arenas or open pvp?

Offline ricardokb

  • Level 5
  • *
  • Posts: 18
  • Reputation: +0/-0
    • View Profile
Re: Need help with Player Vs Player Combat System
« Reply #5 on: January 11, 2010, 05:11:23 PM »
could this simple code work?

for (i=1; i<=$player1_health; i++ ; || i=1; i<=$player2_health; i++)

{
//atack system
}

That means that the attacks will end when one player's health is 0.
« Last Edit: January 11, 2010, 05:25:04 PM by ricardokb »

 


SimplePortal 2.3.3 © 2008-2010, SimplePortal