Got this running OK, and applied a bunch of the fixes and extras from this thread (man, there were a LOT of them). I've applied:
- Equation fixes
- Trade option
- Restrict access to overpopulated nations
- Usergroup (subscriber) specific nation
- a few more
I've also slightly edited a lot of the templates to look - at least in my opinion - a bit better, plus a crapload of phrases and/or text.
Kinda working on fudging a couple of new simple options (by literally copying code - I can't write it myself):
- Hire mercenaries (troops for gold)
- Dismiss troops (to free up some gold)
I've managed those, as I just used the code already in place for recruiting troops and just changed the numbers:
USE AT OWN RISK -THIS IS WHAT I'VE DONE SO FAR AND I DOESN'T WORK YET! IN FACT, IT GIVES A BLANK WHITE PAGE WHEN NEW USERS ATTEMPT TO ACCESS THE SYSTEM. WORKING ON IT STILL, BUT DON'T USE THIS CODE.
With that dire disclaimer out of the way, here's how I did it. You'll need to change the red numbers to whatever you prefer. If you wanna see it in action first, I have it
running on my forum, but you'll obviously need to register and create a village before you can view the new options in Village Overview.
ADD TO FUNCTIONS_CONQUEST_HOMEBASE.PHP
Quote:
function hire_mercenary($player)
{
global $vbulletin, $settings, $passcolor, $failcolor;
if ($player[pTurns] < 5)
{
return '<font color="'.$failcolor.'">You can not hire mercenaries as you do not have enough actions available</font>';
}
elseif ($player[pGold] < 10)
{
return '<font color="'.$failcolor.'">You can not hire mercenaries as you do not have enough resources available</font>';
}
$newTurnCount = $player[pTurns] - 5;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pTurns = '".$newTurnCount."' WHERE playerID = ".$player[playerID]."");
$totalGain = ceil($player[pTroops] * ($settings[gRecruitRatio]/50));
$newTroopCount = $player[pTroops] + $totalGain;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pTroops = '".$newTroopCount."' WHERE playerID = ".$player[playerID]."");
$newGoldCount = $player[pGold] -10;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pGold = '".$newGoldCount."' WHERE playerID = ".$player[playerID]."");
return '<font color="'.$passcolor.'">Your recruiters have returned and '.$totalGain.' mercenaries have joined your military ranks</font>';
}
function fire_troop($player)
{
global $vbulletin, $settings, $passcolor, $failcolor;
if ($player[pTroops] < 1)
{
return '<font color="'.$failcolor.'">You do not have any troops to dismiss</font>';
}
elseif ($player[pTurns] < 1)
{
return '<font color="'.$failcolor.'">You can not dismiss troops as you do not have enough actions available</font>';
}
$newTurnCount = $player[pTurns] - 1;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pTurns = '".$newTurnCount."' WHERE playerID = ".$player[playerID]."");
$newTroopCount = $player[pTroops] -1;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pTroops = '".$newTroopCount."' WHERE playerID = ".$player[playerID]."");
$newGoldCount = $player[pGold] +1;
$vbulletin->db->query_write("UPDATE IGNORE ".TABLE_PREFIX."conquest_players SET pGold = '".$newGoldCount."' WHERE playerID = ".$player[playerID]."");
return '<font color="'.$passcolor.'">You have successfully dismissed a soldier and gained 1 resources</font>';
}
|
ADD TO CONQUEST.PHP:
Quote:
// ################################################## ######################
// IS USER RECRUITING MERCENARIES?
if ($vbulletin->input->clean_gpc('p', 'hiremerc', TYPE_STR))
{
$noticeTEXT = hire_mercenary($player);
$player = fetch_player($vbulletin->userinfo[userid]);
}
// ################################################## ######################
// IS USER DISMISSING TROOPS?
if ($vbulletin->input->clean_gpc('p', 'firetroop', TYPE_STR))
{
$noticeTEXT = fire_troop($player);
$player = fetch_player($vbulletin->userinfo[userid]);
}
|
ADD TO TEMPLATE CONQUEST_HOMEBASE:
Quote:
<tr>
<td class="thead" align="center">Hire Mercenaries<br><small>Mercenaries cost 10 resources and 5 actions each</small></td>
</tr>
<tr>
<td class="alt1" align="center"><form action="$filename?do=homebase" method="post">
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="hiremerc" value="true" />
<input type="submit" value="Hire Mercenaries">
</form></td>
</tr>
<tr>
<td class="thead" align="center">Dismiss Troops<br><small>Dismissing troops costs 1 action, and frees up 1 resources</small></td>
</tr>
<tr>
<td class="alt1" align="center"><form action="$filename?do=homebase" method="post">
<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />
<input type="hidden" name="firetroop" value="true" />
<input type="submit" value="Dismiss Troops">
</form></td>
</tr>
|
Things I want to do, but can't because it requires actually writing something (as opposed to copying and pasting some code and changing some numbers):
- Village names
- Couple of extra mission types for spies (which I've renamed "adventurers")
- Marketplace which sells special items
- vBCredits II integration (to spend in that marketplace)
- Leave game option
- Change allegiance option
None of that can I even begin to do, unfortunately, but I think that's what would turn this into a decent but basic game into a really good one.