"); while($row = db_fetch_assoc($r)) { echo(""); } if (db_num_rows($r) == 0) { echo(""); } echo(""); exit(); } check_su_access(SU_EDIT_MOUNTS); tlschema("mounts"); page_header("Mount Editor"); require_once("lib/superusernav.php"); superusernav(); addnav("Mount Editor"); addnav("Add a mount","mounts.php?op=add"); if ($op=="deactivate"){ $sql = "UPDATE " . db_prefix("mounts") . " SET mountactive=0 WHERE mountid='$id'"; db_query($sql); $op=""; httpset("op", ""); invalidatedatacache("mountdata-$id"); } elseif ($op=="activate"){ $sql = "UPDATE " . db_prefix("mounts") . " SET mountactive=1 WHERE mountid='$id'"; db_query($sql); $op=""; httpset("op", ""); invalidatedatacache("mountdata-$id"); } elseif ($op=="del") { //refund for anyone who has a mount of this type. $sql = "SELECT * FROM ".db_prefix("mounts")." WHERE mountid='$id'"; $result = db_query_cached($sql, "mountdata-$id", 3600); $row = db_fetch_assoc($result); $sql = "UPDATE ".db_prefix("accounts")." SET gems=gems+{$row['mountcostgems']}, goldinbank=goldinbank+{$row['mountcostgold']}, hashorse=0 WHERE hashorse={$row['mountid']}"; db_query($sql); //drop the mount. $sql = "DELETE FROM " . db_prefix("mounts") . " WHERE mountid='$id'"; db_query($sql); module_delete_objprefs('mounts', $id); $op = ""; httpset("op", ""); invalidatedatacache("mountdata-$id"); } elseif ($op=="give") { $session['user']['hashorse'] = $id; // changed to make use of the cached query $sql = "SELECT * FROM ".db_prefix("mounts")." WHERE mountid='$id'"; $result = db_query_cached($sql, "mountdata-$id", 3600); $row = db_fetch_assoc($result); $buff = unserialize($row['mountbuff']); if ($buff['schema'] == "") $buff['schema'] = "mounts"; apply_buff("mount",$buff); $op=""; httpset("op", ""); }elseif ($op=="save"){ $subop = httpget("subop"); if ($subop == "") { $buff = array(); $mount = httppost('mount'); if ($mount) { reset($mount['mountbuff']); while (list($key,$val)=each($mount['mountbuff'])){ if ($val>""){ $buff[$key]=stripslashes($val); } } $buff['schema']="mounts"; httppostset('mount', $buff, 'mountbuff'); list($sql, $keys, $vals) = postparse(false, 'mount'); if ($id>""){ $sql="UPDATE " . db_prefix("mounts") . " SET $sql WHERE mountid='$id'"; }else{ $sql="INSERT INTO " . db_prefix("mounts") . " ($keys) VALUES ($vals)"; } db_query($sql); invalidatedatacache("mountdata-$id"); if (db_affected_rows()>0){ output("`^Mount saved!`0`n"); }else{ output("`^Mount `\$not`^ saved: `\$%s`0`n", $sql); } } } elseif ($subop=="module") { // Save modules settings $module = httpget("module"); $post = httpallpost(); reset($post); while(list($key, $val) = each($post)) { set_module_objpref("mounts", $id, $key, $val, $module); } output("`^Saved!`0`n"); } if ($id) { $op="edit"; } else { $op = ""; } httpset("op", $op); } if ($op==""){ $sql = "SELECT count(acctid) AS c, hashorse FROM ".db_prefix("accounts")." GROUP BY hashorse"; $result = db_query($sql); $mounts = array(); while ($row = db_fetch_assoc($result)){ $mounts[$row['hashorse']] = $row['c']; } rawoutput(""); $sql = "SELECT * FROM " . db_prefix("mounts") . " ORDER BY mountcategory, mountcostgems, mountcostgold"; $ops = translate_inline("Ops"); $name = translate_inline("Name"); $cost = translate_inline("Cost"); $feat = translate_inline("Features"); $owners = translate_inline("Owners"); $edit = translate_inline("Edit"); $give = translate_inline("Give"); $del = translate_inline("Del"); $deac = translate_inline("Deactivate"); $act = translate_inline("Activate"); $conf = translate_inline("There are %s user(s) who own this mount, are you sure you wish to delete it?"); rawoutput(""); rawoutput(""); $result = db_query($sql); $cat = ""; $count=0; $number=db_num_rows($result); for ($i=0;$i<$number;$i++){ $row = db_fetch_assoc($result); if ($cat!=$row['mountcategory']){ rawoutput(""); $cat = $row['mountcategory']; $count=0; } if (isset($mounts[$row['mountid']])) { $mounts[$row['mountid']] = (int)$mounts[$row['mountid']]; } else { $mounts[$row['mountid']] = 0; } rawoutput(""); rawoutput(""); addnav("","mounts.php?op=deactivate&id={$row['mountid']}"); }else{ rawoutput("$act ]"); addnav("","mounts.php?op=activate&id={$row['mountid']}"); } rawoutput(""); $count++; } rawoutput("
$ops$name$cost$feat$owners
"); output("Category: %s", $row['mountcategory']); rawoutput("
[ $edit |"); addnav("","mounts.php?op=edit&id={$row['mountid']}"); rawoutput("$give |",true); addnav("","mounts.php?op=give&id={$row['mountid']}"); if ($row['mountactive']){ rawoutput("$del |"); }else{ $mconf = sprintf($conf, $mounts[$row['mountid']]); rawoutput("$del |"); addnav("","mounts.php?op=del&id={$row['mountid']}"); } if ($row['mountactive']) { rawoutput("$deac ]"); output_notl("`&%s`0", $row['mountname']); rawoutput(""); output("`%%s gems`0, `^%s gold`0",$row['mountcostgems'], $row['mountcostgold']); rawoutput(""); $features = array("FF"=>$row['mountforestfights']); $args = array("id"=>$row['mountid'],"features"=>&$features); $args = modulehook("mountfeatures", $args); reset($features); $mcount = 1; $max = count($features); foreach ($features as $fname=>$fval) { $fname = translate_inline($fname); output_notl("%s: %s%s", $fname, $fval, ($mcount==$max?"":", ")); $mcount++; } rawoutput(""); $file = "mounts.php?op=xml&id=".$row['mountid']; rawoutput(""); rawoutput("
"); output("`nIf you wish to delete a mount, you have to deactivate it first."); output("If there are any owners of the mount when it is deleted, they will no longer have a mount, but they will get a FULL refund of the price of the mount at the time of deletion."); }elseif ($op=="add"){ output("Add a mount:`n"); addnav("Mount Editor Home","mounts.php"); mountform(array()); }elseif ($op=="edit"){ addnav("Mount Editor Home","mounts.php"); $sql = "SELECT * FROM " . db_prefix("mounts") . " WHERE mountid='$id'"; $result = db_query_cached($sql, "mountdata-$id", 3600); if (db_num_rows($result)<=0){ output("`iThis mount was not found.`i"); }else{ addnav("Mount properties", "mounts.php?op=edit&id=$id"); module_editor_navs("prefs-mounts", "mounts.php?op=edit&subop=module&id=$id&module="); $subop=httpget("subop"); if ($subop=="module") { $module = httpget("module"); rawoutput("
"); module_objpref_edit("mounts", $module, $id); rawoutput("
"); addnav("", "mounts.php?op=save&subop=module&id=$id&module=$module"); } else { output("Mount Editor:`n"); $row = db_fetch_assoc($result); $row['mountbuff']=unserialize($row['mountbuff']); mountform($row); } } } function mountform($mount){ // Let's sanitize the data if (!isset($mount['mountname'])) $mount['mountname'] = ""; if (!isset($mount['mountid'])) $mount['mountid'] = ""; if (!isset($mount['mountdesc'])) $mount['mountdesc'] = ""; if (!isset($mount['mountcategory'])) $mount['mountcategory'] = ""; if (!isset($mount['mountlocation'])) $mount['mountlocation'] = 'all'; if (!isset($mount['mountdkcost'])) $mount['mountdkcost'] = 0; if (!isset($mount['mountcostgems'])) $mount['mountcostgems'] = 0; if (!isset($mount['mountcostgold'])) $mount['mountcostgold'] = 0; if (!isset($mount['mountfeedcost'])) $mount['mountfeedcost'] = 0; if (!isset($mount['mountforestfights'])) $mount['mountforestfights'] = 0; if (!isset($mount['newday'])) $mount['newday'] = ""; if (!isset($mount['recharge'])) $mount['recharge'] = ""; if (!isset($mount['partrecharge'])) $mount['partrecharge'] = ""; if (!isset($mount['mountbuff'])) $mount['mountbuff'] = array(); if (!isset($mount['mountactive'])) $mount['mountactive']=0; if (!isset($mount['mountbuff']['name'])) $mount['mountbuff']['name'] = ""; if (!isset($mount['mountbuff']['roundmsg'])) $mount['mountbuff']['roundmsg'] = ""; if (!isset($mount['mountbuff']['wearoff'])) $mount['mountbuff']['wearoff'] = ""; if (!isset($mount['mountbuff']['effectmsg'])) $mount['mountbuff']['effectmsg'] = ""; if (!isset($mount['mountbuff']['effectnodmgmsg'])) $mount['mountbuff']['effectnodmgmsg'] = ""; if (!isset($mount['mountbuff']['effectfailmsg'])) $mount['mountbuff']['effectfailmsg'] = ""; if (!isset($mount['mountbuff']['rounds'])) $mount['mountbuff']['rounds'] = 0; if (!isset($mount['mountbuff']['atkmod'])) $mount['mountbuff']['atkmod'] = ""; if (!isset($mount['mountbuff']['defmod'])) $mount['mountbuff']['defmod'] = ""; if (!isset($mount['mountbuff']['invulnerable'])) $mount['mountbuff']['invulnerable'] = ""; if (!isset($mount['mountbuff']['regen'])) $mount['mountbuff']['regen'] = ""; if (!isset($mount['mountbuff']['minioncount'])) $mount['mountbuff']['minioncount'] = ""; if (!isset($mount['mountbuff']['minbadguydamage'])) $mount['mountbuff']['minbadguydamage'] = ""; if (!isset($mount['mountbuff']['maxbadguydamage'])) $mount['mountbuff']['maxbadguydamage'] = ""; if (!isset($mount['mountbuff']['mingoodguydamage'])) $mount['mountbuff']['mingoodguydamage'] = ""; if (!isset($mount['mountbuff']['maxgoodguydamage'])) $mount['mountbuff']['maxgoodguydamage'] = ""; if (!isset($mount['mountbuff']['lifetap'])) $mount['mountbuff']['lifetap'] = ""; if (!isset($mount['mountbuff']['damageshield'])) $mount['mountbuff']['damageshield'] = ""; if (!isset($mount['mountbuff']['badguydmgmod'])) $mount['mountbuff']['badguydmgmod'] = ""; if (!isset($mount['mountbuff']['badguyatkmod'])) $mount['mountbuff']['badguyatkmod'] = ""; if (!isset($mount['mountbuff']['badguydefmod'])) $mount['mountbuff']['badguydefmod'] = ""; rawoutput("
"); rawoutput(""); addnav("","mounts.php?op=save&id={$mount['mountid']}"); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput(""); rawoutput("
"); output("Mount Name:"); rawoutput("
"); output("Mount Description:"); rawoutput("
"); output("Mount Category:"); rawoutput("
"); output("Mount Availability:"); rawoutput(""); // Run a modulehook to find out where stables are located. By default // they are located in 'Degolburg' (ie, getgamesetting('villagename')); // Some later module can remove them however. $vname = getsetting('villagename', LOCATION_FIELDS); $locs = array($vname => sprintf_translate("The Village of %s", $vname)); $locs = modulehook("stablelocs", $locs); $locs['all'] = translate_inline("Everywhere"); ksort($locs); reset($locs); rawoutput("
"); output("Mount Cost (DKs):"); rawoutput("
"); output("Mount Cost (Gems):"); rawoutput("
"); output("Mount Cost (Gold):"); rawoutput("
"); output("Mount Feed Cost`n(Gold per level):"); rawoutput("
"); output("Delta Forest Fights:"); rawoutput("
"); output("`bMount Messages:`b"); rawoutput("
"); output("New Day:"); rawoutput("
"); output("Full Recharge:"); rawoutput("
"); output("Partial Recharge:"); rawoutput("
"); output("Mount Buff:"); rawoutput(""); output("Buff name:"); rawoutput("
"); output("`bBuff Messages:`b`n"); output("Each round:"); rawoutput("
"); output("Wear off:"); rawoutput("
"); output("Effect:"); rawoutput("
"); output("Effect No Damage:"); rawoutput("
"); output("Effect Fail:"); rawoutput("
"); output("(message replacements: {badguy}, {goodguy}, {weapon}, {armor}, {creatureweapon}, and where applicable {damage}.)`n"); output("`n`bEffects:`b`n"); output("Rounds to last (from new day):"); rawoutput("
"); output("Player Atk mod:"); rawoutput(""); output("(multiplier)`n"); output("Player Def mod:"); rawoutput(""); output("(multiplier)`n"); output("Player is invulnerable (1 = yes, 0 = no):"); rawoutput("
"); output("Regen:"); rawoutput("
"); output("Minion Count:"); rawoutput("
"); output("Min Badguy Damage:"); rawoutput("
"); output("Max Badguy Damage:"); rawoutput("
"); output("Min Goodguy Damage:"); rawoutput("
"); output("Max Goodguy Damage:"); rawoutput("
"); output("Lifetap:"); rawoutput(""); output("(multiplier)`n"); output("Damage shield:"); rawoutput(""); output("(multiplier)`n"); output("Badguy Damage mod:"); rawoutput(""); output("(multiplier)`n"); output("Badguy Atk mod:"); rawoutput(""); output("(multiplier)`n"); output("Badguy Def mod:"); rawoutput(""); output("(multiplier)`n"); output("`bOn Dynamic Buffs`b`n"); output("`@In the above, for most fields, you can choose to enter valid PHP code, substituting for fields in the user's account table.`n"); output("Examples of code you might enter:`n"); output("`^`n"); output("round(/10)`n"); output("round(/max(,1))`n"); output("`@Fields you might be interested in for this: `n"); output_notl("`3name, sex `7(0=male 1=female)`3, specialty `7(DA=darkarts MP=mystical TS=thief)`3,`n"); output_notl("experience, gold, weapon `7(name)`3, armor `7(name)`3, level,`n"); output_notl("defense, attack, alive, goldinbank,`n"); output_notl("spirits `7(-2 to +2 or -6 for resurrection)`3, hitpoints, maxhitpoints, gems,`n"); output_notl("weaponvalue `7(gold value)`3, armorvalue `7(gold value)`3, turns, title, weapondmg, armordef,`n"); output_notl("age `7(days since last DK)`3, charm, playerfights, dragonkills, resurrections `7(times died since last DK)`3,`n"); output_notl("soulpoints, gravefights, deathpower `7(%s favor)`3,`n", getsetting("deathoverlord", '`$Ramius')); output_notl("race, dragonage, bestdragonage`n`n"); output("You can also use module preferences by using (for instance '' or ''`n`n"); output("`@Finally, starting a field with 'debug:' will enable debug output for that field to help you locate errors in your implementation."); output("While testing new buffs, you should be sure to debug fields before you release them on the world, as the PHP script will otherwise throw errors to the user if you have any, and this can break the site at various spots (as in places that redirects should happen)."); rawoutput("
"); $save = translate_inline("Save"); rawoutput("
"); } page_footer(); ?>