SphereCommunity
typedef question - Printable Version

+- SphereCommunity (https://forum.spherecommunity.net)
+-- Forum: Sphere 0.56d (/Forum-Sphere-0-56d)
+--- Forum: Script Help (/Forum-Script-Help)
+--- Thread: typedef question (/Thread-typedef-question)

Pages: 1 2


RE: typedef question - Shaklaban - 09-03-2012 10:00 PM

you can check wiki for that:

http://wiki.sphere.torfo.org/index.php/Chapter_7#FOR


RE: typedef question - Mordaunt - 09-04-2012 03:37 AM

layer


RE: typedef question - daedelus - 09-05-2012 08:15 AM

(09-01-2012 05:48 AM)Extreme Wrote:  
PHP Code:
ON=@ITEMEQUIPTEST
IF STRMATCH(*T_BOW*,<ACT.TYPE>)
 IF 
STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_GLOVES.TYPE>)
  
SRC.FINDLAYER.LAYER_GLOVES.UNEQUIP
 
ENDIF
 IF 
STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_ARMS.TYPE>)
  
SRC.FINDLAYER.LAYER_ARMS.UNEQUIP
 
ENDIF
ENDIF
IF 
STRMATCH(*T_PLATE*,<ACT.TYPE>) && ((<ACT.LAYER> == LAYER_ARMS) || (<ACT.LAYER> == LAYER_GLOVES))
 IF 
STRMATCH(*T_BOW*,<SRC.FINDLAYER.2.TYPE>)
  
SRC.FINDLAYER.2.UNEQUIP
 
ENDIF
ENDIF 

19:14:ERROR:(sphere_item_provisions_armor_color.scp,26)Can't resolve <ACT.TYPE>
19:14:ERROR:(sphere_item_provisions_armor_color.scp,34)Can't resolve <ACT.TYPE>
19:14:ERROR:(sphere_item_provisions_armor_color.scp,34)Can't resolve <ACT.LAYER>
19:14:ERROR:(sphere_item_provisions_armor_color.scp,34)Can't resolve <ACT.LAYER>
19:14:ERROR:(sphere_item_provisions_armor_color.scp,34)Undefined symbol ''
19:14:ERROR:(sphere_item_provisions_armor_color.scp,34)Undefined symbol ''

I try yo fix them, but i can't xD.

Thanks


RE: typedef question - RanXerox - 09-05-2012 08:52 AM

Tip of the Day: Write out the logic first using comments, then fill in the actual code...

For example, this:

Code:
ON=@ITEMEQUIPTEST
//Is the player equipping a bow?
   //Player wants to equip a bow, first check if they are wearing gloves
      //They are wearing gloves... but what kind?
         //They are plate, so unequip them
   //Are they wearing arms?
      //They are wearing arms... but what kind?
         //They are plate, so unequip them
//Is the player equipping arms or gloves made of plate?
   //The player wants to equip plate arms or gloves, so check if they have a weapon in their second hand
      //They do have an item in their second hand... is it a bow?
         //They are wielding a bow, so unequip it

...eventually becomes this:

Code:
ON=@ITEMEQUIPTEST
//Is the player equipping a bow?
IF STRMATCH(*T_BOW*,<ACT.TYPE>)
   //Player wants to equip a bow, first check if they are wearing gloves
   IF (<SRC.FINDLAYER.LAYER_GLOVES>)
      //They are wearing gloves... but what kind?
      IF STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_GLOVES.TYPE>)
         //They are plate, so unequip them
         SRC.FINDLAYER.LAYER_GLOVES.UNEQUIP
      ENDIF
   ENDIF
   //Are they wearing arms?
   IF (<SRC.FINDLAYER.LAYER_ARMS>)
      //They are wearing arms... but what kind?
      IF STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_ARMS.TYPE>)
         //They are plate, so unequip them
         SRC.FINDLAYER.LAYER_ARMS.UNEQUIP
      ENDIF
   ENDIF
ENDIF
//Is the player equipping arms or gloves made of plate?
IF ((<ACT.LAYER> == LAYER_ARMS) || (<ACT.LAYER> == LAYER_GLOVES)) && (STRMATCH(*T_PLATE*,<ACT.TYPE>))
   //The player wants to equip plate arms or gloves, so check if they have a weapon in their second hand
   IF (<SRC.FINDLAYER.LAYER_HAND2>)
      //They do have an item in their second hand... is it a bow?
      IF STRMATCH(*T_BOW*,<SRC.FINDLAYER.2.TYPE>)
         //They are wielding a bow, so unequip it
         SRC.FINDLAYER.2.UNEQUIP
      ENDIF
   ENDIF
ENDIF



RE: typedef question - daedelus - 09-05-2012 09:27 AM

Ok, but how i can define de t_plate

Code:
[typedef t_plate]
IF (<SRC.FINDLAYER.LAYER_GLOVES.BASEID> = I<ARGV[0]>_PLATEMAIL_GLOVES) || (<SRC.FINDLAYER.LAYER_ARMS.BASEID> = I<ARGV[0]>_PLATEMAIL_ARMS)

i try and try and try but nothing Sad i'm feeling stupid...

thanks


RE: typedef question - RanXerox - 09-05-2012 09:41 AM

Ahhh I thought you got that sorted out already.

There doesn't need to be any code in the typedef... just declare it, then apply it to the items you want to have it like this:

Code:
[ITEMDEF 01410]
DEFNAME=i_platemail_arms
TYPE=t_armor
FLIP=1
WEIGHT=5
REQSTR=80
RESOURCES=18 i_ingot_iron
SKILLMAKE=Blacksmithing 66.3
CATEGORY=Provisions - Armor - Blacksmithing
SUBSECTION=Platemail Armor
DESCRIPTION=Platemail Arms
TAG.Penalty.Meditation=1
TAG.Penalty.Stealth=10
TAG.ResPhysical=5
TAG.ResFire=3
TAG.ResCold=2
TAG.ResPoison=3
TAG.ResEnergy=2
DUPELIST=01417
TEVENTS=t_plate
ON=@Create
   COLOR=color_o_iron
   HITPOINTS={36 48}

...although your code might need to change to check TEVENTS instead of TYPE.

Another way to accomplish the result is using an item TAG (if you put the TAG above the @create then all items of that type already in game will have it.)


RE: typedef question - daedelus - 09-05-2012 12:32 PM

Code:
[FUNCTION F_DESEQUIPAR]
ON=@ITEMEQUIPTEST
//Is the player equipping a bow?
IF STRMATCH(*T_BOW*,<ACT.TYPE>)
   //Player wants to equip a bow, first check if they are wearing gloves
   IF (<SRC.FINDLAYER.LAYER_GLOVES>)
      //They are wearing gloves... but what kind?
      IF STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_GLOVES.TYPE>)
         //They are plate, so unequip them
         SRC.FINDLAYER.LAYER_GLOVES.UNEQUIP
      ENDIF
   ENDIF
   //Are they wearing arms?
   IF (<SRC.FINDLAYER.LAYER_ARMS>)
      //They are wearing arms... but what kind?
      IF STRMATCH(*T_PLATE*,<SRC.FINDLAYER.LAYER_ARMS.TYPE>)
         //They are plate, so unequip them
         SRC.FINDLAYER.LAYER_ARMS.UNEQUIP
      ENDIF
   ENDIF
ENDIF
//Is the player equipping arms or gloves made of plate?
IF ((<ACT.LAYER> == LAYER_ARMS) || (<ACT.LAYER> == LAYER_GLOVES)) && (STRMATCH(*T_PLATE*,<ACT.TYPE>))
   //The player wants to equip plate arms or gloves, so check if they have a weapon in their second hand
   IF (<SRC.FINDLAYER.LAYER_HAND2>)
      //They do have an item in their second hand... is it a bow?
      IF STRMATCH(*T_BOW*,<SRC.FINDLAYER.2.TYPE>)
         //They are wielding a bow, so unequip it
         SRC.FINDLAYER.2.UNEQUIP
      ENDIF
   ENDIF
ENDIF
[/quote]

On item :
TEVENTS=t_type

ON=@create
blablalba

ON=@equip
call f_desequipar

And do nothing Confused and don't give me errors. Sorry men, i don't understand.


RE: typedef question - RanXerox - 09-05-2012 12:48 PM

You cannot put triggers in a function.


RE: typedef question - daedelus - 09-05-2012 10:05 PM

(09-05-2012 12:48 PM)RanXerox Wrote:  You cannot put triggers in a function.

good point Smile at night i try.


thanks