PDA

View Full Version : Accessing information stored in the XML file for a character.



MyGivinOpinion
March 12th, 2019, 20:40
I'm trying to access the information stored within the XML files of PC "XYZ". The particular area of interest is the weaponlist. The id-XXXXX and the properties. Below is an example of the section of XML i'm trying to query for information.

<weaponlist>
<id-00001>
<attackstat type="string">dexterity</attackstat>
<carried type="number">1</carried>
<damagelist>
<id-00001>
<dice type="dice">d4</dice>
<stat type="string">dexterity</stat>
<statmult type="number">1</statmult>
<type type="string">piercing</type>
</id-00001>
</damagelist>
<isidentified type="number">1</isidentified>
<maxammo type="number">0</maxammo>
<name type="string">Dagger</name>
<prof type="number">1</prof>
<properties type="string">Finesse, light, thrown (range 20/60)</properties>
<shortcut type="windowreference">
<class>item</class>
<recordname>....inventorylist.id-00021</recordname>
</shortcut>
<type type="number">0</type>
</id-00001>
<id-00002>
<attackstat type="string">dexterity</attackstat>
<carried type="number">1</carried>
<damagelist>
<id-00001>
<dice type="dice">d4</dice>
<stat type="string">dexterity</stat>
<type type="string">piercing</type>
</id-00001>
</damagelist>
<isidentified type="number">1</isidentified>
<maxammo type="number">0</maxammo>
<name type="string">Dagger</name>
<prof type="number">1</prof>
<properties type="string">Finesse, light, thrown (range 20/60)</properties>
<shortcut type="windowreference">
<class>item</class>
<recordname>....inventorylist.id-00021</recordname>
</shortcut>
<type type="number">2</type>
</id-00002>
<id-00003>
<attackstat type="string">charisma</attackstat>
<carried type="number">1</carried>
<damagelist>
<id-00001>
<dice type="dice">d8</dice>
<stat type="string">charisma</stat>
<statmult type="number">1</statmult>
<type type="string">slashing</type>
</id-00001>
</damagelist>
<isidentified type="number">1</isidentified>
<maxammo type="number">0</maxammo>
<name type="string">Longsword</name>
<prof type="number">1</prof>
<properties type="string">Versatile (1d10)</properties>
<shortcut type="windowreference">
<class>item</class>
<recordname>....inventorylist.id-00022</recordname>
</shortcut>
<type type="number">0</type>
</id-00003>
</weaponlist>

There is more that comes after this but for now I have a successful trigger I can't figure out how to access this information. As for which weapons would be targeted, that also needs to be determined by the attackframe connection to the actions tab of the character sheet. The one that determines if you hit or miss. My plan is to use the attack frame as a trigger to scan the properties of the weapon whose attack is being dragged for particular phrases.

I'm not very good at explaining stuff. I am more of a visual person so if you need clarification about anything please do not hesitate to ask, and I will do my best to elaborate in a more understandable way..

damned
March 12th, 2019, 23:54
Create a character.
Add a weapon to the character that has a Range value included.
type /save in chat and then open the campaigns db.xml file.
in that file search for the weapon name and you should find it entered two (or three for a melee/thrown weapon) times.
The first will be the Inventory entry and the second the Weaponlist.
You will see links/shortcuts like this in the Weaponlist record:

<shortcut type="windowreference">
<class>item</class>
<recordname>....inventorylist.id-00022</recordname>
</shortcut>

It doesnt appear that 5E stores the weapon range in the Inventory or Weaponlist so if you have to create the range you may as well first determine if its best to store that in Inventory or Weaponlist.

MyGivinOpinion
March 12th, 2019, 23:59
That's not true. Reach implies an additional area for threat range up to ten feet like with glaives and polearms. Scanning for a reach property, then telling the system to change the reach is my intent. I will be adding code for versatile and adding another weapon slot for it, but that's another section for another time. Right now I just need to scan the properties.

MyGivinOpinion
March 13th, 2019, 00:00
Damned my code is from a character XML file.. but i now understand why you are saying the db.xml it's housing all the same information for each and everything taking place in the campaign only. rather than a DB housing allthe code

MyGivinOpinion
March 14th, 2019, 19:05
okay @Damned. I owe you an apology. I do see what you mean by it not being tracked by the weaponlist or inventorylist. I am sorry for arguing with you. I've got a working proof of concept on editing the reach value, but right now it's bound to an effect. Which is not an optimal way of doing this. It seems I'm going have to rethink how to go about this.. Although the properties of "reach" do exist on polearm weapons, the issue is still how to check for that property. What I'm trying to grab is located in both the weapon list of the items menu and in the weapons statistical information under "Properties" for both. So it exists somewhere in the coding, I just have to locate it and use it.

Paul Pratt
March 14th, 2019, 21:15
The file ct_host.xml is the place "reach" is set. It is 5 by default from the .xml, and manually adjusted as needed.

If you want to scan for "reach" during the attack, you will either need to grab it from the CT entry, or add "reach" as a field to the character sheet weapon entries so it can be passed along with the attack roll structure.

MyGivinOpinion
March 14th, 2019, 21:27
Yes. I'm already editing the actual REACH value in CT with my code using an effect(as stated previously), but right now i'm trying to find this..26715 i have three places to pull this from. still can't locate this information in the code.

Trenloe
March 14th, 2019, 21:48
Yes. I'm already editing the actual REACH value in CT with my code using an effect(as stated previously), but right now i'm trying to find this..26715 i have three places to pull this from. still can't locate this information in the code.
The best place to get this from (assuming a PC) is the charsheet.<id-node>.weaponlist.<id-node>.properties field. As PC attacks are rolled directly from the weapon entry on the actions tab, you should have direct access to the weapon database node as part of the attack action.

For D&D 5E:

In the campaign\scripts\char_weapon.lua file there is an onAttackAction function - in this the properties from the weapon database node are extracted and put into a LUA table called aWeaponProps on line 60. This shows how to get the weapon properties, using DB.getValue(nodeWeapon, "properties", "")


For 3.5E/PFRPG:
(Left this in as this was what I originally replied to - as it wasn't obvious to me at first glance which ruleset you were looking at).

The code that is ran when an attack is made is in the 3.5E campaign\scripts\char_weaponattack.lua file - window.getDatabaseNode() in this file will give you direct access to the weapon database node of the weapon in the weaponlist section of the character database (charsheet.<id-node>.weaponlist.<id-node>).

When the attack is made, the action function in this script is ran, it puts together the attack info by calling CharManager.getWeaponAttackRollStructures(window.g etDatabaseNode()) - looking at CharManager.getWeaponAttackRollStructures (the getWeaponAttackRollStructures function in campaign\scripts\manager_char.lua) you can see a number of operations against nodeWeapon - including on line 752: local sProp = DB.getValue(nodeWeapon, "properties", "")


I hope this helps you to understand the structure a little better and get access to the weapon properties.

MyGivinOpinion
March 14th, 2019, 21:54
@trenloe thanks so much! And you're assumption was correct!

MyGivinOpinion
March 15th, 2019, 00:08
So I've accessed the weapon properties and it's debugging semi-correctly, still having issues writing a catch statement at this time, but I current have this bound to onHover of the attackicon and attackview of record_char_weapons.xml of my extension. Not so much asking for help right now as I feel I can manage the next bit. But I wanted to show everyone who has helped that it's functioning as a big thank you!26722

Trenloe
March 15th, 2019, 06:43
Not so much asking for help right now as I feel I can manage the next bit. But I wanted to show everyone who has helped that it's functioning as a big thank you!26722
Fantastic! Great to see you’re making good progress. :-)