View previous topic :: View next topic |
Author |
Message |
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Sun Jul 24, 2005 2:01 Post subject: More NWNX_Functions oddities |
|
|
Dazzle, I found a couple of other oddities starting with 1.66 and NWNX_Functions.....
The following seem to not function anymore:
NWNX_SetName()
NWNX_SetDescription()
I was using them in a custom crafting system and no one told me that they had stopped until now I verified it with your new version also.
Verified still functional:
NWNX_SetTag(oItem,ItemTag);
I know this functions as it is a required part of my crafting system Since everything still "worked" no one had reported the previous issue....
Could you check these?
ThanX! |
|
Back to top |
|
|
Vladiat0r
Joined: 17 Jun 2005 Posts: 25
|
Posted: Sun Jul 24, 2005 5:13 Post subject: |
|
|
I'm guessing the same thing happened with those functions as with Set/GetBodyPart, the offset to the data was shifted... it's a matter of finding out by how much. Set/GetBodyPart got shifted by 12, so it's safe to assume Name and Description were also shifted not more than 12. *shrug* I might be completely wrong though... |
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Sun Jul 24, 2005 5:41 Post subject: |
|
|
It also looks like Tag is probably effected. I forgot that I shifted to use item variables instead of tags for the system... |
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Sun Jul 24, 2005 8:20 Post subject: |
|
|
It might be harder than just setting an offset. A little more playing shows:
SetName WORKS on armor (tested on two different heavy armors)
SetName DOES NOT work on weapons (Tested on a plain scimitar and a +1 Katana)
SetDescription doesn't work on either...
If I get a chance I will go through various item types over the next few days and see what works/doesn't work. |
|
Back to top |
|
|
Dazzle
Joined: 29 Dec 2004 Posts: 19
|
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Sun Jul 24, 2005 18:33 Post subject: |
|
|
Okay... Are you ready to get confused?
I tried:
Great Axe
Commoner Clothing
Bolt
Arrow
Bullet
Potion-Cure Light
Banded Armor
Chain Shirt
Leather Armor
and several other things. EVERY ONE failed to set Name and Description, TAG set correctly each time.
I started thinking of what I noticed before when the armor seemed to work right. The armor that worked is dynamically created via a conversation script (Mandragon's Clothing creator). Its completely custom.
So I took ALL the items that had failed and made a "copy" of each, adding a custom description and changing their name by adding a "1" to the end of it. After that change ALL items set their names and descriptions correctly. I took one (I know, incomplete test) and made a copy of the original pallette armor and changed only its name. NAME now set correctly but DESCRIPTION did not......
It appears the function (now) only works on items that have custom names and descriptions?
Here is the exact code I used to test with, called via conversation script on a placeable. The functions include is called from the beginning of the aps include:
Code: |
#include "aps_include"
void main()
{
object oPlayer=GetPCSpeaker();
object oChest=OBJECT_SELF;
object oItem=GetFirstItemInInventory(oChest);
SendMessageToPC(GetPCSpeaker(),"Current Tag is "+GetTag(oItem));
NWNX_SetTag(oItem,"NewTag");
NWNX_SetName(oItem,"Socketted item");
NWNX_SetDescription(oItem,"Socketted item with 5 sockets.");
SendMessageToPC(GetPCSpeaker(),"Current Tag is "+GetTag(oItem));
}
|
The module is one 2x2 area, specifically setup for this test The only scripts/conversations in it are the ones needed to open the conversation and make Aps/Functions work |
|
Back to top |
|
|
Dazzle
Joined: 29 Dec 2004 Posts: 19
|
Posted: Sun Jul 24, 2005 20:31 Post subject: |
|
|
Okay, what are the old descriptions and names of those items? When changing names the new name may not be longer than the old name. Eg, you can't change "Bullet" to "Socketted Item", same for the description. To work around this you have to give the items names/descriptions like "Bullet######" so the name is actually longer. Also, the same goes for tags. |
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Sun Jul 24, 2005 22:48 Post subject: |
|
|
Dazzle wrote: | Okay, what are the old descriptions and names of those items? When changing names the new name may not be longer than the old name. Eg, you can't change "Bullet" to "Socketted Item", same for the description. To work around this you have to give the items names/descriptions like "Bullet######" so the name is actually longer. Also, the same goes for tags. |
If I take the standard Bullet in the pallette, make a "copy" and name it "1", with a description of "1" and a tag of "t_1" the function sets everything correctly. The new name is "Socketted Item", the new tag is "NewTag" and the new description is "Socketted item with 5 sockets."
I took another bullet, named it "Bullets, lots and lots of bullets", with a tag that was 10 characters and a description of at least two paragraphs of random letters and numbers. The same script renamed it to "b", with a tag of "1" and a description of "S".
Is there a difference in memory locations based on whether the item is default or custom? Or am I misunderstanding what you are saying as for the lengths? |
|
Back to top |
|
|
Senalaya
Joined: 29 Dec 2004 Posts: 82 Location: Germany
|
Posted: Mon Jul 25, 2005 8:32 Post subject: |
|
|
Acrodania,
with strings like names, tags, etc it's a bit more complicated.
At the 'fixed' position in memory, which is addressed by NWNXFuctions, there isn't the string itself, but an int/pointer telling us the real position of the string in memory. So, the position we access is NOT dependent on the string length.
However, at the position where the string is actually stored, there is only enough space reserved for the actual string length.
The NWNX function simply copies the new string to that position and truncates it to the length of the existing string. Otherwise other data (directly behind that string) would be overwritten/corrupted.
When the new string is shorter, it doesn't matter, since the string length is part of the stored string data, so the then unused part will be ignored.
This is completely independent on whether the iterm is standard or custom.
Edit: After taking another look at the code, there could be a 'bug', that actually limits the new string to a length, that is 1 char shorter than the existing one. That could mess up, when the existing name has only a length of 1. |
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Mon Jul 25, 2005 16:20 Post subject: |
|
|
Please bear with me Senalaya, I understand the concept of what you are saying but not the implementation. My programming skills == NWScript and PHP
From what I understand you are saying my above example with very short names, tags and descriptions being changed to long versions should not work. But I have never had a problem with them being altered to longer ones. Unless I have just never exceeded the byte allocation for the addressing. But that still doesn't explain (to me) the oddities that I am now seeing with standard vs. custom items.
I dug through my notes and found mention of one oddity that I had show up which I will continue below, but prior to patch 1.66 I had no problems with this module altering either standard or custom items and their names, tags or descriptions. Now it appears to only work for me on custom items. Even in the example above where I took a standard item (scimitar) and tried to alter its name to a very short one, it failed. Any custom item seems to work fine for me now. Its no big deal, I can always alter the drop system to use only custom templates but I find it odd that it just started happening. Can anyone else verify this is the case?
The only change made to the module that I can think of is that its now running NWNX 2.6.1 and before it was on 2.5.3 Plus its on Win98 now instead of Win2K as we have a bad CPU in the main server (which caused the previous problems I had posted about crashing problems). Other than that the only additions have been expanding the drop system and adding areas.
The one oddity I had in my notes was in another module I was playing with I noticed that an item that had NO description didn't set its description correctly. Just by adding a description to the pallette it then would work. This could be because of the potential bug you noticed? No description ("0" length, maybe 1 with a default place-holder) would then not set right.
ThanX for the help! |
|
Back to top |
|
|
chris421
Joined: 07 Apr 2005 Posts: 53
|
Posted: Wed Sep 07, 2005 5:55 Post subject: |
|
|
Any resolution on the weapon SetName problem???
Seems like all my custom built Armor & Clothes can be renamed just fine--regardless of original name length.
From the custom Weapons however, I can only rename the Bastard Sword and Scimitar. Ammo, I believe I get mixed results.
Any relation to how the items were named in the Toolset? I did notice that some of my custom items have the glowy-yellow backdrop to the ItemName field. Some are just on white backdrop. I think it may be a result of having copied from a pre-existing item, without altering the item name.
Code: |
//This is only the relevant code...
#include "inc_nwnx_func"
PrintString(GetName(oItem)+GetResRef(oItem));
string sPrefix1 = "Not ";
string sPrefix2 = "Even ";
string sBaseName = "This";//GetName(oItem);
string sSuffix1 = " Worked";
string sSuffix2 = " +1";
string sName;
sName = sPrefix1+sPrefix2+sBaseName+sSuffix1+sSuffix2;
NWNX_SetName(oItem, sName);
|
|
|
Back to top |
|
|
Acrodania
Joined: 02 Jan 2005 Posts: 208
|
Posted: Wed Sep 07, 2005 17:53 Post subject: |
|
|
I solved my issues by taking the recommendations above and setting the names, tags and descriptions of the base items like so....
"Custom Longsword ."
Notice the long space and period |
|
Back to top |
|
|
chris421
Joined: 07 Apr 2005 Posts: 53
|
Posted: Wed Sep 07, 2005 22:30 Post subject: |
|
|
Ugh. I have over 800 custom items. This may be the deal-breaker for using this dll.
Worried that if I go back through all the items and change the name, some future patch could break nwnx_SetName entirely leaving me with a module full of oddly named items. |
|
Back to top |
|
|
Aedrielle
Joined: 30 May 2005 Posts: 7
|
Posted: Sun Sep 25, 2005 14:04 Post subject: |
|
|
chris421 wrote: | Any relation to how the items were named in the Toolset? I did notice that some of my custom items have the glowy-yellow backdrop to the ItemName field. Some are just on white backdrop. I think it may be a result of having copied from a pre-existing item, without altering the item name. |
Yellow means an 'original' name/description.
And IMO it's rather a reference to a text in dialog.tlk, not an actual string.
Therefore it will not change. (?)
Names/descriptions on custom or copied items are set properly on my mod, as long as they are not empty and on white background..
(If you're using a multilingual mod make sure all names/desc. strings are empty except the ones in default language, so everyone sees new name/desc). |
|
Back to top |
|
|
|