Because of this, I started to delve into some parts I was avoiding. Like parties and guilds, what role they play and how they work.
Forgive the lack of comments, I'll probably go through and add them in later; but I am about to hop off here for the day and just wanted to be able to check in on people's thoughts/opinions. I was also going to opt for making the party system with a datum, not sure why I went with obj here.
/obj/Party/
var
openJoining=0
maxMembers=10
var/list/
Members=new()
proc/
AddMember(mob/M)
if(src.Members.len>=src.maxMembers){ return FALSE }
src.Members<<"[M] has joined the party!"
src.Members.Add(M)
M.Party=src
return TRUE
Invite(mob/Character/M)
switch(input(M,"You have been invited to join [src.Members[1]]'s party, do you accept?","Party Invite")in list("Join","Decline"))
if("Join")
if(M.Party.Members.len)
switch(input(M,"You're currently in [M.Party.Members[1]]'s party,\n\
are you sure you want to join [src.Members[1]]'s party?","Join Party")in list("For sure!","No, thanks."))
if("For Sure!")
if(src.Members.len>=src.maxMembers)
M<<"Party is full! Sorry."
return FALSE
if(M.Party.Members[1]==M&&M.Party.Members.len>1)
var/mob/Character/m2=M.Party.Members[2]
M.Party.Members<<"[M] has left the party, [m2]'s taken command!"
M.Party.Members.Remove(m2)
M.Party.Members.Insert(1,m2)
M.TakePartyLeader()
m2.MakePartyLeader()
M.Party.Members.Remove(M)
src.AddMember(M)
if("No, thanks.")
return FALSE
else
src.AddMember(M)
if("Decline")
return FALSE
/mob/Character/
verb
StartParty()
src.Party.AddMember(src)
src.verbs+=typesof(/mob/Character/PartyLeader/verb/)
PartyLeader
verb
Party_Invite()
var/list/l=new()
for(var/mob/m in Players-src)
if((m.partyinvite)&&(m.Party!=src.Party))
l+=m
if(l.len)src.Party.Invite(input(src,"Please, select someone to invite to your party.","Party Invite")as mob in l)
ChangeOpenJoin()
set name = "Open/Close Party"
src.Party.openJoining=!src.Party.openJoining
switch(src.Party.openJoining)
if(1)
for(var/mob/m in src.Party.Members)
viewers(m)<<"[m]'s party, lead by [src], is now openly accepting members!"
m.verbs+=/mob/Character/OpenParty/verb/Join_Party
if(0)
for(var/mob/m in src.Party.Members)
viewers(m)<<"[m]'s party, lead by [src], is no longer openly accepting members!"
m.verbs-=/mob/Character/OpenParty/verb/Join_Party
ChangePartyLeader()
set name = "Transfer Party Leader"
if(src.Party.Members.len>1)
var/mob/Character/m = input(src,"Select whom you would like to make your party leader.","Transfer Leadership")as mob in src.Party.Members-src
src.Party.Members.Remove(m)
src.Party.Members.Insert(1,m)
src.TakePartyLeader()
m.MakePartyLeader()
OpenParty
verb
Join_Party()
set src in oview()
if(!src.Party.AddMember(usr))
usr<<"You were unable to join [src]'s party."
proc
MakePartyLeader()
src.verbs+=typesof(/mob/Character/PartyLeader/verb/)
TakePartyLeader()
src.verbs-=typesof(/mob/Character/PartyLeader/verb/)
I decided I wanted Parties to divide exp/gold evenly; this is what I came up with:
mob
Character
var/obj/Party/Party=new()
proc
//Leveling
GainExp(var/N as num)
if(N)
if(src.Party.Members.len>1) N=max(1,round(N/src.Party.Members.len))
for(var/mob/m in src.Party.Members) if(m!=src) m.GainExp(N)
src<<"You have gained [N]xp."
for(var/g in src.JoinedGuilds)
var/obj/Guild/G = Guilds[g]
if(G.name==g)
var/taken=round(max(1,N*(G.exp_tax/100)))
G.exp+=taken
N=max(1,N-taken)
src<<"Your guild, [g], has a [G.exp_tax]%xp tax, taking [taken]xp and leaving you [N]xp."
G.Level_Up()
src.exp+=N
if(src.exp<src.expmax) return
var/lvls=0
while(src.exp>=src.expmax)
lvls+=1
src.exp-=src.expmax
src.Level_Up(lvls)
GainGold(var/N as num, var/Preferance="Cash")
if(!N)return
switch(Preferance)
if("Cash")
if(src.Party.Members.len>1) N=max(1,round(N/src.Party.Members.len))
for(var/mob/m in src.Party.Members) if(m!=src) m.GainGold(N)
src<<"You have gained [N]g."
for(var/g in src.JoinedGuilds)
var/obj/Guild/G = Guilds[g]
if(G.name==g)
var/taken=round(max(1,N*(G.gold_tax/100)))
G.gold+=taken
N=max(1,N-taken)
src<<"Your guild, [g], has a [G.gold_tax]%g tax, taking [taken]g and leaving you [N]g."
src.gold+=N
if("Banked")
src.banked_gold+=N
SpendGold(var/Amount as num, var/Preferance="Player's Choice" as text)
switch(Preferance)
if("Cash")
if(Amount>gold+banked_gold)
src<<"You can't afford this! You need at least [Amount]!"
return FALSE
if(gold>=Amount)
gold-=Amount
else
gold-=Amount
Amount-=gold
gold=0
banked_gold-=Amount
if("Cash Only")
if(Amount>gold)
src<<"You can't afford this! You need to be holding at least [Amount]!"
return FALSE
gold-=Amount
if("Banked")
if(Amount>gold+banked_gold)
src<<"You can't afford this! You need at least [Amount]!"
return FALSE
if(banked_gold>=Amount)
banked_gold-=Amount
else
banked_gold-=Amount
Amount-=banked_gold
banked_gold=0
gold-=Amount
if("Banked Only")
if(Amount>banked_gold)
src<<"You can't afford this! You need to have at least [Amount] stored!"
return FALSE
banked_gold-=Amount
if("Player's Choice")
return src.SpendGold(Amount,src.paymentpreferance)
return TRUE
Any suggestions/thoughts? Tweaks/modifications? Do you believe this is the correct way to implement a 'Party' system into a RPG?