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:
  • 1 Votes - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripting items, take 2
Author Message
Stephka
Apprentice
*

Posts: 8
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Oct 2012
Reputation: 2



Post: #1
Scripting items, take 2
Hi again all of you!
It's me again, and now I'm trying to script more complicated items.

I want to script poisons and such for alchemy. Say I want to script a poison named Nightshade,with one charge, which upon consumption gets the player to be more intelligent, but he must take it every 72 hours or suffer a -15 penalty in Dex, Str and Int for 96 hours (withdrawal time).
How do I do that?

[ITEMDEF i_nightshade]
NAME= Nightshade
ID=0EFB
TYPE=t_normal
VALUE=0
WEIGHT=1
CHARGE=1
RESOURCES=1 i_blue_flower, 1 i_empty_bottle, 1 i_ash
SKILLMAKE=ALCHEMY 60.0
CATEGORY=TdF
SUBSECTION=Drug
DESCRIPTION=Nightshade

ON=@Create
MORE1=s_Cunning


What is missing for it to be functionnal?

Thank you all so much for bearing with my inexperience!
10-30-2012 04:38 AM
Find all posts by this user Like Post Quote this message in a reply
Barnabus
Journeyman
*

Posts: 124
Likes Given: 0
Likes Received: 3 in 2 posts
Joined: Apr 2012
Reputation: 1



Post: #2
RE: Scripting items, take 2
Hi the spherewiki should be a great help to you with item creation.
Though just to help, if you were creating a posion first it must be in a bottle or have the id of a bottle I assume thats what 0efb is ? the type I guess must be T_Potion thats something you dclick and apparently drink, unlike t_normal which kind of declares a custom script. Though you can use any type there or make your own to suit. A value of 0 should be considered because if you add these to your vendor NPCS to sell at any point, they are a bit cheap !
The resourses are fine but were is the nightshade. LOL @ the withdrawal time thats funny.

PHP Code:
[DEFNAME potionControlPanel]
color_poison_nightshade   63 
PHP Code:
[ITEMDEF i_potion_nightShade]
DEFNAME=i_potion_nightShade
NAME
=Nightshade Poison
ID
=i_bottle_GREEN
WEIGHT
=1
TYPE
=t_potion_nightshade
TDATA1
=i_bottle_empty
RESOURCES
=i_reag_nightshade 3i_bottle_EMPTY
SKILLMAKE
=ALCHEMY 100.0

ON
=@Create
    COLOR
=color_poison_nightshade 

PHP Code:
[TYPEDEF t_potion_nightshade]
ON=@DCLICK
    
IF (<SRC.FINDID.i_potiondelay>)
        
SRC.SYSMESSAGE @00023,,1 You can't use another potion yet.
        RETURN 1
    ELSE
        NEWITEM i_potiondelay, 1, <SRC.UID>
        NEWITEM i_potionNightshadeAddiction, 1, <SRC.UID>
        RETURN 0
    ENDIF 

PHP Code:
[ITEMDEF i_potiondelay]
ID=i_bottle_empty
TYPE
=t_eq_script
WEIGHT
=0
LAYER
=layer_special

ON
=@CREATE
    ATTR
=attr_invis|attr_decay
    TIMER
=7

ON
=@EQUIP
    TIMER
=7    

ON
=@TIMER
    REMOVE
    
RETURN 

Then all you would have to deal with is the i_potionNightshadeAddiction memory. First we will add your variables to the control.

PHP Code:
[DEFNAME potionControlPanel]
color_potion_nightshade   63
nightshade_int_Increase   10
nightshade_dose_timeout  72
nightshade_withdrawl_time 96
nightshade_withdrawl_penalty 15 

Before your write the memory that will control the effect on the player you need to consider your time format its in hours so we could use a function to convert that to seconds-ish
PHP Code:
[FUNCTION f_convertHoursSecs]
RETURN <EVAL <
ARGV[0]> * 60 60
now when i want to use the value from the control to compare with the server time
i write <EVAL <f_convertHoursSecs <nightshade_withdrawl_time>>>
Finally the Memory
PHP Code:
[ITEMDEF i_nightShadeEffect]
DEFNAME=nightShadeEffect
ID
=i_flesh_brain
TYPE
=t_eq_script
NAME
=Nightshade Effect
layer
=layer_special

ON
=@CREATE
      ATTR
=attr_newbie|attr_decay|attr_move_never
      TIMER
=1
      
ON
=@TIMER
IF !<CONT.TAG0.NightShadeTimer> && !<CONT.TAG0.NightShadeWithdrawlTimer>
    
// They wont have either on first effect so give the dose timer and the effect here
    
CONT.TAG.NightShadeTimer=<EVAL <f_convertHoursSecs <nightshade_dose_timeout>>>
    
f_doNightShadeEffectOnTarget <CONT.UID>
    
ELIF <CONT.TAG.NightShadeTimer> && !<CONT.TAG0.NightShadeWithdrawlTimer>
    
// If they have the effect active just count the timer up one
    
CONT.TAG.NightShadeTimer --
    IF <EVAL <
CONT.TAG.NightShadeTimer>> < 1
        CONT
.TAG.NightShadeTimer=
        
CONT.TAG.NightShadeWithdrawlTimer=<EVAL <f_convertHoursSecs <nightshade_withdrawl_time>>>
        
f_doNightShadeWithdrawl <CONT.UID>
    ENDIF
ELSE
    IF <
CONT.TAG0.NightShadeWithdrawlTimer>
        
// If they are in withdrawel they wont have the effect,
        // The effect should have been removed by here
        // The peanlity already applied before here 
        // Just count the withdrawl Down.
        
CONT.TAG.NightShadeWithdrawlTimer --
        IF <EVAL <
CONT.TAG.NightShadeWithdrawlTimer>> < 1
            f_removeNightShadeWithdrawl 
<CONT.UID>
            
CONT.TAG.NightShadeTimer=
            
REMOVE
            
RETURN 1
        
ENDIF
    ENDIF
ENDIF

TIMER=1
RETURN 

^^ thats got to have errors in it but you should see whats supposed to happen.

finally the functions

f_doNightShadeEffect
f_removeNightShadeEffect
f_doNightShadeWithdrawl
f_removeNightShadeWithdrawl

PHP Code:
[FUNCTION f_doNightShadeEffect]
REF1=<SERV.UID.<ARGV[0]>>
REF1.INT = <EVAL <REF1.INT> +  nightshade_int_Increase >

[FUNCTION 
f_removeNightShadeEffect]
REF1=<SERV.UID.<ARGV[0]>>
REF1.INT = <EVAL <REF1.INT> -  nightshade_int_Increase >

[FUNCTION 
f_doNightShadeWithdrawl]
REF1=<SERV.UID.<ARGV[0]>>
REF1.INT = <EVAL <REF1.INT> -  nightshade_withdrawl_penalty >
REF1.DEX= <EVAL <REF1.DEX> -  nightshade_withdrawl_penalty >
REF1.STR= <EVAL <REF1.STR> -  nightshade_withdrawl_penalty >

[FUNCTION 
f_removeNightShadeWithdrawl]
REF1=<SERV.UID.<ARGV[0]>>
REF1.INT = <EVAL <REF1.INT> + nightshade_withdrawl_penalty >
REF1.DEX= <EVAL <REF1.DEX> +  nightshade_withdrawl_penalty >
REF1.STR= <EVAL <REF1.STR> +  nightshade_withdrawl_penalty 

^^ I havnt tested any of that so you might have to fix or rearrange it, but it should give you a good idea of how you could layout and code something like drugs
(This post was last modified: 11-02-2012 05:02 AM by Barnabus.)
11-02-2012 04:53 AM
Find all posts by this user Like Post Quote this message in a reply
Stephka
Apprentice
*

Posts: 8
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Oct 2012
Reputation: 2



Post: #3
RE: Scripting items, take 2
Thank you for your help! That should help me getting started.
11-09-2012 12:17 PM
Find all posts by this user Like Post Quote this message in a reply
Stephka
Apprentice
*

Posts: 8
Likes Given: 0
Likes Received: 1 in 1 posts
Joined: Oct 2012
Reputation: 2



Post: #4
RE: Scripting items, take 2
Well, my first try made my server go boom.

Second try, a wooden wall came out of nowhere.

This is fun! Big Grin
11-09-2012 04:47 PM
Find all posts by this user Like Post Quote this message in a reply
Barnabus
Journeyman
*

Posts: 124
Likes Given: 0
Likes Received: 3 in 2 posts
Joined: Apr 2012
Reputation: 1



Post: #5
RE: Scripting items, take 2
LOL ^^

What did you do ? I would not have tested anything I wrote previously, did you follow my instructions?
If your still stuck with this...

Just post what you have built and I will check over it for you!
11-16-2012 10:59 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


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