Jump to content
  • 0

Question

Posted

I searched but I think what I need wasn't done yet. I'm still new at source programming and was trying to do this command without sucess.

What I need is an script_command that, when you put 2 characters ids(if work with mob unique ids will be even better), those 2 players or 2 mobs start to identify each other as enemy and became able to attack, even if they were from the same guild and group. A little bit like the @duel. 

 

8 answers to this question

Recommended Posts

  • 0
Posted
 src/map/battle.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index bd93370fb..8df9921fe 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -7643,6 +7643,13 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 	if( (s_bl = battle_get_master(src)) == NULL )
 		s_bl = src;
 
+	if ( s_bl->type == BL_PC && t_bl->type == BL_PC ) {
+		struct map_session_data *sd = BL_CAST( BL_PC, s_bl );
+		struct map_session_data *tsd = BL_CAST( BL_PC, t_bl );
+		if ( sd->status.account_id == 2000000 && tsd->status.account_id == 2000001 || sd->status.account_id == 2000001 && tsd->status.account_id == 2000000 )
+			return 1;
+	}
+
 	if ( s_bl->type == BL_PC ) {
 		switch( t_bl->type ) {
 			case BL_MOB: // Source => PC, Target => MOB

 

And THIS is the MOTHER of all FACTION script

 src/map/battle.cpp | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/map/battle.cpp b/src/map/battle.cpp
index bd93370fb..769d0fc98 100644
--- a/src/map/battle.cpp
+++ b/src/map/battle.cpp
@@ -7643,6 +7643,13 @@ int battle_check_target( struct block_list *src, struct block_list *target,int f
 	if( (s_bl = battle_get_master(src)) == NULL )
 		s_bl = src;
 
+	if ( s_bl->type == BL_PC && t_bl->type == BL_PC ) {
+		struct map_session_data *sd = BL_CAST( BL_PC, s_bl );
+		struct map_session_data *tsd = BL_CAST( BL_PC, t_bl );
+		if ( pc_readglobalreg( sd, add_str("faction") ) != pc_readglobalreg( tsd, add_str("faction") ) )
+			return 1;
+	}
+
 	if ( s_bl->type == BL_PC ) {
 		switch( t_bl->type ) {
 			case BL_MOB: // Source => PC, Target => MOB
prontera,155,185,5	script	ksjfdhsk	1_F_MARIA,{
	input faction;
}

 

 

  • Love 1
  • Like 1
  • 0
Posted
8 hours ago, SyncMaster said:

I searched but I think what I need wasn't done yet. I'm still new at source programming and was trying to do this command without sucess.

What I need is an script_command that, when you put 2 characters ids(if work with mob unique ids will be even better), those 2 players or 2 mobs start to identify each other as enemy and became able to attack, even if they were from the same guild and group. A little bit like the @duel. 

 

 

ctrl + f, in your script_commands, and read about, OnPCDieEvent :, OnPCKillEvent :, OnNPCKillEvent :, and also has that rid2name

  • 0
Posted

@cder why should he look into the script commands docs if he wants to create a src modification? Makes no sense too me. Maybe you could elaborate on why your suggested script commands help.

@SyncMaster Have you tried taking the duel command src code as reference for your custom script command? 

https://github.com/rathena/rathena/blob/master/src/map/duel.cpp

  • 0
Posted (edited)
50 minutes ago, Normynator said:

@cder why should he look into the script commands docs if he wants to create a src modification? Makes no sense too me. Maybe you could elaborate on why your suggested script commands help.

@SyncMaster Have you tried taking the duel command src code as reference for your custom script command? 

https://github.com/rathena/rathena/blob/master/src/map/duel.cpp

Yes, I'm already studying the @duel function to develop the command, just put it here to check if someone has already done that or know better to do it quicker.

Edited by SyncMaster
  • 0
Posted (edited)
9 hours ago, AnnieRuru said:

...

And THIS is the MOTHER of all FACTION script

...

You're an angel? Worked and will fit in my need *-*. Thank you so much. I'll use as basis for other modifications ?

Edited by SyncMaster
  • Love 1
  • 0
Posted (edited)

it works if you press shift. how to make an attack right away? I searched for a long time in clif.c how to make an enemy. not found =( can someone tell me how to send a packet to a client about an enemy? (I've been trying to figure out how to make factions hostile for 2 weeks)

On 4/14/2020 at 8:06 AM, joey93 said:

@AnnieRuru, hello !!

how i use this??


prontera,155,185,5	script	ksjfdhsk	1_F_MARIA,{
	input faction;
}

npc menu 

if (select(.@menu$) == 1) {
	set faction, 1;
}else{
	set faction, 2;
}

\src\map\battle.cpp 

int battle_check_target( struct block_list *src, struct block_list *target,int flag)

	int64 s_fvf = pc_readglobalreg((TBL_PC*)src, add_str("faction"));
	int64 t_fvf = pc_readglobalreg((TBL_PC*)target, add_str("faction"));
	if (s_fvf > 0 && t_fvf > 0 && s_fvf != t_fvf && mapdata->flag[MF_FVF]) {
		return 1;
	}

 

Edited by issid

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.   Paste as plain text instead

  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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...