From a189181f004d76fb29ee04c242de8883725fdd2f Mon Sep 17 00:00:00 2001 From: John S Hobart Date: Fri, 9 Jul 2021 21:27:49 -0400 Subject: [PATCH 1/3] add pet library --- libraries/pet/README.md | 67 ++++++++++++++++++++++++++++++++++++++ libraries/pet/manifest.xml | 11 +++++++ libraries/pet/pet.lua | 52 +++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100644 libraries/pet/README.md create mode 100644 libraries/pet/manifest.xml create mode 100644 libraries/pet/pet.lua diff --git a/libraries/pet/README.md b/libraries/pet/README.md new file mode 100644 index 00000000..75efef2e --- /dev/null +++ b/libraries/pet/README.md @@ -0,0 +1,67 @@ +# Pet + +Provides information about the player's pet. + +## `pet` +This table mostly contains simple/self explanatory information about the player's currently active pet, if any. +- **index** +- **id** +- **name** +- **owner_index** +- **owner_id** +- **target_id** +- **hp_percent** (current/max values not available, except for the player's automaton in `pet.automaton`) +- **mp_percent** (current/max values not available, except for the player's automaton in `pet.automaton`) +- **tp** +- **active** true if the player has a pet out + +## `pet.automaton` +This table holds more complex data describing the player's puppetmaster automaton. +- **name** +- **hp** +- **hp_max** +- **mp** +- **mp_max** +- **active** true if the player's currently active pet appears to be their automaton +- **head** + - **raw**: unmodified value + - **item_id**: `raw` + 0x2000 + - **item**: Item information from `client_data.items` +- **frame** + - **raw**: unmodified value + - **item_id**: `raw` + 0x2000 + - **item**: Item information from `client_data.items` +- **attachments**: Arrays from 0 to 11 of the following type: + - **raw**: unmodified value + - **item_id**: `raw` + 0x2100 + - **item**: Item information from `client_data`` +- **available_heads[i]**: Original index. Offset from `item_id` by 0x2000, starting at `harlequin_head == 1` (no `0`). +- **available_frames[i]**: Original index. Offset from `item_id` by 0x2020, starting at `harlequin_frame == 0`. +- **available_attach[i]**: Original index. Offset from `item_id` by 0x2100, starting at `strobe == 1` (no `0`). +- **heads_available[item_id]** Modified index to accept `item_id`. +- **frames_available[item_id]** Modified index to accept `item_id`. +- **attach_available[item_id]** Modified index to accept `item_id`. +Automaton's current skill values +- **melee** +- **ranged** +- **magic** +Automaton's skill caps +- **melee_max** +- **magic_max** +- **ranged_max** +Automaton's base stats +- **str** +- **dex** +- **vit** +- **agi** +- **int** +- **mnd** +- **chr** +Automaton's current stat modifiers +- **str_modifier** +- **dex_modifier** +- **vit_modifier** +- **agi_modifier** +- **int_modifier** +- **mnd_modifier** +- **chr_modifier** diff --git a/libraries/pet/manifest.xml b/libraries/pet/manifest.xml new file mode 100644 index 00000000..44c7fc48 --- /dev/null +++ b/libraries/pet/manifest.xml @@ -0,0 +1,11 @@ + + pet + 1.0 + library + + client_data + entities + pet_service + shared + + diff --git a/libraries/pet/pet.lua b/libraries/pet/pet.lua new file mode 100644 index 00000000..cce72bbb --- /dev/null +++ b/libraries/pet/pet.lua @@ -0,0 +1,52 @@ +local client = require('shared.client') +local entities = require('entities') +local items = require('client_data.items') + +local data, ftype = client.new('pet_service') + + + +ftype.fields.target_entity = { + get = function(data) + return entities:by_id(data.target_id) + end, +} + + +ftype.fields.automaton.type.fields.attachments.type.base.fields.item = { + get = function(data) + return items[data.item_id] + end, +} + +ftype.fields.automaton.type.fields.heads_available = { + get = function(data) + return setmetatable({}, { + __index = function(t, k) + return data.available_heads[k - 0x2000] + end, + }) + end, +} + +ftype.fields.automaton.type.fields.frames_available = { + get = function(data) + return setmetatable({}, { + __index = function(t, k) + return data.available_frames[k - 0x2020] + end, + }) + end, +} + +ftype.fields.automaton.type.fields.attach_available = { + get = function(data) + return setmetatable({}, { + __index = function(t, k) + return data.available_attach[k - 0x2100] + end, + }) + end, +} + +return data From d85609fd6f7d53f71bda8f9135376e4dd260bbba Mon Sep 17 00:00:00 2001 From: John S Hobart Date: Fri, 9 Jul 2021 21:44:38 -0400 Subject: [PATCH 2/3] add license to pet.lua --- libraries/pet/pet.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/libraries/pet/pet.lua b/libraries/pet/pet.lua index cce72bbb..763c67d6 100644 --- a/libraries/pet/pet.lua +++ b/libraries/pet/pet.lua @@ -50,3 +50,28 @@ ftype.fields.automaton.type.fields.attach_available = { } return data + +--[[ +Copyright © 2018, John S Hobart +All rights reserved. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the Windower Dev Team nor the + names of its contributors may be used to endorse or promote products + derived from this software without specific prior written permission. +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE WINDOWER DEV TEAM BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +]] \ No newline at end of file From b41b1295914bb35ba60d2dceb2d424e52219b1de Mon Sep 17 00:00:00 2001 From: John S Hobart Date: Fri, 9 Jul 2021 21:48:07 -0400 Subject: [PATCH 3/3] fix copyright date --- libraries/pet/pet.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/pet/pet.lua b/libraries/pet/pet.lua index 763c67d6..603d70d7 100644 --- a/libraries/pet/pet.lua +++ b/libraries/pet/pet.lua @@ -52,7 +52,7 @@ ftype.fields.automaton.type.fields.attach_available = { return data --[[ -Copyright © 2018, John S Hobart +Copyright © 2020, John S Hobart All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: