The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My Shrink Potion
Author Message
sub-zero
Apprentice
*

Posts: 5
Likes Given: 0
Likes Received: 3 in 2 posts
Joined: Sep 2012
Reputation: 0



Post: #1
My Shrink Potion
VERSION=0.56c

[ITEMDEF i_shrink_potion]
ID=i_bottle_white
NAME=shrink potion
TYPE=t_potion
TDATA1=i_bottle_empty
RESOURCES=2 i_reag_batwing,1 i_bottle_empty
SKILLMAKE=ALCHEMY 100.0, t_mortar

ON=@CREATE
MORE1=s_shrink
MORE2=100.0
COLOR=color_gray_lt

ON=@DROPON_CHAR
REF1=<ARGO>
IF (<REF1.DISTANCE> > 2)
SRC.SMSGL=-1,500446 // That is too far away.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_CONJURED)
SRC.SMSG=@03B2,0,1 You cannot shrink summoned creatures.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_WAR)
SRC.SMSG=@03B2,0,1 You cannot shrink your pet while it is in combat.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_ONHORSE)
SRC.SMSGL=-1,1040016 // You cannot use this while riding a mount
RETURN 1
ENDIF
IF (<REF1.ISPLAYER>)
SRC.SMSGL=-1,500329 // That's not an animal!
RETURN 1
ENDIF
IF (!<REF1.ISMYPET>)
SRC.SMSGL=-1,502676 // That's not your pet!
RETURN 1
ENDIF
IF (((<REF1.BASEID> = c_horse_pack) || (<REF1.BASEID> = c_llama_pack)) && (<REF1.FINDLAYER.LAYER_PACK.FCOUNT> > 0))
SRC.SMSGL=-1,1042563 // You need to unload your pet.
RETURN 1
ENDIF
REF1.SHRINK
IF (<AMOUNT> > 1)
AMOUNT -= 1
ELSE
REMOVE
ENDIF
RETURN 1

ON=@DCLICK
IF (<TOPOBJ.UID> != <SRC>)
SRC.SMSGL=-1,1116249 // That must be in your backpack for you to use it.
RETURN 1
ENDIF
TARGET=@03B2,0,1 What do you wish to shrink?
RETURN 1

ON=@TARGON_CHAR
REF1=<SRC.TARG.UID>
IF (<REF1.DISTANCE> > 2)
SRC.SMSGL=-1,500446 // That is too far away.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_CONJURED)
SRC.SMSG=@03B2,0,1 You cannot shrink summoned creatures.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_WAR)
SRC.SMSG=@03B2,0,1 You cannot shrink your pet while it is in combat.
RETURN 1
ENDIF
IF (<REF1.FLAGS> & STATF_ONHORSE)
SRC.SMSGL=-1,1040016 // You cannot use this while riding a mount
RETURN 1
ENDIF
IF (<REF1.ISPLAYER>)
SRC.SMSGL=-1,500329 // That's not an animal!
RETURN 1
ENDIF
IF (!<REF1.ISMYPET>)
SRC.SMSGL=-1,502676 // That's not your pet!
RETURN 1
ENDIF
IF (((<REF1.BASEID> = C_HORSE_PACK) || (<REF1.BASEID> = C_LLAMA_PACK)) && (<REF1.FINDLAYER.LAYER_PACK.FCOUNT> > 0))
SRC.SMSGL=-1,1042563 // You need to unload your pet.
RETURN 1
ENDIF
REF1.SHRINK
IF (<AMOUNT> > 1)
AMOUNT -= 1
ELSE
REMOVE
ENDIF
RETURN 1

ON=@TARGON_ITEM
SRC.SMSGL=-1,500329 // That's not an animal!
RETURN 1

[EOF]

any suggestion will be welcome


Attached File(s)
.scp  shrink_potion.scp (Size: 2.41 KB / Downloads: 4)
01-24-2015 02:52 PM
Find all posts by this user Like Post Quote this message in a reply
[+] 2 users Like sub-zero's post
XuN
Sphere Developer
*****

Posts: 852
Likes Given: 102
Likes Received: 156 in 119 posts
Joined: Jul 2013
Reputation: 30



Post: #2
RE: My Shrink Potion
Just a tip, to improve it using less code and creating in the proccess a function that you can use in another situations:

Instead of calling the same code twice in both triggers you can create a function with all your checks:

Code:
ON=@TARGON_CHAR
SRC.TARG.f_shrink
IF (<AMOUNT> > 1)
    AMOUNT -= 1
ELSE
    REMOVE
ENDIF
RETURN 1

ON=@DROPON_CHAR
ARGO.f_shrink
IF (<AMOUNT> > 1)
    AMOUNT -= 1
ELSE
    REMOVE
ENDIF
RETURN 1


[function f_shrink]
IF (<DISTANCE> > 2)
    SRC.SMSGL=-1,500446 // That is too far away.
    RETURN 1
ENDIF
IF (<FLAGS> & STATF_CONJURED)
    SRC.SMSG=@03B2,0,1 You cannot shrink summoned creatures.
    RETURN 1
ENDIF
IF (<FLAGS> & STATF_WAR)
    SRC.SMSG=@03B2,0,1 You cannot shrink your pet while it is in combat.
    RETURN 1
ENDIF
IF (<FLAGS> & STATF_ONHORSE)
    SRC.SMSGL=-1,1040016 // You cannot use this while riding a mount
    RETURN 1
ENDIF
IF (<ISPLAYER>)
    SRC.SMSGL=-1,500329 // That's not an animal!
    RETURN 1
ENDIF
IF (!<ISMYPET>)
    SRC.SMSGL=-1,502676 // That's not your pet!
    RETURN 1
ENDIF
IF (((<BASEID> = C_HORSE_PACK) || (<BASEID> = C_LLAMA_PACK)) && (<FINDLAYER.LAYER_PACK.FCOUNT> > 0))
    SRC.SMSGL=-1,1042563 // You need to unload your pet.
    RETURN 1
ENDIF
SHRINK 1 // shrink will create the figurine in the char's position, shrink 1 will bounce it automatically

So this way the function is being called on both triggers and you can call it via script whenever you need it with a simple x.f_shrink or trysrc <whoever> x.f_shrink, etc.
01-25-2015 01:17 AM
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)