-
Notifications
You must be signed in to change notification settings - Fork 21
Add pet_service library #460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
sigilbaram
wants to merge
14
commits into
Windower:master
Choose a base branch
from
sigilbaram:pet-service
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5fe0f53
add pet_service library
sigilbaram 54976f3
add trailing newline
sigilbaram 9617737
add license to pet_service.lua
sigilbaram 8b31bbe
adding pet library to same branch
sigilbaram 34c9462
re-added license
sigilbaram 1155022
fix xml indentation
sigilbaram 277d538
fix license
sigilbaram cf816e2
change all ints to int32
sigilbaram c59ddfc
change stats to str->str-base and str_modifier->str_bonus
sigilbaram 5b392df
update interface for auto parts
sigilbaram 6790941
remove old commented code
sigilbaram b0a3112
remove unnessary estimation of auto HP/MP
sigilbaram 615b5fa
restore missing 'end'
sigilbaram 44ec8ef
remote automaton related fields
sigilbaram File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| <package> | ||
| <name>pet</name> | ||
| <version>1.0</version> | ||
| <type>library</type> | ||
| <dependencies> | ||
| <dependency>client_data</dependency> | ||
| <dependency>entities</dependency> | ||
| <dependency>pet_service</dependency> | ||
| <dependency>shared</dependency> | ||
| </dependencies> | ||
| </package> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| local table = require('table') | ||
|
|
||
| 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, | ||
| } | ||
|
|
||
| return data | ||
|
|
||
| --[[ | ||
| Copyright © 2020, Windower Dev Team | ||
| 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. | ||
| ]] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <package> | ||
| <name>pet_service</name> | ||
| <version>1.0</version> | ||
| <type>service</type> | ||
| <dependencies> | ||
| <dependency>packet</dependency> | ||
| <dependency>shared</dependency> | ||
| <dependency>struct</dependency> | ||
| </dependencies> | ||
| </package> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| local math = require('math') | ||
| local ffi = require('ffi') | ||
|
|
||
| local packet = require('packet') | ||
| local server = require('shared.server') | ||
| local struct = require('struct') | ||
|
|
||
| local data = server.new(struct.struct({ | ||
| index = {struct.int32}, | ||
| id = {struct.int32}, | ||
| name = {struct.string(0x10)}, | ||
| owner_index = {struct.int32}, | ||
| owner_id = {struct.int32}, | ||
| target_id = {struct.int32}, | ||
| hp_percent = {struct.int32}, | ||
| mp_percent = {struct.int32}, | ||
| tp = {struct.int32}, | ||
| active = {struct.bool}, | ||
| })) | ||
|
|
||
| packet.incoming:register_init({ | ||
| [{0x037}] = function(p) -- While this packet is mostly player data, it does occassionally update the pet index when no other pet related packet is sent. For example, when moving into zones where the pet is supressed, such as cities and towns, this packet will set the pet index to 0. | ||
| data.index = p.pet_index | ||
| if p.pet_index and p.pet_index ~= 0 then | ||
| data.active = true | ||
| else | ||
| data.active = false | ||
| end | ||
| end, | ||
| [{0x067}] = function(p) | ||
| if p.type == 4 then | ||
| data.index = p.pet_index | ||
| data.id = p.pet_id | ||
| data.owner_index = p.owner_index | ||
| data.hp_percent = p.hp_percent | ||
| data.mp_percent = p.mp_percent | ||
| data.tp = p.pet_tp | ||
| if p.pet_index and p.pet_index ~= 0 then | ||
| data.active = true | ||
| else | ||
| data.active = false | ||
| end | ||
| end | ||
| end, | ||
| [{0x068}] = function(p) | ||
| if p.type == 4 then | ||
| data.owner_index = p.owner_index | ||
| data.owner_id = p.owner_id | ||
| data.index = p.pet_index | ||
| data.hp_percent = p.hp_percent | ||
| data.mp_percent = p.mp_percent | ||
| data.tp = p.pet_tp | ||
| data.target_id = p.target_id | ||
| data.name = p.pet_name | ||
| if p.pet_index and p.pet_index ~= 0 then | ||
| data.active = true | ||
| else | ||
| data.active = false | ||
| end | ||
| end | ||
| end, | ||
| }) | ||
|
|
||
| --[[ | ||
| Copyright © 2020, Windower Dev Team | ||
| 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 | ||
sigilbaram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 | ||
sigilbaram marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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. | ||
| ]] | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
p.pet_indexshould never benil, so the first check could be removed (elsewhere as well).