SphereCommunity
Automatic target when equipping weapons through dclick - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: General Help (/Forum-General-Help)
+--- Thread: Automatic target when equipping weapons through dclick (/Thread-Automatic-target-when-equipping-weapons-through-dclick)



Automatic target when equipping weapons through dclick - karma - 10-09-2014 06:51 AM

As Sphere's default behavior, when you equip a weapon by dclicking it, a target is called. Is there any way to prevent this?
It would be ideal if dclicking an unequipped weapon simply equips it, and then if you dclick the equipped weapon the target appears.


RE: Automatic target when equipping weapons through dclick - Extreme - 10-09-2014 06:56 AM

Check if you can equip it and use EQUIP then return 1 on @dclick


RE: Automatic target when equipping weapons through dclick - karma - 10-09-2014 07:32 AM

I have considered this solution, but i'm afraid to interfere with other events which manage @DClick. Do you say there won't be any problems?


RE: Automatic target when equipping weapons through dclick - Coruja - 10-09-2014 08:50 AM

you can softcode the dclick behavior creating a typedef to override the hardcoded typedef

the softcoded typedef will always run before the hardcoded typedef, so you can use return 1 to prevent the hardcoded action

Code:
[TYPEDEF t_weapon_axe]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_sword]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_fence]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_mace_pick]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_mace_smith]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_mace_crook]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_mace_sharp]
ON=@DClick
return <DClickWeapon>

[TYPEDEF t_weapon_mace_staff]
ON=@DClick
return <DClickWeapon>


[FUNCTION DClickWeapon]
IF (<CONT> == <SRC>)        //show target selection if the weapon is already equiped
  TARGET <DEFMSG.itemuse_weapon_promt>
ELIF (<TOPOBJ> != <SRC>)    //check TOPOBJ to prevent equip weapons locked on ground (houses) or steal weapons dclicking on another paperdoll
  SRC.SYSMESSAGE <DEFMSG.reach_fail>
ELSE
  EQUIP
ENDIF
return 1        //this will stop the hardcoded behavior for @DClick



RE: Automatic target when equipping weapons through dclick - karma - 10-09-2014 09:10 AM

That should work fine! I re-read the wiki, the order of firing for events/types is:
1) event
2) tevent
3) type
4) itemdef
So, if i RETURN 1 in the @DClick declared in the typedef, i will stop only the execution of the code under @DClick in the itemdef. Not too bad, but i have to remember that Big Grin
Thanks to both of you!


RE: Automatic target when equipping weapons through dclick - Coruja - 10-11-2014 04:51 PM

it's your lucky day, XuN added a new OF_NODClickTarget .ini setting that will do it automatically

Quote:XuN r2051 10.10.14

Added OF_NODClickTarget to ini, enabling this will not make the cursor appear as a target when double clicking weapons to equip them.

it works on all t_weapon_* except weapons that can get resources from trees (t_weapon_mace_sharp, t_weapon_sword, t_weapon_fence, t_weapon_axe)
I don't know if this exclusion is planned or if XuN forgot to change the code on these typedefs lol


RE: Automatic target when equipping weapons through dclick - XuN - 10-11-2014 05:49 PM

Its working in these types too, notice that there's no break, continue or return above these ones so they are being grouped together with t_weapon_mace_staff and t_weapon_mace_smith.

EDIT: Otherwise Ben would've commited to fix it! Big Grin


RE: Automatic target when equipping weapons through dclick - karma - 10-12-2014 09:22 AM

(10-11-2014 04:51 PM)Coruja Wrote:  it's your lucky day, XuN added a new OF_NODClickTarget .ini setting that will do it automatically

Quote:XuN r2051 10.10.14

Added OF_NODClickTarget to ini, enabling this will not make the cursor appear as a target when double clicking weapons to equip them.

it works on all t_weapon_* except weapons that can get resources from trees (t_weapon_mace_sharp, t_weapon_sword, t_weapon_fence, t_weapon_axe)
I don't know if this exclusion is planned or if XuN forgot to change the code on these typedefs lol

I know, thanks Coruja Big Grin
(This also fixes a bug in the EC with equipping items from ground not disappearing from ground, what a lovely guy is XuN LOL)


RE: Automatic target when equipping weapons through dclick - Coruja - 10-13-2014 04:12 PM

roflmao I didn't saw this line Tongue

but just a note, spells anim got broken on latest build, it's playing the non-mounted anim on mounted chars (classic client 5.x.x). Only spells seems to have this issue, weapons anim are working fine


RE: Automatic target when equipping weapons through dclick - XuN - 10-13-2014 10:23 PM

I'll take a look, I have to commit some more code anyways.