Thread: Major Additions - Realm Conquest System
View Single Post
  #569  
Old 04-25-2011, 05:18 PM
Morrus Morrus is offline
 
Join Date: Jan 2002
Posts: 494
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01323 seconds
  • Memory Usage 1,802KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_quote
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete