bonus_script by cydh

Angelmelody

(\ /) ( . .)
Messages
772
Points
0
Age
32
Location
new_1-1,53,111
Github
Angelmelody
Emulator
This script command is from rathena  created by cydh ,I convert it to herc

*bonus_script "<script code>",<duration>{,<flag>{,<type>{,<status_icon>{,<char_id>}}}};This command will attach a script to a player for a given duration, in seconds.After that time, the script will automatically expire. The same bonus cannot bestacked. By default, this bonus will be stored on `bonus_script` table when playerlogs out.Note that the maximum number of 'bonus_script' commands that can run simultaneouslyfor a player is 20 (MAX_PC_BONUS_SCRIPT in 'src/common/mmo.h').Flags: (Default is 0) &1: Remove when dead. &2: Removable by Dispell. &4: Removable by Clearance. &8: Remove when player logs out.Types: This will be used to decide negative or positive buff for 'debuff_on_logout'. 0: Ignore the buff type and won't be removed if the flag is not &8 (Default) 1: Buff 2: DebuffStatus_icon: See "Status Icon" section in 'db/const.txt'. Default is SI_BLANK (-1).Example: // Apple gives you +5 Str bonus for 1 minute when it's consumed. 512,Apple,Apple,0,15,,20,,,,,0xFFFFFFFF,63,2,,,,,,{ bonus_script "{ bonus bStr,5; }",60; },{},{} 


download: bonus script.patch

Code:
---- Table structure for table `bonus_script`--CREATE TABLE IF NOT EXISTS `bonus_script` (  `char_id` varchar(11) NOT NULL,  `script` varchar(1024) NOT NULL,  `tick` varchar(11) NOT NULL DEFAULT '0',  `flag` varchar(3) NOT NULL DEFAULT '0',  `type` char(1) NOT NULL DEFAULT '0',  `icon` varchar(3) NOT NULL DEFAULT '-1') ENGINE=InnoDB;
 

Attachments

Last edited by a moderator:
Nice,

why not make PR*Pull Request) of this?

 
This script command is from rathena  created by cydh ,I convert it to herc

*bonus_script "<script code>",<duration>{,<flag>{,<type>{,<status_icon>{,<char_id>}}}};This command will attach a script to a player for a given duration, in seconds.After that time, the script will automatically expire. The same bonus cannot bestacked
do it accept -1 for infinite duration?

 
Last edited by a moderator:
I used this quite a lot when I was still on rathena forum

but one thing that bugs me is ...

*bonus_script "<script code>",<duration>{,<flag>{,<type>{,<status_icon>{,<char_id>}}}};

This command will attach a script to a player for a given duration, in seconds.

After that time, the script will automatically expire. The same bonus cannot be

stacked. By default, this bonus will be stored on `bonus_script` table when player

logs out.
let's say I finished a quest, and I get a bonus bstr, 10;then I went into an event, which gives another bonus bstr,10;

it doesn't stack

that part needs to be revise a little bit

@evilpuncker

seems no

dur = 1000 * abs(script_getnum(st,3));
http://www.cprogramming.com/fod/abs.html
I tried on rathena test server

prontera,162,180,5 script asdf 100,{ bonus_script "{ bonus bStr,5; }",-1; end;}I get bonus +5 str for 1 second

the one who made this release should be fixing this
 
Zratinel said:
i have a problem on this part .. can you help me please.. 

2d6kz8g.jpg
Why don't you ignore the part status_calc_pc(sd, SCO_NONE);

 
Zratinel said:
i have a problem on this part .. can you help me please.. 

2d6kz8g.jpg
pc.c inside  pc_setoption function

Code:
pc.c@@ -8091,6 +8091,13 @@ int pc_setoption(struct map_session_data *sd,int type) 		clif->sc_end(&sd->bl,sd->bl.id,AREA,SI_WUGRIDER); 		status_calc_pc(sd,SCO_NONE); 	}+	+	if( (sd->class_&MAPID_THIRDMASK) == MAPID_MECHANIC ) {+		if( type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR) )+			pc->bonus_script_clear(sd,BONUS_FLAG_REM_ON_MADOGEAR); // cydh bonus_script+		else if( !(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR )+			pc->bonus_script_clear(sd,BONUS_FLAG_REM_ON_MADOGEAR); // cydh bonus_script+	}  	if( (type&OPTION_MADOGEAR && !(p_type&OPTION_MADOGEAR)) 	|| (!(type&OPTION_MADOGEAR) && p_type&OPTION_MADOGEAR) ) {
 
This script command is from rathena  created by cydh ,I convert it to herc

*bonus_script "<script code>",<duration>{,<flag>{,<type>{,<status_icon>{,<char_id>}}}};This command will attach a script to a player for a given duration, in seconds.After that time, the script will automatically expire. The same bonus cannot bestacked
do it accept -1 for infinite duration?
 temporary patch for infinite duration when duration set to -1

infinite duration.patch

 

Attachments

got warning with gcc on centos

Code:
pc.c: In function 'pc_bonus_script_clear':pc.c:10858: warning: suggest parentheses around && within ||char.c: In function 'bonus_script_save':char.c:5070: warning: format '%d' expects type 'int', but argument 5 has type 'uint64'char.c:5076: warning: too many arguments for format
 
got warning with gcc on centos

pc.c: In function 'pc_bonus_script_clear':pc.c:10858: warning: suggest parentheses around && within ||char.c: In function 'bonus_script_save':char.c:5070: warning: format '%d' expects type 'int', but argument 5 has type 'uint64'char.c:5076: warning: too many arguments for format
 windows dont have that warning,but I can try to fix

for 1st warning

pc.c in pc_bonus_script_clear function 

find

if (&sd->bonus_script && sd->bonus_script.script && (sd->bonus_script.flag&flag || //Remove bonus script based on e_bonus_script_flags (sd->bonus_script.type && (flag&BONUS_FLAG_REM_BUFF && sd->bonus_script.type == 1) || //Remove bonus script based on buff type (flag&BONUS_FLAG_REM_DEBUFF && sd->bonus_script.type == 2)))) //Remove bonus script based on debuff typereplace with
Code:
		if(&sd->bonus_script[i] && sd->bonus_script[i].script && 			(sd->bonus_script[i].flag&flag || //Remove bonus script based on e_bonus_script_flags				(sd->bonus_script[i].type && 					((flag&BONUS_FLAG_REM_BUFF && sd->bonus_script[i].type == 1) || //Remove bonus script based on buff type					 (flag&BONUS_FLAG_REM_DEBUFF && sd->bonus_script[i].type == 2) //Remove bonus script based on debuff type					)				)			)		  )
for another warningCan you post line 5070 and 5076 in your char.c ?

 
Last edited by a moderator:
5070 : StrBuf->Printf(&buf,"('%d','%s','%d','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);5076 : ShowInfo("Saved %d bonus_script for char_id: %dn",count,cid,bs.icon);
char.c.diff

 
5070 : StrBuf->Printf(&buf,"('%d','%s','%d','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);5076 : ShowInfo("Saved %d bonus_script for char_id: %dn",count,cid,bs.icon);
char.c.diff
findStrBuf->Printf(&buf,"('%d','%s','%d','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);

change to

StrBuf->Printf(&buf,"('%d','%s','%u','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);

find

ShowInfo("Saved %d bonus_script for char_id: %dn",count,cid,bs.icon);

change to

ShowInfo("Saved %d bonus_script for char_id: %dn",count,cid);

 
char.c: In function 'bonus_script_save':char.c:5070: warning: format '%u' expects type 'unsigned int', but argument 5 has type 'uint64'
changed uint64 tick; to unsigned int tick; in mmo.h removed the warning (is it right? about compatible compiler, source here) but what the difference '%u' and '%d' ?

 
Last edited by a moderator:
char.c: In function 'bonus_script_save':char.c:5070: warning: format '%u' expects type 'unsigned int', but argument 5 has type 'uint64'
changed uint64 tick; to unsigned int tick; in mmo.h removed the warning (is it right? about compatible compiler, source here) but what the difference '%u' and '%d' ?
WRONG WAY..(by chantging uint64 to unsigned int, you are lowering the limit of that variable, which can cause undesirable effects.)instead change that

%u

To

%" PRIu64 "

p.s: the priu64 should be outside the quotes, and not inside the quotes.

%d - int, supporting 2.14bil

%u - unsigned int, supporting 0-4.xx bil

Uint64 - supproting till billions of billions (correct this one, if I am wrong
default_tongue.png
)

 
Last edited by a moderator:
WRONG WAY..(by chantging uint64 to unsigned int, you are lowering the limit of that variable, which can cause undesirable effects.)

instead change that

%u

To

%" PRIu64 "

p.s: the priu64 should be outside the quotes, and not inside the quotes.

%d - int, supporting 2.14bil

%u - unsigned int, supporting 0-4.xx bil

Uint64 - supproting till billions of billions (correct this one, if I am wrong
default_tongue.png
)
i have change it back to uint64 tick; and change the code like this and warning not appear

StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type)
i use %llu since the format used same by %d or %s and it says the same for %" PRIu64 ", and the "p.s: the priu64 should be outside the quotes, and not inside the quotes",im not sure how to write it into the code..

 
WRONG WAY..(by chantging uint64 to unsigned int, you are lowering the limit of that variable, which can cause undesirable effects.)

instead change that

%u

To

%" PRIu64 "

p.s: the priu64 should be outside the quotes, and not inside the quotes.

%d - int, supporting 2.14bil

%u - unsigned int, supporting 0-4.xx bil

Uint64 - supproting till billions of billions (correct this one, if I am wrong
default_tongue.png
)
 i have change it back to uint64 tick; and change the code like this and warning not appear

StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type)
i use %llu since the format used same by %d or %s and it says the same for %" PRIu64 ", and the "p.s: the priu64 should be outside the quotes, and not inside the quotes",im not sure how to write it into the code..
try this ? (I merge bs.icon into one line)

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);

 
Last edited by a moderator:
try this ? (I merge bs.icon into one line)

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
Then i have to replace 2 line right ?

Find :

StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);StrBuf->Printf(&buf, "'%d')", bs.icon);
Into :

Code:
StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
 
Last edited by a moderator:
try this ? (I merge bs.icon into one line)

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
Then i have to replace 2 line right ?

Find :

StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);StrBuf->Printf(&buf, "'%d')", bs.icon);
Into :

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
humhum,  I think its no need to divide into two lines

ouch!..forgot to say, PRId64(for thoese who already patched #8) and PRIu64 (for those who dosnt patched #8) 

 
Last edited by a moderator:
try this ? (I merge bs.icon into one line)

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
Then i have to replace 2 line right ?

Find :

StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type);StrBuf->Printf(&buf, "'%d')", bs.icon);
Into :

StrBuf->Printf(&buf,"('%d','%s','%"PRId64"','%"PRIu8"','%d','%d')",cid,esc_script,bs.tick,bs.flag,bs.type,bs.icon);
humhum,  I think its no need to divide into two lines

ouch!..forgot to say, PRId64(for thoese who already patched #8) and PRIu64 (for those who dosnt patched #8) 
will you update the first post with issues fixed? =D

 
Back
Top