Jump to content
  • 0

areaeffect effect #,x,y,d;


Conflicts

Question


  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  317
  • Reputation:   63
  • Joined:  11/13/11
  • Last Seen:  

Okay I've searched through the source and I learned that there are limited ways to display client-side effects.

It's either, have an NPC as the target object (specialeffect), or the attached player as the target object (specialeffect2).

What I'm trying to do this time, is display a client-side effect, on a certain coordinate (x,y) on the map.

The x and y coordinates will be supplied by the target coordinates of the player's mouse.

Say I want to display effect number 900, on the ground, centered to that x,y position of my mouse.

I'd just input areaeffect 900,xcoord,ycoord,duration(optional); on my script.

Can I get the script.c code needed to get this working?

Thanks.

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

Okay I've searched through the source and I learned that there are limited ways to display client-side effects.

It's either, have an NPC as the target object (specialeffect), or the attached player as the target object (specialeffect2).

What I'm trying to do this time, is display a client-side effect, on a certain coordinate (x,y) on the map.

The x and y coordinates will be supplied by the target coordinates of the player's mouse.

Say I want to display effect number 900, on the ground, centered to that x,y position of my mouse.

I'd just input areaeffect 900,xcoord,ycoord,duration(optional); on my script.

Can I get the script.c code needed to get this working?

Thanks.

AFAIK the client needs a target to display the effect.

Therefore you need an npc or player. Dont know about mobs/units, never tried it.

But you could just spawn an npc, hide them and display an effect with the hidden npc as the target.

AFAIK this works for certain minigames.

For the mouse coordinates, you could try to use the itemSkill() script command and hope to receive a clif_parse_UseSkillToPos() packet, containing the coordinates of the target.

If so, you will be able to move the npc to this coordinates and display the effect on it.

If I'm right, i tried to catch the mouse coordinates sometimes before and had some trouble in it,

But i cant remind me.. so let me know if youre lucked :)

Edited by GodLesZ
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  9
  • Topics Per Day:  0.00
  • Content Count:  379
  • Reputation:   304
  • Joined:  11/10/11
  • Last Seen:  

Well, I don't really know if you want to detect the mouse position...

About displaying an effect on x y I used this method in my Bomberman script:

A fake npc:

map,0,0,4    FAKE_EFFECT    139,{
end;
OnEffect:
   specialeffect(900);
}

And do the effect on x-y with:

moveNPC "FAKE_EFFECT", x, y;
donpcevent "FAKE_EFFECT::OnEffect";

The script.c equivalent should be something like this (but I can't test it):

//use : areaeffect( effect id, x, y);
BUILDIN_FUNC(areaeffect) {
   TBL_PC* sd = script_rid2sd(st);
   struct map_session_data* fk = (struct map_session_data*)aCalloc(1, sizeof(struct map_session_data));

   fk->bl.id  = npc_get_new_npc_id();
   fk->bl.x   = script_getnum(st,3);
   fk->bl.y   = script_getnum(st,4);
   fk->ud.dir = 0;

   clif_sendfakenpc( sd, fk->bl.id );
   clif_specialeffect_single( fk->bl, script_getnum(st,2), sd->fd );
   return 0;
}

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  317
  • Reputation:   63
  • Joined:  11/13/11
  • Last Seen:  

@GodLesZ,

Seems interesting. I can create a dummy skill which would just be used for capturing mouse coordinates.

Though I'm not exactly sure how I can use / convert clif_parse_UseSkillToPos() to actual x and y coordinates , if ever I'm successful on getting it.

@KeyWorld,

Yeah, mouse position would be vital, since this would be used mainly for a quest.

I would be confined to using DIR compared to current player's position (getmapxy)

to still somewhat make the NPC spawning (x,y) variable.

I tried using your mod, it shows me this;

script.c: In function 'buildin_areaeffect':
script.c:17900: warning: implicit declaration of function 'clif_sendfakenpc'
script.c:17901: error: incompatible type for argument 1 of 'clif_specialeffect_single'

Also, would the correct entry below be;

//Areaeffect
BUILDIN_DEF(areaeffect, "iii"),

PS: My post got answered in less than 2 hours. I prefer this new board. Lol.

Edit:

I changed this;

clif_specialeffect_single( fk->bl, script_getnum(st,2), sd->fd );

To this;

clif_specialeffect_single( fk->bl.id, script_getnum(st,2), sd->fd );

It compiled without error and 1 warning (shown above).

But when I attach it to a script, my map server crashes. :)

Edited by Conflicts
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  186
  • Reputation:   51
  • Joined:  11/14/11
  • Last Seen:  

@GodLesZ,

Seems interesting. I can create a dummy skill which would just be used for capturing mouse coordinates.

Though I'm not exactly sure how I can use / convert clif_parse_UseSkillToPos() to actual x and y coordinates , if ever I'm successful on getting it.

@KeyWorld,

Yeah, mouse position would be vital, since this would be used mainly for a quest.

I would be confined to using DIR compared to current player's position (getmapxy)

to still somewhat make the NPC spawning (x,y) variable.

I tried using your mod, it shows me this;

script.c: In function 'buildin_areaeffect':
script.c:17900: warning: implicit declaration of function 'clif_sendfakenpc'
script.c:17901: error: incompatible type for argument 1 of 'clif_specialeffect_single'

Also, would the correct entry below be;

//Areaeffect
BUILDIN_DEF(areaeffect, "iii"),

PS: My post got answered in less than 2 hours. I prefer this new board. Lol.

Edit:

I changed this;

clif_specialeffect_single( fk->bl, script_getnum(st,2), sd->fd );

To this;

clif_specialeffect_single( fk->bl.id, script_getnum(st,2), sd->fd );

It compiled without error and 1 warning (shown above).

But when I attach it to a script, my map server crashes. :)

You need to declare clif_sendfakenpc() in clif.h first.

Just paste the line

void clif_sendfakenpc(struct map_session_data *sd, int npcid);

above of

#endif /* _CLIF_H_ */

And clif_specialeffect_single() needs a pointer on the block_list struct, so the line should be

clif_specialeffect_single(&fk->bl, script_getnum(st,2), sd->fd); 

As for the mouse coordinates, I remeber to got some combinations to work, using a dummy skill called via itemSkill() script function after item usage.

This was a ground spell and triggerd clif_parse_UseSkillToPos(), which i hijacked to check for my dummy skill and triggered an NPC after this.

My old Revision is lost, so i cant provide some examples, Sorry =/

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  317
  • Reputation:   63
  • Joined:  11/13/11
  • Last Seen:  

You need to declare clif_sendfakenpc() in clif.h first.

Just paste the line

void clif_sendfakenpc(struct map_session_data *sd, int npcid);

above of

#endif /* _CLIF_H_ */

And clif_specialeffect_single() needs a pointer on the block_list struct, so the line should be

clif_specialeffect_single(&fk->bl, script_getnum(st,2), sd->fd); 

As for the mouse coordinates, I remeber to got some combinations to work, using a dummy skill called via itemSkill() script function after item usage.

This was a ground spell and triggerd clif_parse_UseSkillToPos(), which i hijacked to check for my dummy skill and triggered an NPC after this.

My old Revision is lost, so i cant provide some examples, Sorry =/

Aww. Yeah creating a ground-targetting skill would be the easy part.

I'd really appreciate if you could at least give some ideas on how to utilize clif_parse_UseSkillToPos()'s x and y coordinates.

Anyway, that fix above worked.

Though there's some problems.

-	script	GroundEffects	-1,{
end;

OnUse:
while( 1 )
{
	areaeffect(900,155,171);
	sleep2 5000;
}
end;
}

I tried using that NPC above.

It is supposed to display the effect on coordinates 155,171 on the map.

But instead, it displays the effect on my character.

Also, it's leaving this mark, which, is kinda expected, lol.

2s1vjuc.png

Edited by Conflicts
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  14
  • Topics Per Day:  0.00
  • Content Count:  317
  • Reputation:   63
  • Joined:  11/13/11
  • Last Seen:  

Are we allowed to bump our posts here?

*A good way to bump without being noticed* :D

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  15
  • Topics Per Day:  0.01
  • Content Count:  69
  • Reputation:   79
  • Joined:  02/20/20
  • Last Seen:  

Quote

 

It is supposed to display the effect on coordinates 155,171 on the map.

But instead, it displays the effect on my character.

 

 

Replace

 clif_sendfakenpc( sd, fk->bl.id );

By

Quote

   clif_sendfakenpc2( sd, fk );

 

Then:

clif.h:
 

Quote

void clif_sendfakenpc2(struct map_session_data *sd, struct map_session_data *fk);

clif.c:

Quote

 

void clif_sendfakenpc2(struct map_session_data *sd,struct map_session_data *fk) {
    unsigned char *buf;
    int fd = sd->fd;
    sd->state.using_fake_npc = 1;

    WFIFOHEAD(fd, packet_len(0x78));
    buf = WFIFOP(fd,0);
    memset(WBUFP(buf,0), 0, packet_len(0x78));
    WBUFW(buf,0)=0x78;
#if PACKETVER >= 20071106
    WBUFB(buf,2) = 0; // object type
    buf = WFIFOP(fd,1);
#endif
    WBUFL(buf,2)=fk->bl.id;
    WBUFW(buf,14)=111;
    WBUFPOS(buf,46,fk->bl.x,fk->bl.y,fk->ud.dir);
    WBUFB(buf,49)=5;
    WBUFB(buf,50)=5;
    WFIFOSET(fd, packet_len(0x78));
}

 

 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   0
  • Joined:  08/12/13
  • Last Seen:  

On 3/1/2021 at 9:00 PM, grenat50 said:

 

Replace


 clif_sendfakenpc( sd, fk->bl.id );

By

 

Then:

clif.h:
 

 

On 3/1/2021 at 9:00 PM, grenat50 said:

clif.c:

 

image.png.3662a5995db3670fd7bc40f3f5e23896.png

perform your fix, but the silhouette that there is an NPC is still appearing as can be seen in the photo, it is worth mentioning that it is mandatory to make an attach to the npc so that it can be started and I think that what is sought is that It can be started without anyone having to click it and in your case there is no trace of clicking as if it were an npc, since it can be annoying in the case of being invoked in several simultaneous areas.

[Error]: buildin_areaeffect: fatal error! player not attached!
[Debug]: Function: areaeffect (3 parameters):

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