Jump to content
  • 0
Sign in to follow this  
Kichi

Discussion about HPM - Bg create

Question

Helo guys
i tried to convert my mod to HPM, i got error when compile,
I certainly write in wrong format
This is the MOD

 

--- a/src/map/battleground.c+++ b/src/map/battleground.c@@ -187,6 +187,21 @@ int bg_create(unsigned short mapindex, short rx, short ry, const char *ev, const 	return bgd->bg_id; } +int bg_create2( unsigned short bg_id, unsigned short mapindex, short rx, short ry, const char *ev, const char *dev ) {+	struct battleground_data *bgd = bg->team_search(bg_id);+	if ( bgd ) return 0;+	CREATE(bgd, struct battleground_data, 1);+	bgd->bg_id = bg_id;+	bgd->count = 0;+	bgd->mapindex = mapindex;+	bgd->x = rx;+	bgd->y = ry;+	safestrncpy(bgd->logout_event, ev, sizeof(bgd->logout_event));+	safestrncpy(bgd->die_event, dev, sizeof(bgd->die_event));+	memset(&bgd->members, 0, sizeof(bgd->members));+	idb_put(bg->team_db, bg_id, bgd);+	return bgd->bg_id;+} int bg_team_get_id(struct block_list *bl) { 	nullpo_ret(bl); 	switch( bl->type ) {@@ -787,7 +802,7 @@ void battleground_defaults(void) { 	bg->arenas = 0; 	/* */ 	bg->team_db = NULL;-	bg->team_counter = 0;+	bg->team_counter = 1000; 	/* */ 	bg->init = do_init_battleground; 	bg->final = do_final_battleground;@@ -813,6 +828,7 @@ void battleground_defaults(void) { 	bg->team_leave = bg_team_leave; 	bg->member_respawn = bg_member_respawn; 	bg->create = bg_create;+	bg->create2 = bg_create2; 	bg->team_get_id = bg_team_get_id; 	bg->send_message = bg_send_message; 	bg->send_xy_timer_sub = bg_send_xy_timer_sub;diff --git a/src/map/battleground.h b/src/map/battleground.hindex a5e5409..3236fd3 100644--- a/src/map/battleground.h+++ b/src/map/battleground.h@@ -102,7 +102,8 @@ struct battleground_interface { 	int (*team_get_id) (struct block_list *bl); 	int (*send_message) (struct map_session_data *sd, const char *mes, int len); 	int (*send_xy_timer_sub) (DBKey key, DBData *data, va_list ap);-	int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);	+	int (*send_xy_timer) (int tid, int64 tick, int id, intptr_t data);+	int (*create2) ( unsigned short bg_id, unsigned short mapindex, short rx, short ry, const char *ev, const char *dev ); 	/* */ 	void (*config_read) (void); };diff --git a/src/map/script.c b/src/map/script.cindex d51f27c..ff21ec7 100644--- a/src/map/script.c+++ b/src/map/script.c@@ -15851,7 +15851,52 @@ int axtoi(const char *hexStg) 	 	return true; }-+//	createbgid <battleground ID>, <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;+BUILDIN(createbgid) {+	if ( bg->create2( script_getnum(st,2), mapindex_name2id( script_getstr(st,3) ), script_getnum(st,4), script_getnum(st,5), script_getstr(st,6), script_getstr(st,7) ) > 0 )+		script_pushint( st, script_getnum(st,2) );+	else+		script_pushint( st, 0 );+	return 0;+}+ +//	setbgid <battleground ID> {, <player name> };+BUILDIN(setbgid) {+	unsigned short bg_id = script_getnum(st,2);+	struct battleground_data *bgd = bg->team_search(bg_id);+	TBL_PC* sd;+	if ( bg_id < 0 || bg_id > 1000 ) {+		script_pushint( st, -4 );+		return 0;+	}+	if ( script_hasdata(st,3) ) +		sd = map->nick2sd( script_getstr(st,3) );+	else+		sd = script_rid2sd(st);+	if ( sd == NULL ) {+		script_pushint( st, -3 );+		return 0;+	}+	if ( bg_id > 0 && bg == NULL ) {+		script_pushint( st, -1 );+		return 0;+	}+	if ( sd->bg_id == bg_id && bg_id != 0 ) {+		script_pushint( st, -5 );+		return 0;+	}+	if ( sd->bg_id )+		bg->team_leave(sd,0);+	if ( bg_id == 0 ) {+		script_pushint( st, 0 );+		return 0;+	}+	if ( bg->team_join( bg_id, sd ) == 0 )+		script_pushint( st, -2 );+	else+		script_pushint( st, bg_id );+	return 0;+} /*==========================================  * Instancing Script Commands  *------------------------------------------*/@@ -18061,7 +18106,9 @@ void script_parse_builtin(void) { 		BUILDIN_DEF(bg_get_data,"ii"), 		BUILDIN_DEF(bg_getareausers,"isiiii"), 		BUILDIN_DEF(bg_updatescore,"sii"),-		+		//custom bg+		BUILDIN_DEF(createbgid,"isiiss"),+		BUILDIN_DEF(setbgid,"i?"), 		// Instancing 		BUILDIN_DEF(instance_create,"si?"), 		BUILDIN_DEF(instance_destroy,"?"),

 


 

and This is the HPM

// Copyright (c) Hercules Dev Team, licensed under GNU GPL.// See the LICENSE file// Sample Hercules Plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../common/HPMi.h"#include "../common/mmo.h"#include "../common/mapindex.h"#include "../common/mapindex.c"#include "../map/script.h"#include "../map/pc.h"#include "../map/battle.h"#include "../map/status.h"#include "../map/map.h"#include "../map/battleground.h"HPExport struct hplugin_info pinfo = {    "BG2",// 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)};static int bg_create2( unsigned short bg_id, unsigned short mapindex, short rx, short ry, const char *ev, const char *dev ) {    struct battleground_data *bgd = bg->team_search(bg_id);    if ( bgd ) return 0;    CREATE(bgd, struct battleground_data, 1);    bgd->bg_id = bg_id;    bgd->count = 0;    bgd->mapindex = mapindex;    bgd->x = rx;    bgd->y = ry;    safestrncpy(bgd->logout_event, ev, sizeof(bgd->logout_event));    safestrncpy(bgd->die_event, dev, sizeof(bgd->die_event));    memset(&bgd->members, 0, sizeof(bgd->members));    idb_put(bg->team_db, bg_id, bgd);    return bgd->bg_id;}/* to check for the bonus *//*    createbgid <battleground ID>, <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;*/BUILDIN(createbgid) {    int mapindex;    mapindex = mapindex_name2id( script_getstr(st,3) );    if ( bg->create2( script_getnum(st,2), mapindex, script_getnum(st,4), script_getnum(st,5), script_getstr(st,6), script_getstr(st,7) ) > 0 )        script_pushint( st, script_getnum(st,2) );    else        script_pushint( st, 0 );    return 0;} //    setbgid <battleground ID> {, <player name> };BUILDIN(setbgid) {    unsigned short bg_id = script_getnum(st,2);    struct battleground_data *bgd = bg->team_search(bg_id);    TBL_PC* sd;    if ( bg_id < 0 || bg_id > 1000 ) {        script_pushint( st, -4 );        return 0;    }    if ( script_hasdata(st,3) )        sd = map->nick2sd( script_getstr(st,3) );    else        sd = script->rid2sd(st);    if ( sd == NULL ) {        script_pushint( st, -3 );        return 0;    }    if ( bg_id > 0 && bg == NULL ) {        script_pushint( st, -1 );        return 0;    }    if ( sd->bg_id == bg_id && bg_id != 0 ) {        script_pushint( st, -5 );        return 0;    }    if ( sd->bg_id )        bg->team_leave(sd,0);    if ( bg_id == 0 ) {        script_pushint( st, 0 );        return 0;    }    if ( bg->team_join( bg_id, sd ) == 0 )        script_pushint( st, -2 );    else        script_pushint( st, bg_id );    return 0;}/*void battleground_defaults(void) {    bg->team_counter = 1000;    bg->create2 = bg_create2;}*/HPExport void plugin_init (void){    map = GET_SYMBOL("map");    script = GET_SYMBOL("script");    bg = GET_SYMBOL("battleground");    skill = GET_SYMBOL("skill");    pc = GET_SYMBOL("pc");    battle = GET_SYMBOL("battle");        if( HPMi->addScript != NULL ) {//link our 'sample' script command                HPMi->addScript("createbgid","isiiss",BUILDIN_A(createbgid));                HPMi->addScript("setbgid","i?",BUILDIN_A(setbgid));        }}

 


im new using HPM :)

 

What i've tried

  1. apply  battleground.c and battleground.h and  script.c in HPM NO WORK
  2. apply "void battleground_defaults" to core and leave other in HPM NO WORK
  3. apply mod to battleground.c and battleground.h and leave script.c in HPM NO WORK
  4. including mapindex.c < NO ERROR, but the map CRASH
  5. and much other NO WORK

 

---- INFO----

This mod work when applied directly to core

 

---- EDIT -------

Update Plugin and Mod

Edited by Kichi

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

havnt test it yet, try this

// Copyright (c) Hercules Dev Team, licensed under GNU GPL.// See the LICENSE file// Sample Hercules Plugin#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../common/HPMi.h"#include "../map/script.h"#include "../map/pc.h"#include "../map/map.h"#include "../map/battleground.h"HPExport struct hplugin_info pinfo = {    "BG2",// 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)};static int bg_create2( unsigned short bg_id, unsigned short mapindex, short rx, short ry, const char *ev, const char *dev ) {    struct battleground_data *bgd = bg->team_search(bg_id);    if ( bgd ) return 0;    CREATE(bgd, struct battleground_data, 1);    bgd->bg_id = bg_id;    bgd->count = 0;    bgd->mapindex = mapindex;    bgd->x = rx;    bgd->y = ry;    safestrncpy(bgd->logout_event, ev, sizeof(bgd->logout_event));    safestrncpy(bgd->die_event, dev, sizeof(bgd->die_event));    memset(&bgd->members, 0, sizeof(bgd->members));    idb_put(bg->team_db, bg_id, bgd);    return bgd->bg_id;}/* to check for the bonus *//*    createbgid <battleground ID>, <respawn map>, <respawn x>, <respawn y>, <On Quit event>, <On Death event>;*/BUILDIN(createbgid) {    int map_index;	const char* str = script_getstr(st,3);    map_index = mapindex->name2id(str);    if ( bg_create2( script_getnum(st,2), map_index, script_getnum(st,4), script_getnum(st,5), script_getstr(st,6), script_getstr(st,7) ) > 0 )        script_pushint( st, script_getnum(st,2) );    else        script_pushint( st, 0 );    return true;} //    setbgid <battleground ID> {, <player name> };BUILDIN(setbgid) {    unsigned short bg_id = script_getnum(st,2);    struct battleground_data *bgd = bg->team_search(bg_id);    TBL_PC* sd;    if ( bg_id < 0 || bg_id > 1000 ) {        script_pushint( st, -4 );        return 0;    }    if ( script_hasdata(st,3) )        sd = map->nick2sd( script_getstr(st,3) );    else        sd = script->rid2sd(st);    if ( sd == NULL ) {        script_pushint( st, -3 );        return 0;    }    if ( bg_id > 0 && bg == NULL ) {        script_pushint( st, -1 );        return 0;    }    if ( sd->bg_id == bg_id && bg_id != 0 ) {        script_pushint( st, -5 );        return 0;    }    if ( sd->bg_id )        bg->team_leave(sd,0);    if ( bg_id == 0 ) {        script_pushint( st, 0 );        return 0;    }    if ( bg->team_join( bg_id, sd ) == 0 )        script_pushint( st, -2 );    else        script_pushint( st, bg_id );    return true;}/*void battleground_defaults(void) {    bg->team_counter = 1000;    bg->create2 = bg_create2;}*/HPExport void plugin_init (void){    map = GET_SYMBOL("map");    mapindex = GET_SYMBOL("mapindex");    bg = GET_SYMBOL("battleground");    pc = GET_SYMBOL("pc");    	addScriptCommand("createbgid","isiiss",createbgid);	addScriptCommand("setbgid","i?",setbgid);}

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.