• 0
Sign in to follow this  
Vettra

Item party bonus

Question

It is possible a certain item give a bonus by the number of members at the party?

Example:

 

+1 STR for each party member(Hat item)

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Something like this I guess?

-	script	bonus_party	-1,{

OnPCStatCalcEvent:

	[email protected]_id = 1201;
	[email protected] = getcharid(1);
	if(isequipped([email protected]_id) && [email protected]) {
		getpartymember [email protected],1,[email protected]_cid;
		getpartymember [email protected],2,[email protected]_aid;
		[email protected] = [email protected];
		for(;[email protected] < [email protected];[email protected]++)
			[email protected]+= isloggedin([email protected]_aid[[email protected]],[email protected]_cid[[email protected]]);
		bonus bStr,[email protected];
	}
	end;
}

 

  • Love 1

Share this post


Link to post
Share on other sites
  • 0
On 12/13/2018 at 2:16 AM, n0tttt said:

Something like this I guess?

-	script	bonus_party	-1,{

OnPCStatCalcEvent:

	[email protected]_id = 1201;
	[email protected] = getcharid(1);
	if(isequipped([email protected]_id) && [email protected]) {
		getpartymember [email protected],1,[email protected]_cid;
		getpartymember [email protected],2,[email protected]_aid;
		[email protected] = [email protected];
		for(;[email protected] < [email protected];[email protected]++)
			[email protected]+= isloggedin([email protected]_aid[[email protected]],[email protected]_cid[[email protected]]);
		bonus bStr,[email protected];
	}
	end;
}

 

How about instead of giving a bonus from the Player who wear that Item, if the wearer has that item everyone on that party will give bonuses too.

e.g Allstats + 1 everyone on that party will have the bonus Allstats + 1 too. Possible? (A Player who has the item must be the Party Leader or else the bonus won't work)

Edited by Azeroth

Share this post


Link to post
Share on other sites
  • 0
-	script	bonus_party	-1,{

OnPCStatCalcEvent:

	[email protected]_id = 1201;
	[email protected] = getcharid(1);
	[email protected] = getcharid(3);
	if(isequipped([email protected]_id) && [email protected]) {
		[email protected]_leader = is_party_leader();
		getpartymember [email protected],1,[email protected]_cid;
		getpartymember [email protected],2,[email protected]_aid;
		[email protected] = [email protected];
		for(;[email protected] < [email protected];[email protected]++) {
			if(isloggedin([email protected]_aid[[email protected]],[email protected]_cid[[email protected]])) {
				[email protected]++;
				if([email protected]_leader)
					if(attachrid([email protected]_aid[[email protected]]))
						bonus bStr,1;
			}
		}
		attachrid [email protected];	
		bonus bStr,[email protected];
	}
	end;
}

 

Share this post


Link to post
Share on other sites
  • 0

@n0tttt

I've tried your script, but my test server throws error on me ...

[Error]:  Loading NPC file: npc/zzz.txt
script error on npc/zzz.txt line 8
    script:add_word: invalid word. A word consists of undercores and/or alphanum
eric characters, and valid variable prefixes/postfixes.
     3 : OnPCStatCalcEvent:
     4 :        [email protected]_id = 2301;
     5 :        [email protected] = getcharid(1);
     6 :        [email protected] = getcharid(3);
     7 :        if(isequipped([email protected]_id) && [email protected]) {
*    8 :                [email protected]_leader = is_party_leader(')';
     9 :                getpartymember [email protected],1,[email protected]_cid;
    10 :                getpartymember [email protected],2,[email protected]_aid;
    11 :                [email protected] = [email protected];
    12 :                for(;[email protected] < [email protected];[email protected]++) {
    13 :                        if(isloggedin([email protected]_aid[[email protected]],[email protected]_cid[[email protected]])
) {

@Azeroth

I don't think your idea is possible, both methods doesn't work

-	script	sfdfkjshf	-1,{
OnInit:
	setitemscript 2301, "{"+
		"[email protected] = getcharid(1);"+
		"if ( [email protected] ) end;"+
		"if ( getpartyleader( [email protected], 2 ) != getcharid(0) ) end;"+
		"getpartymember [email protected], 1;"+
		"getpartymember [email protected], 2;"+
		"for ( [email protected] = 0; [email protected] < [email protected]; [email protected] ) {"+
		"	if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {"+
		"		attachrid [email protected][[email protected]];"+
		"		bonus bStr, 1;"+ // doesn't give other members
		"		dispbottom 1;"+
		"	}"+
		"}"+
	"}";
}
-	script	sfdfkjshf	-1,{
OnPCStatCalcEvent:
	if ( !isequipped(2301) ) end;
	[email protected] = getcharid(1);
	if ( [email protected] ) end;
	if ( getpartyleader( [email protected], 2 ) != getcharid(0) ) end;
	getpartymember [email protected], 1;
	getpartymember [email protected], 2;
	for ( [email protected] = 0; [email protected] < [email protected]; [email protected] ) {
		if ( isloggedin( [email protected][[email protected]], [email protected][[email protected]] ) ) {
			attachrid [email protected][[email protected]];
			bonus bAllstats, 1;
		//	recalculatestat();
			dispbottom 1;
		}
	}
	end;
}

the dispbottom part shows for the other party member, but the stats aren't updated
probably due to the fact the part where bonus us calculated, namely status_calc_pc function are badly coded
it was coded in the way only gives to the user, not for others

even *recalculatestat script command doesn't work

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

It's a recent command: https://github.com/rathena/rathena/commit/78edf851a00d61dbf3a6668c6f21f1dd1cbb6c45

Thank you for testing my script. It's a shame the two methods you tested didn't work.

The only way I can think now is by using sc_start, but it would overlap with other buffs...

-	script	bonus_party	-1,{

OnPCStatCalcEvent:

	[email protected]_id = 1201;
	[email protected] = getcharid(1);
	[email protected] = getcharid(3);
	if(isequipped([email protected]_id) && [email protected]) {
		[email protected]_leader = is_party_leader();
		getpartymember [email protected],1,[email protected]_cid;
		getpartymember [email protected],2,[email protected]_aid;
		[email protected] = [email protected];
		for(;[email protected] < [email protected];[email protected]++) {
			if(isloggedin([email protected]_aid[[email protected]],[email protected]_cid[[email protected]])) {
				[email protected]++;
				if([email protected]_leader && [email protected]_aid[[email protected]] != [email protected]) {
					if(attachrid([email protected]_aid[[email protected]])) {
						[email protected] = getstatus(SC_INCALLSTATUS,5);
						if([email protected] <= 10000) {
							sc_start SC_INCALLSTATUS,60000,max(1,getstatus(SC_INCALLSTATUS,1) + [email protected]_bonus);
							if([email protected])
								@party_bonus = true;
						}
					}
				}

			}
		}
		attachrid [email protected];
		//sc_start SC_INCSTR,60000,[email protected];
		bonus bStr,[email protected];
	}
	end;
}

Edit: just did a little change (idk if it works) in case the player already had that buff, the script will sum +1 to avoid overwriting. Hope it works (can't test, I don't have a test server).

Edited by n0tttt

Share this post


Link to post
Share on other sites
  • 0
Posted (edited)

in my opinion

I think there is to much going on in "OnPCStatCalcEvent"

 

this how I would do it

-	script	item_party_buff	-1,{

OnPCStatCalcEvent:
	if(getvar(@ITEMPARTYBUFF,getpartyleader(getcharid(1),2))){
		bonus bAllstats, 1;
	}
	end;
}

1201,Knife,Knife,5,50,,400,17,,1,3,0x3E9F7EEF,63,2,2,1,1,1,1,{},{ @ITEMPARTYBUFF = true; },{ @ITEMPARTYBUFF = false; }

 

ofc it's not perfect , the party members won't get the bonus before they hit the event(this event happen a lot but it might be a problem for some to not get the bonus immediately)

 

so if it's for my server , I won't do it and think of other ways , or maybe looking to the src to do it

 

Edited by sader1992
  • Love 1

Share this post


Link to post
Share on other sites
  • 0

@sader1992 Thanks for the base script Sader.
Hopefully, someone could make a little src for this 😄 That would be appreciated.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this