Jump to content
  • 0

Duel script_command


SyncMaster

Question


  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   37
  • Joined:  07/15/13
  • Last Seen:  

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. 

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

 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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.02
  • Content Count:  96
  • Reputation:   0
  • Joined:  08/06/18
  • Last Seen:  

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

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  292
  • Reputation:   199
  • Joined:  05/03/13
  • Last Seen:  

@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

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  36
  • Topics Per Day:  0.02
  • Content Count:  96
  • Reputation:   0
  • Joined:  08/06/18
  • Last Seen:  

 

I thought I could help.

Edited by cder
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   37
  • Joined:  07/15/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  53
  • Topics Per Day:  0.01
  • Content Count:  123
  • Reputation:   37
  • Joined:  07/15/13
  • Last Seen:  

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
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  7
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  02/12/18
  • Last Seen:  

@AnnieRuru, hello !!

how i use this??

prontera,155,185,5	script	ksjfdhsk	1_F_MARIA,{
	input faction;
}
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  6
  • Reputation:   0
  • Joined:  12/06/15
  • Last Seen:  

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
Link to comment
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.   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.

×
×
  • Create New...