Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CanUse extension
Author Message
golfin
Banned

Posts: 213
Likes Given: 2
Likes Received: 32 in 28 posts
Joined: Nov 2017

Eranova

Post: #1
CanUse extension
Hello to everybody.

I'm dealing with the CanUse problem. I'm trying to extend this definition to other career options - That means for a warrior, ranger, sorcerer, alchemist, and thief. The question is, can it be done? I could use a selection based on typedef (t_armor, t_weapon, etc.), but that is not enough. I need a separate feature for each item. And the definition of CanUse seemed to me to be appropriate for this. I have some script that works well for basic subjects. But once I add, for example, can_u_warrior to an object that only Elf can wear, the entire CanUse stops working. It does not write any system message and does not assign the subject to anyone. Here is a sample of the script I've compiled. It is built into [TYPEDEF t_equipitem] in sphere_item_typedef_equipitem.scp. The ToolTip also does not work even though I edited the cliloc.enu file and assembled the upper script sample for the ON = @ ClientToolTip.
Code:
[TYPEDEF t_equipitem]
ON=@ClientToolTip
//IF ((<DISPID>!=<BASEID>) || (<DISPIDDEC>>16381))
//   ADDCLILOC 1042971,<NAME>
//ELSE
//   ADDCLILOC <EVAL 1020000+<DISPIDDEC>>
//ENDIF
SRC.ADDCLILOC 1042971,<NAME>
IF !(<ATTR> & attr_identified)
    SRC.ADDCLILOC 1041522,<def.BFONT_RED>,#1038000,<def.BFONT_WHITE>
ENDIF
IF (<TYPE>==t_wand)
    IF (<MOREX> > 0) && (<MOREX> <= 64)
        LOCAL.SpellCliloc=<EVAL 3002010+<MOREX>>
        SRC.ADDCLILOC <dLOCAL.SpellCliloc>,<dMORE2>
    ENDIF
    SRC.ADDCLILOC 1060741,<dMORE2>
ENDIF
IF (<Rarity>)
    SRC.ADDCLILOC 1061078,<INSTANCES>//"Artifact rarity: ~"
ENDIF
IF (<canuse>&can_u_gargoyle) && !((<canuse>&can_u_human) || (<canuse>&can_u_elf))
    SRC.ADDCLILOC 1111709//"Gargoyles Only"
ENDIF
IF (<canuse> &can_u_elf) && !((<canuse>&can_u_human) || (<canuse>&can_u_gargoyle))
    SRC.ADDCLILOC 1075086
ENDIF
//////////////Start editing
IF (<canuse> &can_u_warrior) && !((<canuse>&can_u_ranger) || (<canuse>&can_u_sorcerer) || (<canuse>&can_u_alchemyst) || (<canuse>&can_u_thiev))
    SRC.ADDCLILOC 1030829
ENDIF
IF (<canuse> &can_u_ranger) && !((<canuse>&can_u_warrior) || (<canuse>&can_u_sorcerer) || (<canuse>&can_u_alchemyst) || (<canuse>&can_u_thiev))
    SRC.ADDCLILOC 1030830
ENDIF
IF (<canuse> &can_u_sorcerer) && !((<canuse>&can_u_ranger) || (<canuse>&can_u_warrior) || (<canuse>&can_u_alchemyst) || (<canuse>&can_u_thiev))
    SRC.ADDCLILOC 1030831
ENDIF
IF (<canuse> &can_u_alchemyst) && !((<canuse>&can_u_ranger) || (<canuse>&can_u_sorcerer) || (<canuse>&can_u_warrior) || (<canuse>&can_u_thiev))
    SRC.ADDCLILOC 1030832
ENDIF
IF (<canuse> &can_u_thiev) && !((<canuse>&can_u_ranger) || (<canuse>&can_u_sorcerer) || (<canuse>&can_u_alchemyst) || (<canuse>&can_u_warrior))
    SRC.ADDCLILOC 1030833
ENDIF
//////////////End editing

Code:
ON=@EquipTest
IF (<CanUse>&can_u_none)
    RETURN 1
ELSEIF (<CanUse>&can_u_all)
    return 0
ENDIF
IF (<SRC.IsPlayer>)
    IF (<CanUse>&can_u_gargoyle)
        IF !(<SRC.f_isgarg>)
            SRC.SYSMESSAGELOC color_text,1111707                            
            RETURN 1
        ENDIF
    ELSEIF !(<CanUse>&can_u_all)
        IF (<SRC.f_isgarg>)
            SRC.SYSMESSAGELOC color_text,1111708                            
            RETURN 1
        ENDIF
    ENDIF
    //return 0
    IF ( (<CanUse>&can_u_female) && !(<CanUse>&can_u_male) )         
        IF !(<SRC.f_isfemale>)                                                    
            SRC.SYSMESSAGELOC color_text,1010388                            
            RETURN 1
        ENDIF
    ELSEIF ( (<CanUse>&can_u_male) && !(<CanUse>&can_u_female) )    
        IF (<SRC.f_isfemale>)                                                    
            SRC.SYSMESSAGELOC color_text,1063343                            
            RETURN 1
        ENDIF
    ENDIF
//////////////Start editing
    IF ( ( (<CanUse>&can_u_human) && !(<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && (<src.f_IsElf>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )
        SRC.SYSMESSAGELOC color_text,1071936                                
        RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )    
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) )
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
    ELSEIF ( ( (<CanUse>&can_u_thiev) && (<src.IsThiev>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) && !( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_warrior) && (<src.IsWarior>) ) && !( (<CanUse>&can_u_ranger) && (<src.IsRanger>) ) && !( (<CanUse>&can_u_sorcerer) && (<src.IsSorcerer>) ) && !( (<CanUse>&can_u_alchemyst) && (<src.IsAlchemyst>) ) )
            SRC.SYSMESSAGELOC color_text,1072203                            
            RETURN 1
        ENDIF
    ENDIF
ENDIF
//////////////End editing

Why am I doing this? I want an elf warrior, for example, to wear all the armor, but Ranger no longer. The Ranger could not wear platemail. And, for example, Dwarf alchemyst to wear only leather armor. I need the objects to be adjusted according to race, by profession, and then to make an exception to an object - For a sorcerer, a magical platemail to wear it. This is just an example.
(This post was last modified: 10-23-2018 03:12 AM by golfin.)
10-23-2018 03:01 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #2
RE: CanUse extension
Did you add the values for can_u_warrior, can_u_sorcerer and so on in the sphere_defs.scp (can_use flag section)?
10-23-2018 06:12 PM
Find all posts by this user Like Post Quote this message in a reply
golfin
Banned

Posts: 213
Likes Given: 2
Likes Received: 32 in 28 posts
Joined: Nov 2017

Eranova

Post: #3
RE: CanUse extension
Yes, they are added as well as function iswarrior, isranger, issorcerer, isalchemyst and isthiev.

Code:
[DEFNAME canuse_flags]
can_u_all            0
can_u_male            01
can_u_female        02
can_u_human            04
can_u_elf            08
can_u_gargoyle        010
can_u_none            020
can_u_warrior        040
can_u_ranger        060
can_u_sorcerer        080
can_u_alchemyst    100
can_u_thiev            200
Code:
[function IsWarior]
IF ( (<SKILLCLASS>==Class_Warrior) )
   RETURN 1
ENDIF
RETURN 0

[function IsRanger]
IF ( (<SKILLCLASS>==Class_Ranger) )
   RETURN 1
ENDIF
RETURN 0

[function IsSorcerer]
IF ( (<SKILLCLASS>==Class_Sorcerer) )
   RETURN 1
ENDIF
RETURN 0

[function IsAlchemyst]
IF ( (<SKILLCLASS>==Class_Alchemyst) )
   RETURN 1
ENDIF
RETURN 0

[Function IsThiev]
IF ( (<SKILLCLASS>==Class_Thiev) )
   RETURN 1
ENDIF
RETURN 0
(This post was last modified: 10-23-2018 06:58 PM by golfin.)
10-23-2018 06:55 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
darksun84
Sir Spamalot
****

Posts: 1,687
Likes Given: 246
Likes Received: 162 in 151 posts
Joined: Mar 2012
Reputation: 35



Post: #4
RE: CanUse extension
can_u_alchemyst 100
can_u_thiev 200

This two values needs a 0 in front of them (0100 and 0200), also i don't remember if the bitmask needs to be the same length.
(0001, 0002, 0004,0008 and so on)
10-23-2018 08:30 PM
Find all posts by this user Like Post Quote this message in a reply
golfin
Banned

Posts: 213
Likes Given: 2
Likes Received: 32 in 28 posts
Joined: Nov 2017

Eranova

Post: #5
RE: CanUse extension
I tried both variants, added zero to the flag number, and the second version with the same bitmask length and it still does not work.



So I thought. The original script is written into three groups (Gargoyles, male / female and human / elf). So I thought, remodeling it. Man - warrior, human - ranger, etc
Elf - warrior, elf - ranger, etc
gargoyle - warrior, gargoyle - ranger, etc

Etc by race. and also include a man / woman
(This post was last modified: 10-23-2018 10:52 PM by golfin.)
10-23-2018 09:14 PM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
golfin
Banned

Posts: 213
Likes Given: 2
Likes Received: 32 in 28 posts
Joined: Nov 2017

Eranova

Post: #6
RE: CanUse extension
For about 10 days, I've tried different ways to write this CanUse flag. It was not without success, but it was not what I wanted. So I resolved it differently. I use the ON=@EquipTest trigger directly on the subject. Can I keep the CanUse flag for the race. To enter a job, I placed the code directly to the subject using the function. See the following example. But you need to delete everything around CanUse in sphere_item_typedef_equipitem.scp and put it to the subject. TEVENTS=t_equipitem must be commented.

Code:
[ITEMDEF i_helm_swiftness]
ID=i_helm_winged
NAME=Helm of Swiftness
CanUse=can_u_elf
BonusInt=5
FasterCasting=1
FasterCastRecovery=2
RESPHYSICAL=6
RESFIRE=5
RESCOLD=6
RESPOISON=6
RESENERGY=8
MageArmor=1
//TEVENTS=t_equipitem
CATEGORY=Artifacts
SUBSECTION=Minor Artifacts
DESCRIPTION=Helm of Swiftness
ON=@Create
   COLOR=0592
   ATTR=attr_magic|attr_identified
   HITPOINTS=255

ON=@EquipTest
    IF ( ( (<CanUse>&can_u_elf) && !(<SRC.f_iself>) ) && !( (<CanUse>&can_u_human) && (<src.f_IsHuman>) ) )        
        IF <SRC.IsUndeclared>
            SRC.SYSMESSAGELOC color_text,1070722,<def.can_use_warrior>
            RETURN 1
        ELSEIF <SRC.IsRanger>
            SRC.SYSMESSAGELOC color_text,1070722,<def.can_use_warrior>
            RETURN 1
        ELSEIF <SRC.IsSorcerer>
            SRC.SYSMESSAGELOC color_text,1070722,<def.can_use_warrior>
            RETURN 1
        ELSEIF <SRC.IsAlchemyst>
            SRC.SYSMESSAGELOC color_text,1070722,<def.can_use_warrior>
            RETURN 1
        ELSEIF <SRC.IsThiev>
            SRC.SYSMESSAGELOC color_text,1070722,<def.can_use_warrior>
            RETURN 1
        ENDIF
    ENDIF
    
ON=@ClientToolTip
IF (<canuse> &can_u_elf) && !((<canuse>&can_u_human) || (<canuse>&can_u_gargoyle))
    SRC.ADDCLILOC 1075086
ENDIF
    src.addcliloc=1070722,<def.only_warrior>

This works smoothly as I wanted to * Smile *
Even though, I will have multiple rows in scripts.

Well, I thought, I will try to create [TYPEDEF t_equipitem] for all jobs separately. [TYPEDEF t_equipitem_warrior], [TYPEDEF t_equipitem_ranger] and so on ... It will come out * smile *


Yes and it works well as a separate typedef, heurekaa
(This post was last modified: 10-25-2018 05:06 AM by golfin.)
10-25-2018 04:35 AM
Visit this user's website Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)