Attack and Hug use a role play system where it deals or heals random damage, everyone has 1000hp and 0 exp at level 0, every time you kill someone you gain 1 exp, every 100 exp you level up!

Simple /dice command (Rolls a 6 sided dice) dice.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_dice extends pfcCommand
{
var $usage = "/dice";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$msg = phpFreeChat::PreFilterMsg(rand(1,6));
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s rolls a dice: It lands %s!",$u->getNickname(), $msg);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}
}
?>
/attack command (Attacks target with optional weapon) attack.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_attack extends pfcCommand
{
var $usage = "/attack {nick} [{tool}]";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$params = $p["params"]; // modif 1
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$nick = isset($params[0]) ? $params[0] : '';
$tool = isset($params[1]) ? $params[1] : '';
$tool = $tool==''?"weapon":$tool;
$dmg = phpFreeChat::PreFilterMsg(rand(0,100));
$hitpoint = $ct->getUserMeta($nick, 'hp');
$exp = $ct->getUserMeta($u->nickid, 'xp');
if ($hitpoint == "") $hitpoint = 1000;
if (trim($param) == "" || $nick== "")
{
// error
$cmdp = $p;
$cmdp["param"] = _pfc("Missing parameter");
$cmdp["param"] .= " (".$this->usage.")";
$cmd =& pfcCommand::Factory("error");
$cmd->run($xml_reponse, $cmdp);
return;
}
$hitpoint -= $dmg;
$ct->setUserMeta($nick, 'hp', $hitpoint);
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s attacks %s with a %s, dealing %s damage! [%s]",$u->getNickname(), $nick, $tool, $dmg, $hitpoint);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
if ($hitpoint <= 0)
{
$exp += 1;
$ct->setUserMeta($u->nickid, 'xp', $exp);
$ct->setUserMeta($nick, 'hp', 1000);
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s has been defeated! %s gained 1 exp! [%s]", $nick,$u->getNickname(), $exp);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}
if ($exp > 100)
{
$exp = 0;
$ct->setUserMeta($u->nickid, 'xp', $exp);
$lvl = $ct->getUserMeta($u->nickid, 'lvl');
$lvl += 1;
$ct->setUserMeta($u->nickid, 'lvl', $lvl);
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s levelled up! [%s]", $u->getNickname(), $lvl);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}
}
}
?>
/hug command (Hugs target or asks for hug) hug.class.php
- Code: Select all
<?php
require_once(dirname(__FILE__)."/../pfccommand.class.php");
class pfcCommand_hug extends pfcCommand
{
var $usage = "/hug {nick}";
function run(&$xml_reponse, $p)
{
$clientid = $p["clientid"];
$param = $p["param"];
$params = $p["params"]; // modif 1
$sender = $p["sender"];
$recipient = $p["recipient"];
$recipientid = $p["recipientid"];
$c =& pfcGlobalConfig::Instance();
$u =& pfcUserConfig::Instance();
$ct =& pfcContainer::Instance();
$nick = isset($params[0]) ? $params[0] : '';
$dmg = phpFreeChat::PreFilterMsg(rand(0,100));
$hitpoint = $ct->getUserMeta($nick, 'hp');
$exp = $ct->getUserMeta($u->nickid, 'xp');
if ($hitpoint == "") $hitpoint = 1000;
if (trim($param) == "" || $nick== "" || $nick == $u->getNickname())
{
// Need hug
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s wants a hug!",$u->getNickname());
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
return;
}
$hitpoint += $dmg;
$ct->setUserMeta($nick, 'hp', $hitpoint);
$cmdp = $p;
$cmdp["recipient"] = $recipient;
$cmdp["recipientid"] = $recipientid;
$cmdp["param"] = _pfc("%s hugs %s, healing them %s points! [%s]",$u->getNickname(), $nick, $dmg, $hitpoint);
$cmd =& pfcCommand::Factory("notice");
$cmd->run($xml_reponse, $cmdp);
}
}
?>