[Release] Reading map_XXXX.xns

01/27/2017 14:25 Plastic#1
This is the file structure for the .xns map files. With this information you should be able to change which NPC is spawned at which location. I haven't tested it, but I'm sure someone will be able to find a use for this. Please feel free to let anyone know what you've successfully changed with this information.

Code:
typedef struct
{
    int objectIndex;
    struct
    {
        float m[ 4 ]; // float m[ 4 ][ 4 ]
    } D3DMATRIX[ 4 ]; // no multidimensional array support in 010 editor :(
} XOBJECT;

typedef struct
{
    int enable;
    int conditionClass;
    int compareClass1 : 8;
    int compareClass2 : 8;
    int compareClass3 : 8;
    int compareClass4 : 8;
    int numericValue1;
    int numericValue2;
    int numericValue3;
    int numericValue4;
} XNPC_SUBSCRIPT_CONDITION;

typedef struct
{
    int conditionID;
    char conditionString[ 64 ];
    XNPC_SUBSCRIPT_CONDITION npcSubscriptCondition;

    int strLength;

    if ( strLength > 0 )
        char str[ strLength ]; 
} XNPC_SCRIPTCONDITIONITEM;

typedef struct
{
    int msgLength1;
    if( msgLength1 > 0 )
        char prevGreetingMsg[ msgLength1 ]; // client fseeks past ( read in by .xsd )
    int msgLength2;
    if( msgLength2 > 0 )
        char greetingGeneralMsg[ msgLength2 ]; // client fseeks past ( read in by .xsd )
    int msgLength3;
    if( msgLength3 > 0 )
        char greetingHostilityMsg[ msgLength3 ]; // client fseeks past ( read in by .xsd )
    int msgLength4;
    if( msgLength4 > 0 )
        char greetingCustomerMsg[ msgLength4 ]; // client fseeks past ( read in by .xsd )
    int msgLength5;
    if( msgLength5 > 0 )
        char greetingHeroStayMsg[ msgLength5 ]; // client fseeks past ( read in by .xsd )

    int indexPrevGreetingSound;
    int indexGreetingGeneralSound;
    int indexGreetingHostilitySound;
    int indexGreetingCustomerSound;
    int indexGreetingHeroStaySound;
} XNPC_GREETING_SOUNDMSG;

typedef struct
{
    int msgLength;
    if( msgLength > 0 )
        char goodbyeMessage[ msgLength ];
} XNPC_GOODBYE_MSG;

typedef struct
{
    int msgLength1;
    if( msgLength1 > 0 )
        char strMessage1[ msgLength1 ]; // client fseeks past ( read in by .xsd )
    int msgLength2;
    if( msgLength2 > 0 )
        char strMessage2[ msgLength2 ]; // client fseeks past ( read in by .xsd )
    int msgLength3;
    if( msgLength3 > 0 )
        char strMessage3[ msgLength3 ]; // client fseeks past ( read in by .xsd )
} XNPC_STRMSG;

typedef struct
{
    int enable;
    int scriptClass;
    int compareClass;
    int condition1;
    int condition2;
    int condition3;
    int condition4;
    int condition5;
    int condition6;
    int condition7;
    int condition8;
    int condition9;
    int condition10;
    int condition11;
    int condition12;
    int condition13;
    int quantityNumber1;
    int quantityNumber2;
    int quantityNumber3;
    int quantityNumber4;
    int quantityNumber5;

    int quantityStrLength;
    if( quantityStrLength > 0 )
        char quantityStr[ quantityStrLength ]; // client fseeks past ( read in by .xsd )

    int messageLength;
    if( messageLength > 0 )
        char messageStr[ messageLength ]; // client fseeks past ( read in by .xsd )

    XNPC_STRMSG strMsg[ 5 ];

    int subscriptConditionCount;
    if( subscriptConditionCount > 0 )
        XNPC_SCRIPTCONDITIONITEM conditionItem[ subscriptConditionCount ];
} XNPC_SCRIPTITEM;

typedef struct
{
    char scriptName[ 32 ];
    int compareClass;
    int npcScriptConditionCount;
    if ( npcScriptConditionCount > 0 )
        XNPC_SCRIPTCONDITIONITEM npcConditionItem[ npcScriptConditionCount ];

    XNPC_GREETING_SOUNDMSG greetSoundMsg[ 5 ];
    XNPC_GOODBYE_MSG goodbyeMsg[ 4 ];
    int indexGoodbyeSound[ 4 ];

    int subscriptCount;
    if( subscriptCount > 0 )
        XNPC_SCRIPTITEM subscriptConditionCount[ subscriptCount ];
} XNPC_MAINSCRIPT;

typedef struct
{
    int uniqueID;
    int npcJobClass;
    int tradeItemClass;
    int npcClass;
    int npcClanClass;

    int npcRelationMapID;
    int npcRelationVillageID;
    int npcRelationRoleID;

    int npcNameLength;
    if( npcNameLength > 0 )
        char npcName[ npcNameLength ]; // client fseek's past this

    int npcRoleLength;
    if( npcRoleLength > 0 )
        char npcRole[ npcRoleLength ]; // client fseek's past this

    XOBJECT savedObject;

    int scriptCount;
    XNPC_MAINSCRIPT mainScript[ scriptCount ];
} XNPC_OBJECTARRAY;

struct
{
    char npcListFileName[ 260 ]; // MAX_PATH
    int objectCount;
    XNPC_OBJECTARRAY npcObjectArray[ objectCount ];
} theFile;
Template for 010 Editor 7.0 attached below.
01/27/2017 15:23 Plastic#2
Referencing which NPC an object refers to is as easy as:

Code:
npcName = ( uniqueID * 1000 ) + 1
roleName = ( uniqueID * 1000 ) + 2


prevGreetMsg = ( uniqueID * 1000 ) + 11 + arrayIndex
greetingGeneralMsg = ( uniqueID * 1000 ) + 16 + arrayIndex
greetingHostilityMsg = ( uniqueID* 1000 ) + 21 + arrayIndex
greetingCustomerMsg = ( uniqueID * 1000 ) + 26 + arrayIndex
greetingHeroStayMsg = ( uniqueID * 1000 ) + 31 + arrayIndex

goodbyeMessage = ( uniqueID * 1000 ) + 41 + arrayIndex
Using the XSD Editor that saweet made with map_beegoong ( SF Clan Base ):

[Only registered and activated users can see links. Click Here To Register...]
10/07/2017 12:19 hoannguyet#3
How i add new npc on the map?