ID:268118
 
I am trying to figure something out. I have a game. There are a group of four people, and they are on a quest. After the four of them defeat a monster, I want those 4 to get a health boost. How would I do that?

Sounds difficult to me.

Non-PC
You might try using the mob.group var, then just cycling through the list and adding health to each mob in the group.

<code>for(var/mob/M in leader.group) M.health++</code>

How you determine who's in what group is up to you.
In response to Foomer
Foomer wrote:
You might try using the mob.group var, then just cycling through the list and adding health to each mob in the group.

<code>for(var/mob/M in leader.group) > M.health++</code>

How you determine who's in what group is up to you.

How's this?

var/leader.group

Entered(mob/M)
if(entered_people == 4)
usr << "You cannot enter, theres already a group in there!"
return
else
if(entered_people == 3)
usr.loc = locate(1,8,4)
entered_people += 1
usr << "You must press start."
view(10) << "Everyone, press the start verb to begin."
usr.verbs += /mob/game/verb/Start
leader.group += usr
else
usr.loc = locate(1,8,4)
usr.verbs += /mob/game/verb/Start
entered_people += 1
leader.group += usr

In response to Non-PC
No put usr in Entered(). Ungh.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
No put usr in Entered(). Ungh.

Lummox JR

Well, besides that, is there anything wrong?

And thanks for pointing that out, Lummox.

Non-PC
In response to Non-PC
That's not quite how you'd do this. /mob/var/group is already defined anyways. Alright, here we go:
mob/verb
join() // verb to join a mob's group
set src in view() // make sure this mob is within the usr's view
src.group.Add(usr) // add the usr to that mob's group
disband()
for(var/mob/M in src.group) // for every mob in the src's group
src.group.Remove(M) // remove it from this group


Something like that is more what you want to get people in and out of a group. Keep in mind those are extremely primitive, and you'd probably want safeguards to check who is allowed to join who's group, and max group sizes and whatnot.