ID:1282027
 
(See the best response by Pirion.)
Code:
mob
proc
GiveReward(mob/died)
exp += died.expgive
Credit += died.Creditgive
src.expgain()
src.goldgain()
if(died.specie == "Sand Cat")
if(prob(10))
new/Item/equippable/Body/clothes/shirt(src.loc)
new/Item/equippable/weapons/crudesword(src.loc)
view() << output("<font color = Yellow>Drop:</font>[died.specie] dropped a Crude Sword","system")
expgain(expgive as num)
if(!partycheck(src,expgive))
exp += expgive
levelup()
goldgain(Creditgive as num)
if(!partycheck(src,null,Creditgive))
Credit += Creditgive


Problem description:
Im using a demo from byond resources, Party System by DivineTraveller, and i can see hes not answering any questions, so i thought i would try my luck here.

The problem with the code is that when a mob is killed it dont pass on the exp for the party members, but only the killer.
in my deathproc i have my GiveReward() so i thought i would only show that here with the relevant code. I have been staring on this code, and have been trying back and fourth whith all i could come up with, for i dont know how long.

The game dont give me any runtime errors, but nothing happends when its time to pass on the exp to the party members, anyone got an idea on how to fix this? PS. Everything else in the GiveReward() works like its supposed to, I.e the shirt and weapon dropping.
By the way. Yes i have tried searching on the forum, but i did not find a answer that would fit in this given situation.

Thanks in advance!
~Sleaze
src.expgain() does not pass an argument, so it defaults to zero? Same with goldgain. Also, you would be giving your killer exp and gold twice (Under GiveReward and expgain/goldgain).
mob
proc
GiveReward(mob/died)
src.giveEXP(died.expgive) // trigger the killer's exp gain as well as the party's
src.giveGold(died.Creditgive) // same for gold, credit, whatever...

// related code goes here...

giveEXP(value)
if(src.party) // does src have an active party? if so...
for(var/mob/M in src.party & hearers(10, src) - src) spawn // grant exp gain for anyone within range AND in src's party...
M.exp += value
M.levelup()
src.exp += value // then move on to giving src his or her exp
src.levelup()

giveGold(value)
if(src.party)
for(var/mob/M in src.party & hearers(10, src) - src) spawn
M.Credit += value
src.Credit += value
Well thanks for giving me the answers, but can you tell me what you did and why a little more indept? Because i really want to improve and learn. :)
I just tested it ingame, and when ever i kill a mob, i now get teleported to 1,1,1 LOL
Well, nothing in my example code modifies your location, so it's not that.

What I suggested was basically just to make a function "giveEXP()" that handled experience gain, and in that function is where party member gains are also handled. If src has an active party "if(src.party)" it proceeds to grant the same experience gain to any party member within a 10-tile range of src "hearers(10, src)". Anyone who is farther away won't receive anything (that's there so that, say, I wouldn't be able to just join a party and sit somewhere afk, leveling up and stuff). giveGold() does the same thing.

Post the rest of the relevant code for killing/death and I can help you with your teleporting issue.
In death, M probably refers to the killer?

You call M.Respawn() after giving rewards.
I'm not seeing anything significant in those snippets. It has to be something else.

Ever considered debugging? You just place some output commands around the relevant code areas just to see where it gets and what it does when they are executed.

Also, if you were implying my code is what caused the teleportation, then I'd like to see your levelup() function.
No, Pirion was right, i changed the respawn in the death() and now it dont teleport anymore :) But the exp is not passed on, but when i used your code FKI, it said undefined variable party, and in the party system i found, it creates parties as a datum, can that have a say in the matter?

EDIT: the killer does infact get exp.
You'd change 'party' in my code to 'partydatum'. Also, I think partydatum should be a list. O_o How else are you going to store multiple mobs in the same group? o_o (Assuming you aren't making it a list somewhere else.)
Best response
Use what you used before Sleaze.

All the range, and the checking, etc. is handled in the partycheck call, so if your using that system, don't change these.

The only issue you had is as I said above:

src.expgain()/src.goldgain() does not pass an argument, so it defaults to zero.

Edit2:
Seen another - You shouldn't be dropping items in GiveReward. It should be called in Death and overwritten for each mob that drops different things.

mob
proc
GiveReward(mob/died)
src.expgain(died.expgive)
src.goldgain(died.Creditgive)
if(died.specie == "Sand Cat")
if(prob(10))
new/Item/equippable/Body/clothes/shirt(src.loc)
new/Item/equippable/weapons/crudesword(src.loc)
view() << output("<font color = Yellow>Drop:</font>[died.specie] dropped a Crude Sword","system")
expgain(expgive as num)
if(!partycheck(src,expgive))
exp += expgive
levelup()
goldgain(Creditgive as num)
if(!partycheck(src,null,Creditgive))
Credit += Creditgive



Edit: FKI - check out his reference and you would know! In this case a datum is much better than a list attached to mob. The list is attached to the datum.

DivineTraveller Party System.

http://www.byond.com/developer/DivineTraveller/ PartySystem?tab=index
Ah, I see. :p
Omg! it worked Pirion! Im so happy! thanks mate! I did not even realize i was so close to the goal xD
While i got you Pirion, do you know what i have to check for if i want to tell if a player is in a party or not?

Like if i want a player to be in a party inorder to walk into a dungeon? is that partydatum?
As said earlier, partydatum has a list attached to it. For a party to really be a party, there are four conditions.

1 - There is a partydatum present.
2 - partydatum is of type /party.
3 - Inside partydatum, there is a members present.
4 - The members is a list. If there is more than one person, we have a party going on.

mob/proc/IsInParty()
if(partydatum && istype(partydatum,/party) && partydatum.members && partydatum.members.len > 1)
return 1
return 0


Edit: Found another condition.
alright! Thanks alot mate! You have no idea what this means to me! I was so close to start crying before getting help from you guys xD
How would i call drops in the death proc instead og give reward?
By using inheritance.
This same concept can be defined to mob too, so you define one logic on player and another on monster.

mob
proc
Death(mob/M)
if(src.hp <= 0)
if(src.client)
{
...
}
else
M.GiveReward(src)
src.DropItems()
//call the defined drop items. This does nothing
//unless we overwrite the other.
proc
DropItems() //define so we can overwite it

mob
SandCat
DropItems() //This is just for SandCats. :)
if(prob(10))
new/Item/equippable/Body/clothes/shirt(src.loc)
new/Item/equippable/weapons/crudesword(src.loc)
view() << output("<font color = Yellow>Drop:</font>[died.specie] dropped a Crude Sword","system")

ReallyBigUglyMonster
DropItems() //eww...drops goo.
new/obj/goo/green(src.loc)

alright thanks mate!