Sign in to follow this  
Followers 0
AnnieRuru

OnPCStatCalcEvent

6 posts in this topic

rathena already has this by default -> https://github.com/rathena/rathena/commit/27a0f3f
someone else has tried to pull request in hercules, -> https://github.com/HerculesWS/Hercules/pull/351
but it was denied, so have to leave this as plugin

 

Download : 1.2
plugin

 

Tested with:

prontera,155,185,4	script	Test	1_F_MARIA,{
	@a ^= 1;
	mes "hmm...";
	close2;
	recalculatestat(); // if player under a dialog, MUST use close2; then only recalculate
	end;
OnPCStatCalcEvent:
	if ( @a )
		bonus bStr, 1000;
	end;
}

 

 

OnPCStatCalcEvent can't run during npc dialog, and spam map-server error along with it

during the npc dialog, keep change the equipment, you'll lose the str bonus and map-server spam error

[Warning]: npc_event: player's event queue is full, can't add event 'Test::OnPCStatCalcEvent' !

conf/map/battle/items.conf

// Enable all NPC to allow changing of equipments while interacting? (Note 1)
// Script commands 'enable_items/disable_items' will not be override. (see doc/script_commands.txt)
// Default: true (official)
item_enabled_npc: true

change this to false should stop it

 

but none the less, its still a great feature

Spoiler

1.0 - plugin

1.1 - plugin
- found a way to get *recalculatestat working, although its not thread-safe, but meh ~

1.2 - plugin
- remove some nullpo

 

Edited by AnnieRuru

Share this post


Link to post
Share on other sites

if got warning about queue is full , it's had a bad affect to our server ? or just showing warning

Share this post


Link to post
Share on other sites
Annie is gone, so I was in doubt about where to post, but here it is.
 
Note: I updated the plugin for the latest version of hercules.

 

 

 

//===== Hercules Plugin ======================================
//= OnPCStatCalcEvent
//===== By: ==================================================
//= AnnieRuru
//= originally by QQfoolsorellina
//===== Current Version: =====================================
//= 1.0
//===== Compatible With: ===================================== 
//= Hercules 2015-11-29
//===== Description: =========================================
//= give player permanent bonus
//===== Topic ================================================
//= http://herc.ws/board/topic/11292-onpcstatcalcevent/
//===== Additional Comments: =================================  
//= stat_recalc script command doesn't really work, I dunno why
//============================================================


#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#include "common/hercules.h"
#include "map/pc.h"
#include "map/npc.h"
//#include "map/script.h"
#include "map/status.h"
#include "common/nullpo.h"
#include "plugins/HPMHooking.h"
#include "common/HPMDataCheck.h"

HPExport struct hplugin_info pinfo = {
	"OnPCStatCalcEvent", // Plugin name
	SERVER_TYPE_MAP,// Which server types this plugin works with?
	"1.0",			// Plugin version
	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)
};

void status_calc_pc_additional_pre( struct map_session_data *sd, enum e_status_calc_opt *opt ) {
	nullpo_retv(sd);
	npc->event_doall_id( "OnPCStatCalcEvent", sd->bl.id );
	return;
}

/*	this stupid command doesn't work
BUILDIN(stat_recalc) {
	TBL_PC* sd;
	if ( script_hasdata(st,2) ) {
		if ( data_isstring( script_getdata(st,2) ) )
			sd = map->nick2sd( script_getstr(st,2) );
		else
			sd = map->id2sd( script_getnum(st,2) );
	} else
		sd = script->rid2sd(st);
	if (sd) {
//		status_calc_pc(sd, SCO_NONE);
//		status->calc_pc_(sd, SCO_NONE);
//		status->calc_pc_(sd, SCO_FORCE);
		status_calc_pc(sd, SCO_FORCE);
		ShowDebug( "run" );
	}
	return true;
}
*/
HPExport void plugin_init (void) {
	addHookPre(status, calc_pc_additional, status_calc_pc_additional_pre );
//	addScriptCommand( "stat_recalc", "?", stat_recalc );
}

 

 

 

Errors:

[Error]: --- nullpo info --------------------------------------------
[Error]: hercules\src\map\npc.c:841: 'sd' in function `unknown'
[Error]: --- end nullpo info ----------------------------------------
[Error]: --- nullpo info --------------------------------------------
[Error]: hercules\src\map\npc.c:841: 'sd' in function `unknown'
[Error]: --- end nullpo info ----------------------------------------
[Error]: --- nullpo info --------------------------------------------
[Error]: hercules\src\map\npc.c:841: 'sd' in function `unknown'
[Error]: --- end nullpo info ----------------------------------------
[Error]: --- nullpo info --------------------------------------------
[Error]: hercules\src\map\npc.c:841: 'sd' in function `unknown'
[Error]: --- end nullpo info ----------------------------------------

Share this post


Link to post
Share on other sites

1.1
plugin
- found a way to get *recalculatestat working, although its not thread-safe, but meh ~

Share this post


Link to post
Share on other sites

Found an issue. Console getting spammed with this:

[Mar/29 14:50:41][Warning]: npc_event: player's event queue is full, can't add event 'RecalcStat::OnPCStatCalcEvent' !

Share this post


Link to post
Share on other sites
15 hours ago, Myriad said:

Found an issue. Console getting spammed with this:

 

[Mar/29 14:50:41][Warning]: npc_event: player's event queue is full, can't add event 'RecalcStat::OnPCStatCalcEvent' !

 

this isn't an issue, it just say it runs this event too many times
probably having some scripts runs jobchange + statusup +equip + .... etc stuffs

I remember you said something about having a refiner script runs in loop ... probably caused by that
and even that ... it shouldn't effect anything ... just an error message

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  
Followers 0