I think this is complete....
rename spellshop.php to battleshop.php (or whatever you want)
remove the sell logic:
if ($_GET[action]=="sell"){ // Zauberladen (written on a cassiopeia while taking a bath)
if (isset($_GET[id])){
$sql="SELECT * FROM items WHERE id=$_GET[id]";
$result=db_query($sql);
$row = db_fetch_assoc($result);
output("`2$shopowner takes $row[name]`2 and gives you ".($row[gold]?"`^$row[gold] `2gold":"")." ".($row[gems]?"`#$row[gems]`2 gems":"").". ");
addnav("Sell more","spellshop.php?action=sell");
$sql="DELETE FROM items WHERE id=$_GET[id]";
$session[user][gold]+=$row[gold];
$session[user][gems]+=$row[gems];
db_query($sql);
}else{
$sql="SELECT * FROM items WHERE owner=".$session[user][acctid]." AND (gold>0 OR gems>0) AND class='Spell' ORDER BY name ASC";
$result=db_query($sql);
if (db_num_rows($result)){
output("`2 You show $shopowner your spells and he tells you what he's willing to pay.`n`n");
output("<table border='0' cellpadding='1' cellspacing='3'>",true);
output("<tr class='trhead'><td>`bName`b</td><td>`bPreis`b</td></tr>",true);
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$bgcolor=($i%2==1?"trlight":"trdark");
output("<tr class='$bgcolor'><td><a href='spellshop.php?action=sell&id=$row[id]'>$row[name]</a></td><td align='right'>`^$row[gold]`0 Gold, `#$row[gems]`0 Edelsteine</td></tr><tr class='$bgcolor'><td colspan='2'>$row[description]</td></tr>",true);
addnav("","spellshop.php?action=sell&id=$row[id]");
}
output("</table>",true);
} else {
output("`2You don't have any interesting spells.");
}
}
addnav("To Shop","spellshop.php");
change:
}else if ($_GET[action]=="buy"){ // ok, water's getting cold ^^
to:
if ($_GET[action]=="buy"){ // ok, water's getting cold ^^
in the buy logic, change:
if ($session[user][gems]<$row[gems] || $session[user][gold]<$row[gold]){
to:
if ($session[user][battlepoints]<$row[gold]){
also change:
}else if (db_num_rows(db_query("SELECT id FROM items WHERE name='$row[name]' AND owner=".$session[user][acctid]." AND class='Spell'"))>0){
to:
}else if (db_num_rows(db_query("SELECT id FROM items WHERE name='$row[name]' AND owner=".$session[user][acctid]." AND class='BattleItem'"))>0){
change:
output("`2You point on \"`3$row[name]`2\". $shopowner gives it to you and you hand him ".($row[gold]?"`^$row[gold] `2gold":"")." ".($row[gems]?"`#$row[gems]`2 gems":"")." over. ");
to:
output("`2You point to\"`3$row[name]`2\". $shopowner gives it to you and you lose ".($row[gold]?"`^$row[gold] `2battle points":""));
change:
$sql="INSERT INTO items(name,class,owner,value1,value2,hvalue,gold,gems,description,buff) VALUES ('$row[name]','Spell',".$session[user][acctid].",$row[value1],$row[value2],$row[hvalue],$row[gold],$row[gems],'".addslashes($row[description])."','".addslashes($row[buff])."')";
to:
$sql="INSERT INTO items(name,class,owner,value1,value2,hvalue,gold,gems,description,buff) VALUES ('$row[name]','BattleItem',".$session[user][acctid].",$row[value1],$row[value2],$row[hvalue],$row[gold],$row[gems],'".addslashes($row[description])."','".addslashes($row[buff])."')";
change:
$session[user][gold]-=$row[gold];
$session[user][gems]-=$row[gems];
to:
$session[user][battlepoints]-=$row[gold];
change:
output("`2What do you want?`n`n");
to:
output("`2What do you want?`n`n");
output("`3You have ".$session[user][battlepoints]." battlepoints you can spend!`n`n");
change:
$sql="SELECT * FROM items WHERE (owner=0 AND class='Spell') OR class='Spell.Prot' AND gold<=".$session[user][gold]." AND gems<=".$session[user][gems]." ORDER BY class,name ASC LIMIT $limit";
to:
$sql="SELECT * FROM items WHERE (owner=0 AND class='BattleItem') OR class='Batt.Prot' AND gold<=".$session[user][battlepoints]." ORDER BY class,name ASC LIMIT $limit";
change:
output("<tr class='$bgcolor'><td><a href='spellshop.php?action=buy&id=$row[id]'>$row[name]</a></td><td align='right'>`^$row[gold]`0 Gold, `#$row[gems]`0 Edelsteine</td></tr><tr class='$bgcolor'><td colspan='2'>$row[description]</td></tr>",true);
to:
output("<tr class='$bgcolor'><td><a href='battleshop.php?action=buy&id=$row[id]'>$row[name]</a></td><td align='right'>`^$row[gold]`0 Battle Points</td></tr><tr class='$bgcolor'><td colspan='2'>$row[description]</td></tr>",true);
change:
output("`2\"`3We don't have any spells for you that you can afford`2\"");
to:
output("`2\"`3You don't have enough battle points to get any items!`2\"");
Remove:
addnav("Sell spell","spellshop.php?action=sell");
Change:
all references to spellshop.php
to:
battleshop.php (or whatever you called it)
In common.php, right after:
// spells by anpera
$sql="SELECT * FROM items WHERE (class='Spell') AND owner=".$session[user][acctid]." AND value1>0 ORDER BY class,name ASC";
$result=db_query($sql) or die(db_error(LINK));
if (db_num_rows($result)>0) addnav("Spells & Moves");
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$spellbuff=unserialize($row[buff]);
addnav("`2$spellbuff[name] `0(".$row[value1]."x)","$script?op=fight&skill=zauber&itemid=$row[id]");
}
// end spells
add:
// Battle Items
$sql="SELECT * FROM items WHERE (class='BattleItem') AND owner=".$session[user][acctid]." AND value1>0 ORDER BY class,name ASC";
$result=db_query($sql) or die(db_error(LINK));
if (db_num_rows($result)>0) addnav("Battle Items");
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
$spellbuff=unserialize($row[buff]);
addnav("`2$spellbuff[name] `0(".$row[value1]."x)","$script?op=fight&skill=zauber&itemid=$row[id]");
}
// end Battle Items
If you want the players to lose their battle items on a DK, then in dragon.php, somewhere around the DK part, you'll need to add:
$sql = "DELETE FROM items WHERE owner=".$session[user][acctid]." AND class='BattleItem'";
db_query($sql) or die(db_error(LINK));
in newday.php, after:
$session['user']['bounties']=0;
add:
// Handle buffs from Battle items
$sql="SELECT * FROM items WHERE (class='BattleItem' OR class='Move') AND owner=".$session[user][acctid]." ORDER BY id";
$result=db_query($sql);
for ($i=0;$i<db_num_rows($result);$i++){
$row = db_fetch_assoc($result);
if ($row[hvalue]>0){
$row[hvalue]--;
if ($row[hvalue]<=0 && $row['class']=="BattleItem"){
db_query("DELETE FROM items WHERE id=$row[id]");
output("`n`2$row[name]`2 has turned to dust and crumbled.`n");
}else{
$what="hvalue=$row[hvalue]";
if ($row['class']=='BattleItem') $what.=", value1=$row[value2]";
db_query("UPDATE items SET $what WHERE id=$row[id]");
}
}
}
I added a link in my pvparena.php as "Spend Battle Points". You can put it wherever.
You can use the Item editor from spellshop, just make your prototypes in class Batt.Prot
Put the number of battlepoints it costs in the Item Cost (Gold) spot. Item Cost (Gems) is not used. Everything else works like Anpera's Spells.
Again, this was originally posted to merely give ideas, not for me to post the actual changes I made.
I think I have listed everything here, I didn't actually keep track of the changes I made because I didn't think I would be posting them. But if I did miss something, I'm sure you get the jist, and thanks again to Anpera and LonnyL for sweet mods!