Skip to content

Conversation

@MishimaHaruna
Copy link
Member

Pull Request Prelude

Changes Proposed

This PR provides constants to be used with the getiteminfo() and setiteminfo() buildins, to replace the unsafe literal numeric values used in the past (and in fact, there was one case of incorrect value used in a script).

The functions are also extended with support for ITEMINFO_MATK (which was previously documented but never implemented) as well as ITEMINFO_VIEWSPRITE (which was no longer available since #1828 was merged).

This also includes an updated version of the global functions F_GetWeaponType() and F_GetArmorType(), and the new function F_GetAmmoType().

The complete list of replacements for the previously used numeric literals is the following:

    0 => ITEMINFO_BUYPRICE
    1 => ITEMINFO_SELLPRICE
    2 => ITEMINFO_TYPE
    3 => ITEMINFO_MAXCHANCE
    4 => ITEMINFO_SEX
    5 => ITEMINFO_LOC
    6 => ITEMINFO_WEIGHT
    7 => ITEMINFO_ATK
    8 => ITEMINFO_DEF
    9 => ITEMINFO_RANGE
    10 => ITEMINFO_SLOTS
    11 (Subtype, for weapons and ammunitions) => ITEMINFO_SUBTYPE
    11 (ViewSprite, for other item types) => ITEMINFO_VIEWSPRITE
    12 => ITEMINFO_ELV
    13 => ITEMINFO_WLV
    14 => ITEMINFO_VIEWID
    15 => ITEMINFO_MATK (this was documented but not implemented)

Affected Branches:

  • master
  • stable

Issues addressed:

Known Issues and TODO List

N/A

Replacements are as follows:

    0 => ITEMINFO_BUYPRICE
    1 => ITEMINFO_SELLPRICE
    2 => ITEMINFO_TYPE
    3 => ITEMINFO_MAXCHANCE
    4 => ITEMINFO_SEX
    5 => ITEMINFO_LOC
    6 => ITEMINFO_WEIGHT
    7 => ITEMINFO_ATK
    8 => ITEMINFO_DEF
    9 => ITEMINFO_RANGE
    10 => ITEMINFO_SLOTS
    11 (Subtype, for weapons and ammunitions) => ITEMINFO_SUBTYPE
    11 (ViewSprite, for other item types) => ITEMINFO_VIEWSPRITE (NOT AVAILABLE YET)
    12 => ITEMINFO_ELV
    13 => ITEMINFO_WLV
    14 => ITEMINFO_VIEWID
    15 => ITEMINFO_MATK (NOT AVAILABLE YET - this was documented but never implemented)

Calls to getiteminfo() and setiteminfo() have been replaced with the
newly introduced constants. Other constants (such as W_ weapon subtypes)
in related code have been replaced as well, to improve code readability.

This fixes an issue in the Eden Tutorial script "Tutorial Goal", where
ITEMINFO_ATK was accidentally used instead of ITEMINFO_WEIGHT.

Note: calls to getiteminfo or setiteminfo with numeric type arguments in
third party scripts must be replaced with the respective constants. The
use of numeric literals is no longer recommended, and those values may
change in the future without notice. See the getiteminfo documentation
for details.

Signed-off-by: Haru <[email protected]>
This item info type was documented in commit
315d632, but never implemented.

Signed-off-by: Haru <[email protected]>
Adds the ability to query an item's view sprite, lost with HerculesWS#1828

Fixes HerculesWS#1895

Signed-off-by: Haru <[email protected]>
… ammunitions

Both functions have now been updated to only check the subtype if the
item type is correct (IT_AMMO for F_GetAmmoType, IT_WEAPON for
F_GetWeaponType)

Signed-off-by: Haru <[email protected]>
…a bitmask

The function now handles multi-slot headgears and other uncommon cases better.

Signed-off-by: Haru <[email protected]>
@MishimaHaruna MishimaHaruna added component:core:scriptengine Affecting the script engine or the script commands component:scripts Affecting the scripts and NPCs severity:3-medium Issues with GM commands, script commands, and other commonly used features type:bug Issue is a bug or describes an incorrect behavior that should be fixed type:enhancement Issue describes an enhancement or feature that should be implemented labels Nov 12, 2017
@MishimaHaruna MishimaHaruna added this to the Release v2017.11.19 milestone Nov 12, 2017
@ghost ghost assigned MishimaHaruna Nov 12, 2017
@ghost ghost added the status:inprogress Issue is being worked on / the pull request is still a WIP label Nov 12, 2017
@HerculesWSAPI
Copy link
Contributor

This change is Reviewable

@MishimaHaruna MishimaHaruna added status:code-review Awaiting code review and removed status:inprogress Issue is being worked on / the pull request is still a WIP labels Nov 12, 2017
ITEMINFO_RANGE - Range
ITEMINFO_SLOTS - Slots
ITEMINFO_SUBTYPE - Item subtype
ITEMINFO_ELV - Equip min. level
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about equip max level? Maybe we should bring that under this command too.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. I opened a separate ticket, #1906, so that we can merge this PR (since it contains fixes for a regression that already landed in the stable branch)

@MishimaHaruna MishimaHaruna merged commit 7b2f685 into HerculesWS:master Nov 18, 2017
@ghost ghost removed the status:code-review Awaiting code review label Nov 18, 2017
@MishimaHaruna MishimaHaruna deleted the getiteminfo-fix branch November 18, 2017 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

component:core:scriptengine Affecting the script engine or the script commands component:scripts Affecting the scripts and NPCs severity:3-medium Issues with GM commands, script commands, and other commonly used features type:bug Issue is a bug or describes an incorrect behavior that should be fixed type:enhancement Issue describes an enhancement or feature that should be implemented

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants