Jump to content
  • 0
Sign in to follow this  
Conflicts

areaeffect effect #,x,y,d;

Question

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.

Share this post


Link to post
Share on other sites

8 answers to this question

Recommended Posts

  • 0

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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

@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

Share this post


Link to post
Share on other sites
  • 0

@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 =/

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0

Are we allowed to bump our posts here?

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

Share this post


Link to post
Share on other sites
  • 0
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

Share this post


Link to post
Share on other sites
  • 0
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):

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

Sign in to follow this  

×
×
  • Create New...

Important Information

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