From b78616340e2421bc9c53f6ceabdc26acd369c94f Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 31 Aug 2019 17:50:20 -0300 Subject: This is the basic for political system to work on HURNSCALD (alpha) --- db/constants.conf | 1 + npc/012-7/_import.txt | 1 + npc/012-7/politics.txt | 52 ++++++++++++++++++++++++++++++++++++++++++++ npc/functions/politics.txt | 54 ++++++++++++++++++++++++++++++++++++++++++++++ npc/functions/util.txt | 6 ++++++ 5 files changed, 114 insertions(+) create mode 100644 npc/012-7/politics.txt diff --git a/db/constants.conf b/db/constants.conf index c90f94094..164148f7d 100644 --- a/db/constants.conf +++ b/db/constants.conf @@ -4159,6 +4159,7 @@ constants_db: { NPC_MONSTERKING: 500 NPC_AIRSHIP: 501 + NPC_POLITICS: 502 NPC_SOUL_NORMAL: 700 NPC_SOUL_DESERT: 701 diff --git a/npc/012-7/_import.txt b/npc/012-7/_import.txt index e02dd58c7..d0177ddd3 100644 --- a/npc/012-7/_import.txt +++ b/npc/012-7/_import.txt @@ -3,3 +3,4 @@ "npc/012-7/_warps.txt", "npc/012-7/airlia.txt", "npc/012-7/celestia.txt", +"npc/012-7/politics.txt", diff --git a/npc/012-7/politics.txt b/npc/012-7/politics.txt new file mode 100644 index 000000000..3c97546dd --- /dev/null +++ b/npc/012-7/politics.txt @@ -0,0 +1,52 @@ +// TMW2 Scripts +// Author: +// Jesusalva +// Description: +// Town Administrator file, see npc/functions/politics.txt +// User variables: +// #POL_APPLYWEEK = Week of last application +// #POL_VOTEDAY = Day of last vote + +012-7,51,60,0 script Hurnscald Office NPC_POLITICS,{ +do +{ + mesc ".:: "+l("Hurnscald Townhall")+" ::.", 2; + mesc l("Current Town Administrator: ")+$HURNS_MAYOR$, 3; + mesc l("Application fee: @@ GP", .applytax); + next; + select + l("Information"), + rif(#POL_APPLYWEEK != gettimeparam(GETTIME_WEEKDAY), l("Apply for the office!")), + l("View Candidate List and cast a vote"), + l("[Quit]"); + + switch (@menu) { + case 1: + POL_Information(); + break; + case 2: + // array_push might be too sensible for getd/setd + if (Zeny < .applytax) + break; + Zeny-=.applytax; + $HURNS_MONEY+=.applytax; + #POL_APPLYWEEK=gettimeparam(GETTIME_WEEKDAY); + array_push($HURNS_CANDIDATE$, strcharinfo(0)); + array_push($HURNS_VOTES, 0); + mesc l("Application successful!"), 3; + break; + case 3: + POL_Candidate("HURNS"); + break; + default: + close; + } +} while (True); +end; + +OnInit: + .applytax=50; + .distance=4; + end; +} + diff --git a/npc/functions/politics.txt b/npc/functions/politics.txt index b4ddde37d..64884ca46 100644 --- a/npc/functions/politics.txt +++ b/npc/functions/politics.txt @@ -138,6 +138,60 @@ OnSun0000: rodex_sendmail(gf_charnameid($FROSTIA_MAYOR$), "Frostia Townhall", "Election Victory", "You've been elected to the office!"); end; +} +///////////////////////// + + +// Dialog helpers +// General info +// POL_Information( ) +function script POL_Information { + + mesc l("Weekly, at Sunday 00:00, elections are held."); + mesc l("The current town administrator will be re-elected if there are no candidates."); + mesc l("Town Administrator can use the town money for investments, and also receive a salary depending on how well the town is."); + next; + mesc l("A player may be the town admin of several different towns."); + mesc l("However, an account may only apply for an office weekly."); + mesc l("The account with highest votes will win. Ties will be solved by date of application."); + mesc l("An account may vote anywhere, but only once every day."); + next; + return; +} + +// Candidate Info and voting +// POL_Candidate( TOWNCODE ) +function script POL_Candidate { + copyarray( .@cd$, getd("$"+getarg(0)+"_CANDIDATE$"), getarraysize(getd("$"+getarg(0)+"_CANDIDATE$")) ); + copyarray( .@vt, getd("$"+getarg(0)+"_VOTES"), getarraysize(getd("$"+getarg(0)+"_VOTES")) ); + .@list="Don't vote"; + for (.@i=0;.@i