summaryrefslogblamecommitdiff
path: root/npc/functions/politics.txt
blob: 5b40ac53b3342d752c001a4227729ce2cac764b1 (plain) (tree)
1
2
3
4
5
6
7
8






                                                                                 
                                  













                                                                             



                                                 





















                                                                                        
          
                    





                                                                           
































                                                                                                                                        




                                             
 




























                                                 








                                                                                                                                 



        
// TMW2 Script
// Author:
//    Jesusalva
// Description:
//    Central Town Political System Controller
//    Note: The office is NOT Mayor, we have from kings to mayors here and you're
//    not a citzen (yet). It'll be... I'll think in a name better than Minister.
//    Perhaps, Town Administrator.
// NPCs:
//    Tulim - 
//    Halin - 
//    Hurns - Airlia
//    LoF - 
//    Nival - 
//    Frostia - 
// Variables:
//      $LOC_MAYOR$ - Stores the name of current Hurnscald Mayor
//      $LOC_MONEY - Total money reserves of Hurnscald
//      $LOC_TAX - How much in % is charged as taxes. (OnBuy income)
//      $LOC_EXPORT - Defines how much Hurnscald exports (weekly income)
//      $LOC_REPUTATION - Town reputation. Affects Max Tax and Weekly Income;
// Note: Tax cannot exceed 10% ie 1000. Reputation must be between 0 and 100.
//
//  "Temporary Arrays":
//      $LOC_CANDIDATE$ - Candidate for Office
//      $LOC_VOTES - Number of votes of Candidate

// Proccess Taxes from purchases
// PurchaseTaxes( Location )
function	script	PurchaseTaxes	{
    .@tax=0;
    for (.@i=0; .@i < getarraysize(@bought_nameid); .@i++) {
        // Note: Some NPC might not 
        .@price=getiteminfo(@bought_nameid[.@i], ITEMINFO_BUYPRICE);
        .@tax+=.@price*@bought_quantity[.@i];
    }
    .@loc$=strtoupper(getarg(0, LOCATION$));
    .@vat=getd("$"+.@loc$+"_TAX");
    .@tax=.@tax*.@vat/10000;
    if (.@tax) {
        debugmes "%s paid %d in taxes to %s prefecture!", strcharinfo(0), .@tax, .@loc$;
        setd("$"+.@loc$+"_TAX", .@vat+.@tax);
    }
    return;
}

-	script	Politics	NPC_HIDDEN,{

OnSun0000:
    // Weekly income
    $TULIM_MONEY+=$TULIM_EXPORT*limit(0, $TULIM_REPUTATION, 100)/100;
    $HALIN_MONEY+=$HALIN_EXPORT*limit(0, $HALIN_REPUTATION, 100)/100;
    $HURNS_MONEY+=$HURNS_EXPORT*limit(0, $HURNS_REPUTATION, 100)/100;
    $LOF_MONEY+=$LOF_EXPORT*limit(0, $LOF_REPUTATION, 100)/100;
    $NIVAL_MONEY+=$NIVAL_EXPORT*limit(0, $NIVAL_REPUTATION, 100)/100;
    $FROSTIA_MONEY+=$FROSTIA_EXPORT*limit(0, $FROSTIA_REPUTATION, 100)/100;

    // Send salary to Town Administrators (20% from exports and 5GP/reputation)
    .@tax=$TULIM_EXPORT*limit(0, $TULIM_REPUTATION, 100)/500;
    .@tax+=$TULIM_REPUTATION*5;
    .@tax=min($TULIM_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($TULIM_MAYOR$), "Tulimshar Townhall", "Term Income", "You've received the money for the term.", .@tax);

    .@tax=$HALIN_EXPORT*limit(0, $HALIN_REPUTATION, 100)/500;
    .@tax+=$HALIN_REPUTATION*5;
    .@tax=min($HALIN_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($HALIN_MAYOR$), "Halinarzo Townhall", "Term Income", "You've received the money for the term.", .@tax);

    .@tax=$HURNS_EXPORT*limit(0, $HURNS_REPUTATION, 100)/500;
    .@tax+=$HURNS_REPUTATION*5;
    .@tax=min($HURNS_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($HURNS_MAYOR$), "Hurnscald Townhall", "Term Income", "You've received the money for the term.", .@tax);

    .@tax=$LOF_EXPORT*limit(0, $LOF_REPUTATION, 100)/500;
    .@tax+=$LOF_REPUTATION*5;
    .@tax=min($LOF_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($LOF_MAYOR$), "LoF Townhall", "Term Income", "You've received the money for the term.", .@tax);

    .@tax=$NIVAL_EXPORT*limit(0, $NIVAL_REPUTATION, 100)/500;
    .@tax+=$NIVAL_REPUTATION*5;
    .@tax=min($NIVAL_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($NIVAL_MAYOR$), "Nivalis Townhall", "Term Income", "You've received the money for the term.", .@tax);

    .@tax=$FROSTIA_EXPORT*limit(0, $FROSTIA_REPUTATION, 100)/500;
    .@tax+=$FROSTIA_REPUTATION*5;
    .@tax=min($FROSTIA_MONEY, .@tax);
    rodex_sendmail(gf_charnameid($FROSTIA_MAYOR$), "Frostia Townhall", "Term Income", "You've received the money for the term.", .@tax);

    // Conduct elections
    .@w=array_highest($TULIM_VOTES);
    if ($TULIM_CANDIDATE$[.@w] != "")
        $TULIM_MAYOR$=$TULIM_CANDIDATE$[.@w];
    deletearray($TULIM_CANDIDATE$);
    deletearray($TULIM_VOTES);

    .@w=array_highest($HALIN_VOTES);
    if ($HALIN_CANDIDATE$[.@w] != "")
        $HALIN_MAYOR$=$HALIN_CANDIDATE$[.@w];
    deletearray($HALIN_CANDIDATE$);
    deletearray($HALIN_VOTES);

    .@w=array_highest($HURNS_VOTES);
    if ($HURNS_CANDIDATE$[.@w] != "")
        $HURNS_MAYOR$=$HURNS_CANDIDATE$[.@w];
    deletearray($HURNS_CANDIDATE$);
    deletearray($HURNS_VOTES);

    .@w=array_highest($LOF_VOTES);
    if ($LOF_CANDIDATE$[.@w] != "")
        $LOF_MAYOR$=$LOF_CANDIDATE$[.@w];
    deletearray($LOF_CANDIDATE$);
    deletearray($LOF_VOTES);

    .@w=array_highest($NIVAL_VOTES);
    if ($NIVAL_CANDIDATE$[.@w] != "")
        $NIVAL_MAYOR$=$NIVAL_CANDIDATE$[.@w];
    deletearray($NIVAL_CANDIDATE$);
    deletearray($NIVAL_VOTES);

    .@w=array_highest($FROSTIA_VOTES);
    if ($FROSTIA_CANDIDATE$[.@w] != "")
        $FROSTIA_MAYOR$=$FROSTIA_CANDIDATE$[.@w];
    deletearray($FROSTIA_CANDIDATE$);
    deletearray($FROSTIA_VOTES);

    // Notify new mayors of their victory
    rodex_sendmail(gf_charnameid($TULIM_MAYOR$), "Tulimshar Townhall", "Election Victory", "You've been elected to the office!");
    rodex_sendmail(gf_charnameid($HALIN_MAYOR$), "Halinarzo Townhall", "Election Victory", "You've been elected to the office!");
    rodex_sendmail(gf_charnameid($HURNS_MAYOR$), "Hurnscald Townhall", "Election Victory", "You've been elected to the office!");
    rodex_sendmail(gf_charnameid($LOF_MAYOR$), "LoF Townhall", "Election Victory", "You've been elected to the office!");
    rodex_sendmail(gf_charnameid($NIVAL_MAYOR$), "Nivalis Townhall", "Election Victory", "You've been elected to the office!");
    rodex_sendmail(gf_charnameid($FROSTIA_MAYOR$), "Frostia Townhall", "Election Victory", "You've been elected to the office!");

    end;

}