Author Topic: PvP timeout  (Read 7984 times)

Alchemion

  • Guest
PvP timeout
« on: September 22, 2008, 05:51:14 pm »
The game engine has a timeout set for attacking a player in pvp, default to 600 s...

For testing purposes I have reduced the timeout (somewhere in /lib/pvplist.php ) from 600s to 1s, but (it seems) the timeout is still 600 ... please, tell me where should I modify more so the pvp timeout would reduce to 1-5 secs ?...

Also, I would like to test the pvp (slay other players) directly on online players... what lines/conditions do I have to remove and, especially, from what files ?...

Thank you very much.


« Last Edit: September 22, 2008, 05:53:40 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #1 on: September 22, 2008, 07:21:36 pm »
First,
do you pvp from the fields or i.e. the dwellings?

dwellings are an entirely different story.

The hook pvplist passes you a list - you can modify it or generate (!) your own.

Means you can select all players you want to be attackable in there - even dead ones. Or online ones.
That's how I do my bloody halloween ^^

All what you want to do can be done easily with a module - nb core should be ready.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #2 on: September 22, 2008, 10:55:26 pm »
Quote
The game engine ...  I would like to test the pvp (slay other players) directly on online players

From the expression, i have pointed that (using the nb+ engine) i would like to test the pvp from the fields, the pvp provided with the core engine...

Quote
All what you want to do can be done easily with a module - nb core should be ready.


is there a module that can alter the attackable (pvp) listed targets ? my alterings to (the seconds from) pvptimeout from pvplist.php did not reduce the pvptimeout ?...
« Last Edit: September 22, 2008, 11:05:48 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #3 on: September 23, 2008, 06:17:49 am »
First off, try not to edit core but to THINK how to make a module.

If you have a solution, and it's dead ugly but can't be done better as the core lacks stuff, think about a core edit.

Download my pvpbalance module from lotgd-downloads.com - it blocks users from the pvplist that have too few DKs (or too much) to be attacked by somebody.

It should show you the general idea.
debug() the $args - and you see what players are in there already - you can even change their location to make them "lying here" ;)) and get pwned. Or, as said, do your own list.

That is, by the way, what the dwellings_pvp does ... hence it is different than the fields.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #4 on: September 23, 2008, 11:17:54 am »
i use pvp balance... i didn't think about modifying it...

but, as you motivated, it might be better modify that module than modify the core pvp code...

i will think... about it... and test some more... testing eats a lot of the novice's time ... :)

and again: i can modify the listing with the pvpbalance module, can i modify also the pvptimeout with it ?...
« Last Edit: September 23, 2008, 12:37:17 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #5 on: September 23, 2008, 12:29:14 pm »
Yes.

You need to set for _each row_ a field "pvpflag" and modify that.
I recommend setting it to

Code: [Select]
date("Y-m-d H:i:s");
so, in the pvpbalance you only need to:

Code: [Select]
$args['pvpflag']=date("Y-m-d H:i:s");

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #6 on: September 23, 2008, 12:53:42 pm »
it is so simple... i know... you keep telling me that to every code here...

by the way : can you improve (enhance) the pvpbalance module so that the admin can set more pvp options, including : "can online players be attacked (yes/no)" ; "max difference level between players (0-x)" ; "pvptimeout (x secs)" and more... you know better...

thank you.

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #7 on: September 23, 2008, 04:24:06 pm »
it is not a "pvp all pvp like you want to" module =)

you can use it like this, but for me it should limit (!) pvp, not expand it.

and also, I cannot do such a setting, as the selected people are not in there - I'd need to expand the modul vastly and make it more core-independent...which I don't like.

the max difference between players is  a core setting in +nb btw.

It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #8 on: September 24, 2008, 12:22:36 am »
Quote
I'd need to expand the modul vastly and make it more core-independent...which I don't like.

that's the same reason for i do want to edit the core, more than a module .. :)

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #9 on: September 24, 2008, 06:14:38 am »
=)

no, what you want to do is just simpler for you to think about in a module.

In a core edit, you just go to the file and edit 3 lines - you don't have to think about "what $args do I get?" and "what do I exactly need to do here without breaking other stuff" and "I  am here in my own module, what do I need to setup in order to get it work"

I might add that these are very obsolete programming styles... google for "loose coupling" and such things - interfaces ARE there for a purpose.

Go ahead and edit core - then in a year a new +nb is out, with features you like - you install it, and all edits go byebye ... and you see much different core code - and are unable to put it in together except if you use days to work on things you already did....

Personally, I am far too lazy to do such things ;)
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #10 on: September 24, 2008, 02:55:06 pm »
you're so right...

but, again, for you it's easy to say... for me... it's a hell of testing time... i might get into learning php... maybe it's easier and will take less than testing logical copy/paste... not sure, though... where will i use php, when my job has nothing to do with it ?!...

nevertheless, you convinced me working on the existing pvpbalance module, to enhance it myself... of course, with your help... :)

thank you very much for your help so far...

Alchemion

  • Guest
Re: PvP timeout
« Reply #11 on: October 04, 2008, 09:20:48 pm »
Hi,

I got back on testing the game engine...

I tried to get my ideas working within a pvp module, yet I finished by modifying the pvplist.php lib...

This is the modified lib (done by commenting 3 more  lines) :

Code: [Select]
<?php
// translator ready
// addnews ready
// mail ready

//put these outside the function since they're used by scripts outside of
//this function.
$pvptime getsetting("pvptimeout",3600);
$pvptimeout date("Y-m-d H:i:s",strtotime("-$pvptime seconds"));

function 
pvplist($location=false,$link=false,$extra=false,$sql=false){
global $session,$pvptime,$pvptimeout;

if ($location===false)
$location $session['user']['location'];
if ($link===false) {
$link basename($_SERVER['SCRIPT_NAME']);
}
if ($extra === false) {
$extra "?act=attack";
}

$days getsetting("pvpimmunity"5);
$exp getsetting("pvpminexp"1500);
$clanrankcolors = array(CLAN_APPLICANT=>"`!",CLAN_MEMBER=>"`#",CLAN_OFFICER=>"`^",CLAN_LEADER=>"`&");
$id $session['user']['acctid'];
$levdiff  getsetting('pvprange',2);
$lev1 $session['user']['level']-$levdiff+1;
$lev2 $session['user']['level']+$levdiff;
//$last = date("Y-m-d H:i:s",strtotime("-".getsetting("LOGINTIMEOUT", 900)." sec"));

if ($sql === false) {
$loc addslashes($location);

$sql "SELECT acctid, name, race, alive, location, sex, level, laston, " .
"loggedin, login, pvpflag, clanshort, clanrank, dragonkills, " .
db_prefix("accounts") . ".clanid FROM " .
db_prefix("accounts") . " LEFT JOIN " .
db_prefix("clans") . " ON " db_prefix("clans") . ".clanid=" .
db_prefix("accounts") . ".clanid WHERE (locked=0) " .
"AND (slaydragon=0) AND " .
"(age>$days OR dragonkills>0 OR pk>0 OR experience>$exp) " .
($levdiff==-1?"":"AND (level>=$lev1 AND level<=$lev2)")." AND (alive=1) " .
//"AND (laston<'$last' OR loggedin=0) AND (acctid<>$id) " .
"AND location='$loc' ".
"ORDER BY location='$loc' DESC, location, level DESC, " .
"experience DESC, dragonkills DESC";
}
$result db_query($sql);

$pvp = array();
while($row db_fetch_assoc($result)) {
$pvp[] = $row;
}

$pvp modulehook("pvpmodifytargets"$pvp);

tlschema("pvp");
$n translate_inline("Name");
$l translate_inline("Level");
$loc translate_inline("Location");
$ops translate_inline("Ops");
$bio translate_inline("Bio");
$att translate_inline("Attack");

rawoutput("<table border='0' cellpadding='3' cellspacing='0'>");
rawoutput("<tr class='trhead'><td>$n</td><td>$l</td><td>$loc</td><td>$ops</td></tr>");
$loc_counts = array();
$num count($pvp);
$j 0;
for ($i=0;$i<$num;$i++){
$row $pvp[$i];

if (isset($row['silentinvalid']) && $row['silentinvalid']) continue;
//if (!isset($loc_counts[$row['location']]))
// $loc_counts[$row['location']] = 0;
//$loc_counts[$row['location']]++;
//if ($row['location'] != $location) continue;
$j++;
$biolink="bio.php?char=".$row['acctid']."&ret=".urlencode($_SERVER['REQUEST_URI']);
addnav(""$biolink);
rawoutput("<tr class='".($j%2?"trlight":"trdark")."'>");
rawoutput("<td>");
if ($row['clanshort']>"" && $row['clanrank'] > CLAN_APPLICANT) {
output_notl("%s&lt;`2%s%s&gt;`0 ",
$clanrankcolors[ceil($row['clanrank']/10)], $row['clanshort'],
$clanrankcolors[ceil($row['clanrank']/10)], true);
}
output_notl("`@%s`0"$row['name']);
rawoutput("</td>");
rawoutput("<td>");
output_notl("%s"$row['level']);
rawoutput("</td>");
rawoutput("<td>");
output_notl("%s"$row['location']);
rawoutput("</td>");
rawoutput("<td>[ <a href='$biolink'>$bio</a> | ");
if($row['pvpflag']>$pvptimeout){
output("`i(Attacked too recently)`i");
}elseif ($location!=$row['location']){
output("`i(Can't reach them from here)`i");
}elseif (isset($row['invalid']) && $row['invalid']!="") {
if ($row['invalid']==1$row['invalid']="Unable to attack";
output("`i`4(%s`4)`i",$row['invalid']);
}else{
rawoutput("<a href='$link$extra&name=".$row['acctid']."'>$att</a>");
addnav("","$link$extra&name=".$row['acctid']);
}
rawoutput(" ]</td>");
rawoutput("</tr>");
}

$sql="SELECT count(location) as counter, location FROM ".db_prefix('accounts').
" WHERE (locked=0) " .
"AND (slaydragon=0) AND " .
"(age>$days OR dragonkills>0 OR pk>0 OR experience>$exp) " .
($levdiff==-1?"":"AND (level>=$lev1 AND level<=$lev2)")." AND (alive=1) " .
//"AND (laston<'$last' OR loggedin=0) AND (acctid<>$id) " .
"AND location!='$loc' GROUP BY location ORDER BY location; ";
$result=db_query($sql);

if ($j==0){
$noone translate_inline("`iThere are no available targets.`i");
output_notl("<tr><td align='center' colspan='4'>$noone</td></tr>"true);
}
rawoutput("</table>",true);

if (db_num_rows($result)!= 0) {
output("`n`n`&As you listen to different people around you talking, you glean the following additional information:`n");
while ($row=db_fetch_assoc($result)) {
$loc=$row['location'];
$count=$row['counter'];
$args modulehook("pvpcount", array('count'=>$count,'loc'=>$loc));
if (isset($args['handled']) && $args['handled']) continue;
if ($count == 1) {
output("`&There is `^%s`& person sleeping in %s whom you might find interesting.`0`n"$count$loc);
} else {
output("`&There are `^%s`& people sleeping in %s whom you might find interesting.`0`n"$count$loc);
}
}
}
tlschema();
}
?>


I succeeded getting rid of the online-offline issue and partenered it with the pvpnocheat.php module, from DP...

But I still could not get the pvptimeout modified according to my game scenario needs... I have set it apparently to 3600, yet it timeouts in 10 minutes...

Please suggest where to modify within the lib or other core file, the pvptimeout.

Thank you very much.
 

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #12 on: October 04, 2008, 09:28:44 pm »
I suggest making a module =)

but well, suit yourself and edit core ^^

see these lines:

$pvptime = getsetting("pvptimeout",3600);
$pvptimeout = date("Y-m-d H:i:s",strtotime("-$pvptime seconds"));

just change the first to a fixed value, and make plenty use of the debug() function.

Sorry, but as said -> build your own list. That is far better.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro

Alchemion

  • Guest
Re: PvP timeout
« Reply #13 on: October 04, 2008, 09:36:58 pm »
I would wish it... but... with my late hosting issues and the urge to get the game working and public, i am getting kinda tired of thinking...

i may do so in the near future : getting a pvp list, through a module, but for now, i just need to test other prioritary stuff like the translation wizard... ;)

by the way, for my enlightment, where else is located the record about the 10 minutes (or 600 seconds) pvptimeout ?... :)

thank you very much for your fast reply... this would keep me working on a little nightyer ... :)

still, if you think now of improving the pvp + nb core game settings, with the option for listing online/offline players and with the option to modify the pvptimeout, I consider it a great addition to the +nb core... and other admins would do, too...
« Last Edit: October 04, 2008, 09:44:04 pm by Alchemion »

Nightborn

  • Administrator
  • Sr. Member
  • *****
  • Posts: 318
  • Karma: +20/-0
    • View Profile
    • Shinobilegends
Re: PvP timeout
« Reply #14 on: October 05, 2008, 09:00:48 am »
As indicated, I made already a lot of the STANDARD pvp to a setting ... but I somewhat refuse making per-admin solutions core - when your wishes are to have it freely customizable...

Last one: hook into the pvplist, make your own list. full stop =)
Edit the info in the $args you pass to make them online - just change the flag.

if you want to alter their last pvp timestamp - do so there also.

if you are tired of thinking, then there is nothing more I have to say =)

I abandoned hope for a "great out of the box" server - Bleach is now almost a year old, and vital things still not in - because they need to be done from scratch ;) and are bigger than a module that needs only a 50 line dohook.
It should be fixed, but it won't be easy and it won't be fast. If you want
to help - wonderful. But keep in mind that it will take months of wading
through the ugliest code we have in the tree. If you've got a weak stomach -
stay out. I've been there and it's not a nice place.

   - Al Viro