Page 1 of 1

pvp help

Posted: Sun Feb 14, 2010 7:13 pm
by witherdon
i have a fully working ai combat system but i don't know how to change this to work in a pvp environment

does anyone know how to construct a pvp system and can give me a basic script or know if halls has done a video or know of any other video ect

thanks

Re: pvp help

Posted: Sun Feb 14, 2010 10:59 pm
by Callan S.
asycronous pvp? Or players take turns?

In terms of numbers engaging each other, each player is much like a monster - they have a set of numbers that work against each other like a standard player vs monster encounter. The only change is player choice, if there is any (if there isn't, you can go full asycronous PVP and indeed aught to). And again, player choices are just logged into the database as a number, numbers interact in the same way they do in player vs monster.

If you know how to do PVE you probably know the bulk of this already.

Re: pvp help

Posted: Sat Feb 20, 2010 5:37 pm
by witherdon
thanks for the reply and it makes it all looks so easy now except how do i alert the people who have been attacked to the fact that they have been attacked?

Re: pvp help

Posted: Sat Feb 20, 2010 6:37 pm
by Jackolantern
If you are wanting to go with PHP alone, you would either have to make PvP voluntary where both players have to agree before it begins, make it open and hardcore where players must be constantly alert since they could be killed without knowing if they don't refresh, or make it abstract where players can only make one attack against other players at a time, over long periods of time.

If you want to use AJAX, you could have an icon on the page that lights up when the player is under attack, allowing them to click on it to defend themselves.

Re: pvp help

Posted: Sat Feb 20, 2010 6:38 pm
by OldRod
You could store a flag in their user data and the next time they log in, or load a page, whatever, check that flag and let them know.

Re: pvp help

Posted: Sat Feb 20, 2010 7:05 pm
by hallsofvallhalla
the way I did it in FS was like what oldrod had mentioned. You have a field in the players table called lastattackeby then why someone attacks you it stores their name there. You could also go further than that and add damage and time.

FS has a full working PVP system that I will be releasing soon.

Re: pvp help

Posted: Sat Feb 20, 2010 8:07 pm
by Jackolantern
OldRod wrote:You could store a flag in their user data and the next time they log in, or load a page, whatever, check that flag and let them know.
That is pretty much what I meant by the third method I mentioned. You either have to let players attack each other back and forth over periods of time, or allow them nearly real-time attacking, which would likely be considered hardcore since players could be killed while they are reading a page, afk for just a moment, just before refreshing the page, etc.

Re: pvp help

Posted: Sat Feb 20, 2010 9:21 pm
by witherdon
well the hard core method would suit the games style better

i used this as my method:

Code: Select all

$username = $_session['username'];
$result=mysql_query("SELECT * from battle where session_id='$username'");
if(mysql_num_rows($result) > 0) {
	while($row = mysql_fetch_array($result)) {	
echo "<a href=\"../battle.php\">you have been attacked";

Re: pvp help

Posted: Sat Feb 20, 2010 10:01 pm
by hallsofvallhalla
so basically you are putting this on top of every page? And then when a attack is made a entry is put into the battle table with the attacked players name?
That's actually a good method. I personally would add a field to players called attacked, and then check it, that way on top of your page you can just put

Code: Select all

if($playerinfo3['attacked'] == 1)
{echo "you have been attacked......and the link blah blah";}
since you are already querying the player on every page anyways you are not making a extra query.

Re: pvp help

Posted: Sat Feb 20, 2010 11:28 pm
by witherdon
are suggesting to use this as well as my method

and to answer your questions my method is place in the menu which is a include and the moves are put directly into the table this was to allow for multiple techniques to be used