Jump to content
  • 0

NPC Hide and progressbar [Q]


Hirasu

Question


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   6
  • Joined:  12/23/11
  • Last Seen:  

hey,

i want to ask if it possible to hide an npc only for one char via variable ? and can i make the "progressbar " script over an npc?

 

thanks :)

Link to comment
Share on other sites

8 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  29
  • Topics Per Day:  0.01
  • Content Count:  270
  • Reputation:   20
  • Joined:  12/10/11
  • Last Seen:  


progressbar "0xRRGGBB",20;

The 20 is the time in seconds

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   6
  • Joined:  12/23/11
  • Last Seen:  

@Jasc

thank but i want the progressbar over the npc head not over the player :(

Link to comment
Share on other sites


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

i want to ask if it possible to hide an npc only for one char via variable ?

yes, but with source modification

you can tackle them with clif_getareachar_unit

if ( pc_readreg( sd, add_str("<variable here>") ) ...

and can i make the "progressbar " script over an npc?

I'm not very sure but by reading clif_progressbar inside clif.c

it looks impossible, because the packet needs to read a player ID

not sure is there any work around with it

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

It's definitly source edit. I did some digging and tried out something, not sure if it's the best solution, but might fit your need. It introduces two new script commands: setvisibility and getvisibility.

 


* setvisibility <value>{, <"npc">}
* @param <value> the value to set it and checkf or
* @param <"npc"> if another NPC should be targetted

 

You set the value of the NPC to a value not 0. Only players with the character variable "npcvisibility" set to this exact value can now see the NPC. It should also not effect NPCs which have no visibility set, since it ignores the value zero. You have to put this into the OnInit event, since I didn't add a saving mechanism so it will be deleted once you reload. Thus the OnInit.

 
 
* getvisibility {<"npc>"}
* @param <"npc"> if another NPC should be targetted
**/

Self explaning, imho.

 

An example:

// Some NPC here
OnInit:
SetVisibility(1);
End;

Only a player with the variable "npcvisibility" set to 1 can see the npc now.

 

The patch:

 

diff --git a/src/map/clif.c b/src/map/clif.c
index 2731018..099466f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4152,11 +4152,16 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
  if (!vd || vd->class_ == INVISIBLE_CLASS)
  return;


- /**
- * Hide NPC from maya purple card.
- **/
- if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
- return;
+ if(bl->type == BL_NPC) {
+ /**
+ * Hide NPC from maya purple card.
+ **/
+ if (!((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
+ return;
+ // Only show NPC to people who have a certain variable set
+ if (((TBL_NPC*)bl)->visibility != 0 && ((TBL_NPC*)bl)->visibility == pc_readglobalreg(sd, "npcvisibility"))
+ return;
+ }


  ud = unit_bl2ud(bl);
  len = ( ud && ud->walktimer != INVALID_TIMER ) ? clif_set_unit_walking(bl,ud,buf) : clif_set_unit_idle(bl,buf,false);
diff --git a/src/map/npc.h b/src/map/npc.h
index ab9d084..b4b6552 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -70,6 +70,7 @@ struct npc_data {
  char killer_name[NAME_LENGTH];
  } tomb;
  } u;
+ int visibility;
 };




diff --git a/src/map/script.c b/src/map/script.c
index eda82c7..681867f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18165,6 +18165,43 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  return SCRIPT_CMD_SUCCESS;
 }


+/**
+ * setvisibility <value>{, <"npc">}
+ * @param <value> the value to set it and checkf or
+ * @param <"npc"> if another NPC should be targetted
+**/
+BUILDIN_FUNC(setvisibility) {
+ struct npc_data *nd = NULL;
+
+ if (script_hasdata(st, 3)) {
+ nd = npc_name2id(script_getstr(st, 3));
+ ShowWarning("buildin_setvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 3));
+ }
+ if (nd == NULL)
+ nd = map_id2nd(st->oid);
+
+ nd->visibility = script_getnum(st, 2);
+ return SCRIPT_CMD_SUCCESS;
+}
+
+/**
+ * getvisibility {<"npc>"}
+ * @param <"npc"> if another NPC should be targetted
+**/
+BUILDIN_FUNC(getvisibility) {
+ struct npc_data *nd = NULL;
+
+ if (script_hasdata(st, 2)) {
+ nd = npc_name2id(script_getstr(st, 2));
+ ShowWarning("buildin_getvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 2));
+ }
+ if (nd == NULL)
+ nd = map_id2nd(st->oid);
+
+ script_pushint(st, nd->visibility);
+ return SCRIPT_CMD_SUCCESS;
+}
+
 #include "../custom/script.inc"


 // declarations that were supposed to be exported from npc_chat.c
@@ -18648,6 +18685,8 @@ struct script_function buildin_func[] = {
  BUILDIN_DEF(vip_time,"i?"),
 #endif
  BUILDIN_DEF(bonus_script,"si???"),
+ BUILDIN_DEF(setvisibility, "i?"),
+ BUILDIN_DEF(getvisibility, "?"),


 #include "../custom/script_def.inc"
Edited by Jonne
  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   6
  • Joined:  12/23/11
  • Last Seen:  

Thanks for the replays !

 

EDIT: 

 

 

 

It's definitly source edit. I did some digging and tried out something, not sure if it's the best solution, but might fit your need. It introduces two new script commands: setvisibility and getvisibility.

 


* setvisibility <value>{, <"npc">}
* @param <value> the value to set it and checkf or
* @param <"npc"> if another NPC should be targetted

 

You set the value of the NPC to a value not 0. Only players with the character variable "npcvisibility" set to this exact value can now see the NPC. It should also not effect NPCs which have no visibility set, since it ignores the value zero. You have to put this into the OnInit event, since I didn't add a saving mechanism so it will be deleted once you reload. Thus the OnInit.

 
 
* getvisibility {<"npc>"}
* @param <"npc"> if another NPC should be targetted
**/

Self explaning, imho.

 

An example:

// Some NPC here
OnInit:
SetVisibility(1);
End;

Only a player with the variable "npcvisibility" set to 1 can see the npc now.

 

The patch:

 

diff --git a/src/map/clif.c b/src/map/clif.c
index 2731018..099466f 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -4152,11 +4152,16 @@ void clif_getareachar_unit(struct map_session_data* sd,struct block_list *bl)
  if (!vd || vd->class_ == INVISIBLE_CLASS)
  return;


- /**
- * Hide NPC from maya purple card.
- **/
- if(bl->type == BL_NPC && !((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
- return;
+ if(bl->type == BL_NPC) {
+ /**
+ * Hide NPC from maya purple card.
+ **/
+ if (!((TBL_NPC*)bl)->chat_id && (((TBL_NPC*)bl)->sc.option&OPTION_INVISIBLE))
+ return;
+ // Only show NPC to people who have a certain variable set
+ if (((TBL_NPC*)bl)->visibility != 0 && ((TBL_NPC*)bl)->visibility == pc_readglobalreg(sd, "npcvisibility"))
+ return;
+ }


  ud = unit_bl2ud(bl);
  len = ( ud && ud->walktimer != INVALID_TIMER ) ? clif_set_unit_walking(bl,ud,buf) : clif_set_unit_idle(bl,buf,false);
diff --git a/src/map/npc.h b/src/map/npc.h
index ab9d084..b4b6552 100644
--- a/src/map/npc.h
+++ b/src/map/npc.h
@@ -70,6 +70,7 @@ struct npc_data {
  char killer_name[NAME_LENGTH];
  } tomb;
  } u;
+ int visibility;
 };




diff --git a/src/map/script.c b/src/map/script.c
index eda82c7..681867f 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -18165,6 +18165,43 @@ static int atcommand_cleanfloor_sub(struct block_list *bl, va_list ap)
  return SCRIPT_CMD_SUCCESS;
 }


+/**
+ * setvisibility <value>{, <"npc">}
+ * @param <value> the value to set it and checkf or
+ * @param <"npc"> if another NPC should be targetted
+**/
+BUILDIN_FUNC(setvisibility) {
+ struct npc_data *nd = NULL;
+
+ if (script_hasdata(st, 3)) {
+ nd = npc_name2id(script_getstr(st, 3));
+ ShowWarning("buildin_setvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 3));
+ }
+ if (nd == NULL)
+ nd = map_id2nd(st->oid);
+
+ nd->visibility = script_getnum(st, 2);
+ return SCRIPT_CMD_SUCCESS;
+}
+
+/**
+ * getvisibility {<"npc>"}
+ * @param <"npc"> if another NPC should be targetted
+**/
+BUILDIN_FUNC(getvisibility) {
+ struct npc_data *nd = NULL;
+
+ if (script_hasdata(st, 2)) {
+ nd = npc_name2id(script_getstr(st, 2));
+ ShowWarning("buildin_getvisibility: NPC '%s' not found. Using active NPC.\n", script_getstr(st, 2));
+ }
+ if (nd == NULL)
+ nd = map_id2nd(st->oid);
+
+ script_pushint(st, nd->visibility);
+ return SCRIPT_CMD_SUCCESS;
+}
+
 #include "../custom/script.inc"


 // declarations that were supposed to be exported from npc_chat.c
@@ -18648,6 +18685,8 @@ struct script_function buildin_func[] = {
  BUILDIN_DEF(vip_time,"i?"),
 #endif
  BUILDIN_DEF(bonus_script,"si???"),
+ BUILDIN_DEF(setvisibility, "i?"),
+ BUILDIN_DEF(getvisibility, "?"),


 #include "../custom/script_def.inc"

 

i Got some src error on rathena (with rAmod)

 

" 14 IntelliSense: identifier "SCRIPT_CMD_SUCCESS" is undefined C:\rAmod\src\map\script.c 20011 "

Edited by Hirasu
Link to comment
Share on other sites


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

@Jonne

I think its more resource wise to set a source variable in pc.h like *pcblockmove did

I got lectured by brainstorm before already

http://www.eathena.ws/board/index.php?s=&showtopic=270470&view=findpost&p=1487092

lol my previous post ... totally forgot about this

https://github.com/rathena/rathena/tree/master/src/custom

I think should move every single custom script command into this file

@Hirasu

return SCRIPT_CMD_SUCCESS;

change into

return 0;

Edited by AnnieRuru
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  149
  • Reputation:   33
  • Joined:  12/24/11
  • Last Seen:  

@Jonne

I think its more resource wise to set a source variable in pc.h like *pcblockmove did

I got lectured by brainstorm before already

http://www.eathena.ws/board/index.php?s=&showtopic=270470&view=findpost&p=1487092

lol my previous post ... totally forgot about this

https://github.com/rathena/rathena/tree/master/src/custom

I think should move every single custom script command into this file

 

Did not know about the custom folder, thanks.

 

Ye it is more resource-wise, but harder for the scripter to apply, imho. Just as I said, it's not the finest solution, but it should do what is needed.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.00
  • Content Count:  61
  • Reputation:   6
  • Joined:  12/23/11
  • Last Seen:  

@Jonne

I think its more resource wise to set a source variable in pc.h like *pcblockmove did

I got lectured by brainstorm before already

http://www.eathena.ws/board/index.php?s=&showtopic=270470&view=findpost&p=1487092

lol my previous post ... totally forgot about this

https://github.com/rathena/rathena/tree/master/src/custom

I think should move every single custom script command into this file

@Hirasu

return SCRIPT_CMD_SUCCESS;

change into

return 0;

@AnnieRuru

Thanks for the info now it works :D

 

@Jonne

Thanks for the code :)

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...