Jump to content


Photo

bonus_script by cydh


  • Please log in to reply
28 replies to this topic

#1 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 03 August 2014 - 04:01 PM

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: Attached File  bonus script.patch   48.38K   109 downloads
 
 
---- 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;

Edited by Angelmelody, 22 August 2014 - 07:07 PM.

Spoiler


#2 Dastgir

Dastgir

    Advanced Member

  • Script Developers
  • 3345 posts
  • IRC Nickname:Dastgir
  • Emulator:Hercules
  • Github:dastgir

Posted 03 August 2014 - 04:16 PM

Nice,

why not make PR*Pull Request) of this?


My Services: Click Here
Clientside Translation: Click HERE
Contact Via Discord: @Dastgir#1460


#3 Quazi

Quazi

    Advanced Member

  • Members
  • PipPipPip
  • 190 posts
  • Emulator:Hercules
  • Github:Miracle

Posted 03 September 2014 - 07:51 PM

i have a problem on this part .. can you help me please.. 
Posted Image



#4 evilpuncker

evilpuncker

    The Suggester

  • Community Contributors
  • 2122 posts
  • Locationbr br hue hue

Posted 03 September 2014 - 08:29 PM

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?


Edited by evilpuncker, 03 September 2014 - 08:30 PM.

before asking for help, click here

some people that I admire:

Ai4rei (tools and client stuff) • Aeomin (the awesome thor patcher) • AnnieRuru (very helpful with script and source stuff)

Neo (N.E.M.O... do I need to say more?) • KeyWord (roBrowser <3) • k3dt (clients and clients) • Tokeiburu (awesome tools)

Dastgir (lua stuff) • Yommy • Ind • Haru • malufett

 

:ok:    and everyone that contributed in any way to the *Athena community in general (emulator, releases, support etc)  :no1: 


#5 AnnieRuru

AnnieRuru

    ~~Cute~Cute~Scripter~~

  • Former Scripting Moderator
  • 1138 posts
  • Locationyour next door ~
  • Emulator:Hercules
  • Github:AnnieRuru

Posted 03 September 2014 - 09:06 PM

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.cprogramm...om/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

Spoiler

~ Posted Image ~ It's time for Battleground and Events Scripts Festival Again ~ Posted Image ~

#6 Frost

Frost

    The Master of White Spaces

  • Script Developers
  • 633 posts
  • LocationPhilippines
  • Emulator:Hercules
  • Github:Jedzkie

Posted 03 September 2014 - 09:24 PM

i have a problem on this part .. can you help me please.. 
Posted Image

 

Why don't you ignore the part [b]status_calc_pc(sd, SCO_NONE);


Posted Image


Don't forget to click Posted Image if i helped you!

#7 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 04 September 2014 - 08:40 AM

i have a problem on this part .. can you help me please.. 
Posted Image

 

pc.c inside  pc_setoption function

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) ) {

Spoiler


#8 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 04 September 2014 - 06:39 PM

 

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

 

Attached File  infinite duration.patch   3.39K   48 downloads


Spoiler


#9 Quazi

Quazi

    Advanced Member

  • Members
  • PipPipPip
  • 190 posts
  • Emulator:Hercules
  • Github:Miracle

Posted 04 September 2014 - 11:04 PM

thank you very much Angelmelody :) it works 



#10 Litro

Litro

    Advanced Member

  • Members
  • PipPipPip
  • 365 posts
  • LocationProntera
  • Emulator:Hercules
  • Github:Litro

Posted 08 September 2014 - 02:44 AM

[font="'courier new', courier, monospace;"]got warning with gcc on centos [/font]

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

:thx:For being you, For all of you :thx: 

 

:wub: ~ Certified Fans of AnnieRuru ~ :wub:

 


#11 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 08 September 2014 - 04:27 PM

[font="'courier new', courier, monospace;"]got warning with gcc on centos [/font]

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[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
replace with
		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 warning
Can you post line 5070 and 5076 in your char.c ?

Edited by Angelmelody, 08 September 2014 - 04:38 PM.

Spoiler


#12 Litro

Litro

    Advanced Member

  • Members
  • PipPipPip
  • 365 posts
  • LocationProntera
  • Emulator:Hercules
  • Github:Litro

Posted 09 September 2014 - 12:37 AM

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);

[font="'courier new', courier, monospace;"]char.c.diff[/font]


:thx:For being you, For all of you :thx: 

 

:wub: ~ Certified Fans of AnnieRuru ~ :wub:

 


#13 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 09 September 2014 - 01:31 AM


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);
[font="'courier new', courier, monospace;"]char.c.diff[/font]


find
StrBuf->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);

Spoiler


#14 Litro

Litro

    Advanced Member

  • Members
  • PipPipPip
  • 365 posts
  • LocationProntera
  • Emulator:Hercules
  • Github:Litro

Posted 09 September 2014 - 02:42 AM

char.c: In function 'bonus_script_save':char.c:5070: warning: format '%u' expects type 'unsigned int', but argument 5 has type 'uint64'

[font="'courier new', courier, monospace;"]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' ?[/font]


Edited by Litro, 09 September 2014 - 03:06 AM.

:thx:For being you, For all of you :thx: 

 

:wub: ~ Certified Fans of AnnieRuru ~ :wub:

 


#15 Dastgir

Dastgir

    Advanced Member

  • Script Developers
  • 3345 posts
  • IRC Nickname:Dastgir
  • Emulator:Hercules
  • Github:dastgir

Posted 09 September 2014 - 03:52 AM

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 :P)

My Services: Click Here
Clientside Translation: Click HERE
Contact Via Discord: @Dastgir#1460


#16 Litro

Litro

    Advanced Member

  • Members
  • PipPipPip
  • 365 posts
  • LocationProntera
  • Emulator:Hercules
  • Github:Litro

Posted 09 September 2014 - 05:49 AM

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 :P)

 
[font="'courier new', courier, monospace;"]i have change it back to uint64 tick; and change the code like this and warning not appear[/font]

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

[font="'courier new', courier, monospace;"]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[/font]..


:thx:For being you, For all of you :thx: 

 

:wub: ~ Certified Fans of AnnieRuru ~ :wub:

 


#17 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 09 September 2014 - 06:06 AM

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 :P)

 
[font="'courier new', courier, monospace;"]i have change it back to uint64 tick; and change the code like this and warning not appear[/font]
StrBuf->Printf(&buf,"('%d','%s','%llu','%d','%d',",cid,esc_script,bs.tick,bs.flag,bs.type)
[font="'courier new', courier, monospace;"]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[/font]..

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);


Edited by Angelmelody, 09 September 2014 - 06:11 AM.

Spoiler


#18 Litro

Litro

    Advanced Member

  • Members
  • PipPipPip
  • 365 posts
  • LocationProntera
  • Emulator:Hercules
  • Github:Litro

Posted 09 September 2014 - 06:14 AM

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);

Edited by Litro, 09 September 2014 - 06:14 AM.

:thx:For being you, For all of you :thx: 

 

:wub: ~ Certified Fans of AnnieRuru ~ :wub:

 


#19 Angelmelody

Angelmelody

    (\ /) ( . .)

  • Members
  • PipPipPip
  • 772 posts
  • Locationnew_1-1,53,111
  • Emulator:Hercules
  • Github:Angelmelody

Posted 09 September 2014 - 06:20 AM

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) 


Edited by Angelmelody, 09 September 2014 - 06:46 AM.

Spoiler


#20 evilpuncker

evilpuncker

    The Suggester

  • Community Contributors
  • 2122 posts
  • Locationbr br hue hue

Posted 27 February 2015 - 02:23 PM

 

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


before asking for help, click here

some people that I admire:

Ai4rei (tools and client stuff) • Aeomin (the awesome thor patcher) • AnnieRuru (very helpful with script and source stuff)

Neo (N.E.M.O... do I need to say more?) • KeyWord (roBrowser <3) • k3dt (clients and clients) • Tokeiburu (awesome tools)

Dastgir (lua stuff) • Yommy • Ind • Haru • malufett

 

:ok:    and everyone that contributed in any way to the *Athena community in general (emulator, releases, support etc)  :no1: 





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users


This topic has been visited by 263 user(s)