So. Here's my issue. First of all I'm still fairly new to lists and I'm learning datums as I create this.
I'm creating a party system. A brief summary of the current party system is:
-You can click create party and input a name
-It will check if that name is already taken
-You can click join party then click on a player. You will join their party if they're in one
-You can view all current parties along with their party members
There's so much more I need to do for this before I'm done.
So anyways. My current issue is that I'm trying to display small health/mana bars around the player and all their party members. But only you and your party can see your own bars. Nobody else.
So I'm thinking client.image is the only way to accomplish this. Which I'm also new to. I think I'm calling the image properly but it doesn't display. I think it has to do with how poorly I have this party system setup. So I'd like some help optimizing this and then doing this health/mana bar part.
Finally, on to my actual code. I'd like to apologize beforehand for the level of noobyness you're going to encounter here. Don't cringe too badly.
I came up with this after reading a few posts on datums and looking at a couple examples of a party system.
Also, mob/HUMANS/PC is for player characters. In case my naming is odd.
Code:
mob/HUMANS/PC/var/PARTY/PT = new
var
list
ALL_PARTIES_LIST = list()
mob
var
PARTY_DATUM //This variable holds the current persons party
tmp/PARTY_INPUT_OPEN = 0 //This is used to check if you have a party command open already. If so, don't let them use any other commands
tmp/JOINING_PARTY = 0 //This is used to check if you're currently joining a party or not.
mob
New()
PARTY_HEALTH_BAR_IMAGE = image("GLOBAL/GUI/HUD/PARTY_HEALTH_BAR.dmi", src)
..()
PARTY
New()
..()
ALL_PARTIES_LIST += src
Del()
ALL_PARTIES_LIST -= src
var/tmp
PARTY_NAME //Party's name
list
MEMBERS = new/list()
DEPUTIES = new/list()
mob/PARTY_LEADER
SHARE_RANGE = 20
proc
CREATE_PARTY(ENTERED_NAME, mob/creator)
if(PARTY_NAME != null)
world << "[PARTY_NAME]"
return
if(usr.PARTY_INPUT_OPEN == 1)
return
usr.PARTY_INPUT_OPEN = 1
PARTY_LEADER = creator
ENTERED_NAME = input("Enter Party Name", "Name", ENTERED_NAME)
for(var/PARTY/P in ALL_PARTIES_LIST)
if(ckey(P.PARTY_NAME) == ckey(ENTERED_NAME))
PARTY_LEADER << "Your party, [ENTERED_NAME] could not be created. It already exists."
PARTY_LEADER = null
del src
PARTY_NAME = ENTERED_NAME
MEMBERS += PARTY_LEADER
PARTY_LEADER.PARTY_DATUM = src
PARTY_LEADER << "You are now the leader of [ENTERED_NAME]!"
usr.PARTY_INPUT_OPEN = 0
JOIN_PARTY()
usr.JOINING_PARTY = 1
usr << "Click a player to join their party"
JOIN_PARTY_SUCCESSFUL(var/PARTY_I_WANT_TO_JOIN)
world << "src:[src] usr: [usr.GMOB_CHARACTER_NAME] Joined [PARTY_I_WANT_TO_JOIN:PT.PARTY_NAME]"
PARTY_I_WANT_TO_JOIN:PT.MEMBERS += usr //Adds the usr to the party of the person they clicked on
for(var/X in PARTY_I_WANT_TO_JOIN:PT.MEMBERS)
world << "1 member. Add health"
X:UPDATE_HEALTH_MANA_PARTY_BARS_DISPLAY()
SHOW_ALL_PARTIES()
usr << "Currently active parties:"
for(var/X in ALL_PARTIES_LIST)
if(X:PARTY_NAME != null)
usr << "[X:PARTY_NAME]"
for(var/Z in X:MEMBERS)
usr << " [Z:GMOB_CHARACTER_NAME]"
UPDATE_HEALTH_MANA_PARTY_BARS_DISPLAY()
usr << "Health bar should show up..."
usr.client.images += usr.PARTY_HEALTH_BAR_IMAGE //Display the health bar on the usr's client
mob
HUMANS
PC
Click()
if(usr.JOINING_PARTY == 1)
usr << "Join this guys party [src]"
usr.JOINING_PARTY = 0
if(src.PT.PARTY_NAME != null)
world << "They're in [src.PT.PARTY_NAME]"
PT.JOIN_PARTY_SUCCESSFUL(src)
else
..()
The only way I know how to call these procs is by using
mob/HUMANS/PC
verb
CREATE_PLAYER_PARTY()
PT.CREATE_PARTY(GMOB_CHARACTER_NAME, src)
The less ambiguous your code, the better. I also seem to recall the lookup operator being slower than the alternative (someone feel free to correct me).
You are responsible for taking care of the images per client and making sure they get cleaned up.