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
Varskill
Author Message
Crusader
Master
**

Posts: 254
Likes Given: 7
Likes Received: 19 in 12 posts
Joined: Apr 2012
Reputation: 6

Erehwon New Hera

Post: #1
Varskill
Varskill <skillnumber> <value>
is a function to take control over the skills we add to an item or a char.
Code + 2 test items below.
Any suggestions for bugfix, exploit, improving will be really appreciated

Code:
[FUNCTION VARSKILL]
IF !(0<ISCHAR>)
        RETURN 0
ENDIF
OBJ=<UID>
IF (<OBJ.FINDID.i_mem_varskill>)
        REF1=<FINDID.i_mem_varskill>
        IF !(0<REF1.TAG.<eval <ARGN1>>>) // nuova skill, la aggiungo
                REF1.TRIGGER @Unequip
                REF1.TAG0.<eval <ARGN1>> = <EVAL <ARGN2>>
                REF1.TRIGGER @Equip
        ELSE    // trovo la stessa skill e ne sommo i valori
                REF1.TRIGGER @Unequip
                REF1.TAG0.<eval <ARGN1>> = <EVAL <REF1.TAG0.<eval <ARGN1>>> + <ARGN2>>
                REF1.TRIGGER @Equip
                IF (<EVAL <REF1.TAG0.<eval <ARGN1>>>> == 0) // se la somma รจ zero, cioe' sto togliendo probabilmente l'item che visto che aggiungo una skill negativa
                        REF1.MORE1 -= 1
                        REF1.TIMER=5
                ENDIF
        ENDIF
ELSE // nn trovo la memory, equippo per la prima volta
        NEWITEM i_mem_varskill
        NEW.TAG.<eval <ARGN1>> = <eval <ARGN2>>
        NEW.CONT=<UID>
        NEW.TRIGGER @Equip
ENDIF
RETURN 1


[ITEMDEF i_mem_varskill]
ID=i_memory
TYPE=t_eq_script
NAME=Skill

CATEGORY=Erehwon
SUBSECTION=NON TOCCARE
DESCRIPTION=Change Skill

ON=@Create
ATTR=attr_decay

ON=@Equip
local.tagcount = <tagcount> -1
IF <dLOCAL.tagcount> >= 0
FOR 0 <local.tagcount>
        LOCAL.SKILLFOUND=<eval <TAGAT.<LOCAL._FOR>.KEY>>
        LOCAL.SKILLVALUE=<eval <TAGAT.<LOCAL._FOR>.VALUE>>
        TRY CONT.<dLOCAL.SKILLFOUND> = <EVAL <CONT.<dLOCAL.SKILLFOUND>>> + <dLOCAL.SKILLVALUE>
        MORE1 += 1
ENDFOR
ENDIF
RETURN 0

ON=@Unequip
local.tagcount = <tagcount> - 1
IF (<dLOCAL.tagcount> > 0)
        FOR 0 <local.tagcount>
                LOCAL.SKILLFOUND=<eval <TAGAT.<LOCAL._FOR>.KEY>>
                LOCAL.SKILLVALUE=<eval <TAGAT.<LOCAL._FOR>.VALUE>>
                TRY CONT.<dLOCAL.SKILLFOUND> = <EVAL <CONT.<dLOCAL.SKILLFOUND>>> - <dLOCAL.SKILLVALUE>
                MORE1 -= 1
        ENDFOR
ELIF (<dLOCAL.tagcount> == 0)
                LOCAL.SKILLFOUND=<eval <TAGAT.0.KEY>>
                LOCAL.SKILLVALUE=<eval <TAGAT.0.VALUE>>
                TRY CONT.<dLOCAL.SKILLFOUND> = <EVAL <CONT.<dLOCAL.SKILLFOUND>>> - <dLOCAL.SKILLVALUE>
                MORE1 -= 1
ENDIF
RETURN 0

ON=@TIMER
IF (<EVAL <MORE1>> <=0)
REMOVE
ENDIF
RETURN 1

[ITEMDEF i_mazzetta]
ID = i_mace
TYPE = t_weapon_mace_smith
NAME = mazza

ON=@EQUIP
SRC.VARSKILL 30 50
SRC.VARSKILL 31 10
RETURN 0

ON=@UNEQUIP
SRC.VARSKILL 30 -50
SRC.VARSKILL 31 -10
RETURN 0

[ITEMDEF i_armat]
ID = i_platemail_chest
TYPE = t_armor
NAME = armatura

ON=@EQUIP
SRC.VARSKILL 30 50
SRC.VARSKILL 35 10
RETURN 0

ON=@UNEQUIP
SRC.VARSKILL 30 -50
SRC.VARSKILL 35 -10
RETURN 0
02-28-2013 05:24 AM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #2
RE: Varskill
I would make the following suggestions:

- don't use OBJ (OBJ is a global reference and some other script could clobber your reference or you could clobber theirs), use a REFn instead

- when you are checking a TAG in an IF statement, use IF (<TAG0.whatever>) instead of IF (0<TAG.Whatever>)

- instead of using ARGN to get passed-in arguments, use ARGV to see how many there are and ARGV[0] to get the first one and ARGV[1] to get the second one etc...

- I would avoid creating tags that are just numeric... (in your example you are using TAG.<eval <ARGN>> and stuff like that... if gets confusing. Instead use TAG.Skill_<dARGN>

- Since you don't use the LOCAL.tagcount inside the loops, this:

Code:
ON=@Equip
local.tagcount = <tagcount> -1
IF <dLOCAL.tagcount> >= 0
FOR 0 <local.tagcount>
...do stuff
ENDFOR
ENDIF

could be simplified to:

Code:
ON=@Equip
FOR 0 <eval <tagcount> -1>
...do stuff
ENDFOR

I think it would also greatly simplify the @unequip trigger to do that... At a glance I don't understand whats going on though.
02-28-2013 10:01 AM
Find all posts by this user Like Post Quote this message in a reply
Crusader
Master
**

Posts: 254
Likes Given: 7
Likes Received: 19 in 12 posts
Joined: Apr 2012
Reputation: 6

Erehwon New Hera

Post: #3
RE: Varskill
Guess i need to do more explanations about this script:
I need something like modstr/moddes/modint but for skills.
Since there is no such command i was in dire need to create one to address the skillcap problem; How can i check if i'm at the skillcap because of my pure skill of because i dress enhancing skill items? i can undress e redress my char every time i do the check or ...more simply check if the char has a memory (i_mem_varskill) and look at what numeric exists on it.
Every time i add something that raise skill, i create a tag.<skillnumber> on the memory which store the value. (that's why the numeric tag) in fact when i check i do:

Code:
[FUNCTION CHECKMEMSKILL]
// IN: skill number OUT: value if found, -99 if it doesn't | or IN: negative value OUT: Skills & values
IF !(<SRC.FINDID.i_mem_varskill>)
    RETURN -1
ELSE
    REF1 = <SRC.FINDID.i_mem_varskill>
    IF (<dARGN> < 0)
        LOCAL.TAGSKILLCOUNT=<REF1.TAGCOUNT>
        LOCAL.TAGCOUNT = <LOCAL.TAGSKILLCOUNT> - 1
        FOR 0 <LOCAL.TAGCOUNT>
            LOCAL.SKILLFOUND=<eval <REF1.TAGAT.<LOCAL._FOR>.KEY>>
            LOCAL.SKILLVALUE=<eval <REF1.TAGAT.<LOCAL._FOR>.VALUE>>
            RETURN <dLOCAL.SKILLFOUND>,<dLOCAL.SKILLVALUE>
        ENDFOR
    ELSE
        IF (0<REF1.TAG.<EVAL <ARGN>>>)
            RETURN <EVAL <REF1.TAG0.<EVAL <ARGN>>>>
        ELSE
            RETURN -99
        ENDIF
    ENDIF
ENDIF


Now...the problems:

Quote:- don't use OBJ (OBJ is a global reference and some other script could clobber your reference or you could clobber theirs), use a REFn instead

Done Big Grin
Quote:- when you are checking a TAG in an IF statement, use IF (<TAG0.whatever>) instead of IF (0<TAG.Whatever>)
I can't. If i use the other way i would get error in console -_-

Quote:- instead of using ARGN to get passed-in arguments, use ARGV to see how many there are and ARGV[0] to get the first one and ARGV[1] to get the second one etc...

ok, i'm gonna changing it, but i just take numbers, since is the only thing i'm working with (skill numbers) maybe i will put a def for the skills in order to use also skill names.

Quote:- I would avoid creating tags that are just numeric... (in your example you are using TAG.<eval <ARGN>> and stuff like that... if gets confusing. Instead use TAG.Skill_<dARGN>

I can't do that, for the reason i told u..otherwise i have to put a STREAT everytime i want to TRY the tags, so i guess it will slow down the process or just make it less efficient.

Quote:- Since you don't use the LOCAL.tagcount inside the loops, this:
ok, done Big Grin

__

Now, lil/big problems:

when i do checkmemskill 0 or checkmemskill and i use
IF <ARGN> or ARGS or whatever, for sphere is the same, but i need to check the difference (since, if i do checkmemskill 0, i'm gonna check if there is a Tag of alchemy in the mem of the player, while if i do checkmemskill, i'm gonna retrieve all the skill tags and values of the player)

so i had to put argn > 0 and use a negative value to check all the tags... seriously?


plus now i find some bugs while adding items with totally different skills coz when i unequip the first item the mem is also, getting char to lose skill points when he unequip the second item.

(ofc, since u are a dev now, if u plan to do a modskill command, all this shit will be useless and i'll very happy to trash it Big Grin )
(This post was last modified: 02-28-2013 06:34 PM by Crusader.)
02-28-2013 06:14 PM
Find all posts by this user Like Post Quote this message in a reply
RanXerox
Master
**

Posts: 550
Likes Given: 1
Likes Received: 12 in 9 posts
Joined: Dec 2010
Reputation: 19



Post: #4
RE: Varskill
To see if the function was passed an argument (even when the argument value is a zero), use IF (<ARGV>)
03-01-2013 01:44 AM
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)