logo logo

 Back to main page

The NWNX Community Forum

 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 
Database conflicts with HCR

 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
Raine



Joined: 28 Jul 2006
Posts: 23

PostPosted: Mon Nov 06, 2006 16:16    Post subject: Database conflicts with HCR Reply with quote

I'm getting a compile error when trying to use the aps scripts. Apparently there's already some type of persistence scripts with HCR and there's a conflict..

At this line (64-65 in the aps_include script):
Code:

void SetPersistentString(object oObject, string sVarName, string sValue, int iExpiration =
                         0, string sTable = "pwdata");

I get the following error:
Function implementation and definition differ

I assume that HCR has already made a set persistent string function.

Yep.. just found it...

Code:

void SetPersistentString(object oTarget, string sName, string sValue) {
    SetPersistentStringByKey(GetKey(oTarget), sName, sValue);}


There's the equivalents for ints and floats as well.

So it looks like I'm in for some fun... Has anyone out there merged HCR and NWNX2 before? I REALLY don't want to have to merge and rewrite these scripts. Given my lack of expertise, I know I'll mess it up.
_________________
Raine
World of Greyhawk (CEP)
http://worldofgreyhawk.10.forumer.com


Last edited by Raine on Fri Nov 10, 2006 23:07; edited 1 time in total
Back to top
View user's profile Send private message
Raine



Joined: 28 Jul 2006
Posts: 23

PostPosted: Fri Nov 10, 2006 23:05    Post subject: Reply with quote

For anyone else who has run into this problem, I found a possible solution on the vault called Persistence Facade. Looks interesting. I'll report back after I test it out.

http://nwvault.ign.com/View.php?view=scripts.Detail&id=1209
_________________
Raine
World of Greyhawk (CEP)
http://worldofgreyhawk.10.forumer.com
Back to top
View user's profile Send private message
Frang



Joined: 22 May 2005
Posts: 32

PostPosted: Fri Nov 10, 2006 23:12    Post subject: Reply with quote

A few people have had both aps and hcr in the same module without conflicts. But I dont know of anyone that has set hcr up to use aps for storing its info. To get both systems in the module you can download a set of scripts from the vault called Persistence Facade. Its just a set of wrappers that lets you pick your way of storing info (hcr, bioware or aps). The instructions tell you how to setup hcr to compile and somewhat use the aps to save the data just not retrieve it. I have been thinking about converting hcr to directly use aps but im still learning the aps functions so may not be able to pull it off.

Frang

edit
lol beat me to it.
Back to top
View user's profile Send private message
Raine



Joined: 28 Jul 2006
Posts: 23

PostPosted: Mon Nov 13, 2006 17:32    Post subject: Reply with quote

Unfortunately, the Persistent Facade is very dated. I don't think HotU was out yet and judging by the documentation HCR 3.00 was just barely out. Because of that, I'm running into some errors.

Apparently some of the scripts for persistent integers were placed in various scripts and then later combined in the hc_inc_pwdb_func script. This PF script goes into the various individual scripts.

Some instructions of the PF say to comment out specific line numbers that I know are incorrect line numbers now. Unfortunately, I'm not sure the correct ones.

I started off with about 100 compile errors. I'm down to about a dozen..
Doesn't mean that it'll work as it's supposed to, just that it's compiling.. It'll be a good start just to get it compiling.

Anyway, I'm getting a parsing variable error for nearly all the scripts for this line of hc_inc_dcorpse (added per instructions):

Code:


location GetPersistentLocation(object oObject, string sVarname, string sTable="WoGpwdata");



Here's the script called from the beginninng:

Code:

/*  Persistence Facade v1.2, by benton
    Persistence facade file
    This file is used to define the persistence functions, and
    to include the desired presistence implementation.
    Include this file wherever you want to use these
        GetPFCampaign<VarType> functions.

    Below the function definitions, you must uncomment exactly
    one #include line. Each of the possible include files
    implements the following functions differently.

    ******** IMPORTANT NOTE FOR HCR USERS ********************
    When HCR is imported, and you want it to use APS persistence,
    you must change line 5 of the HCR script hc_inc_timecheck from
        void GetPersistentInt(object oMod, string sType);
    to
        int GetPersistentInt(object oObject, string sVarName, string sTable="pwdata");
    See the README for details on getting HCR to work with other
    persistence systems.
    **********************************************************
*/
// INTERFACE:

// Here are the functions you should use to store data
void SetPFCampaignInt(string sCampaignName, string sVarName, int nInt,
    object oPlayer=OBJECT_INVALID, int iExpire = 0);
void SetPFCampaignFloat(string sCampaignName, string sVarName, float flFloat,
    object oPlayer=OBJECT_INVALID, int iExpire = 0);
void SetPFCampaignLocation(string sCampaignName, string sVarName, location locLocation,
    object oPlayer=OBJECT_INVALID, int iExpire = 0);
void SetPFCampaignString(string sCampaignName, string sVarName, string sString,
    object oPlayer=OBJECT_INVALID, int iExpire = 0);
void SetPFCampaignVector(string sCampaignName, string sVarName, vector vVector,
    object oPlayer=OBJECT_INVALID, int iExpire = 0);
int StorePFCampaignObject(string sCampaignName, string sVarName, object oObject,
    object oPlayer=OBJECT_INVALID);

// Here are the functions you should use to retrieve data
int GetPFCampaignInt(string sCampaignName, string sVarName,
    object oPlayer=OBJECT_INVALID);
float GetPFCampaignFloat(string sCampaignName, string sVarName,
    object oPlayer=OBJECT_INVALID);
location GetPFCampaignLocation(string sCampaignName, string sVarName,
    object oPlayer=OBJECT_INVALID);
string GetPFCampaignString(string sCampaignName, string sVarName,
    object oPlayer=OBJECT_INVALID);
vector GetPFCampaignVector(string sCampaignName, string sVarName,
    object oPlayer=OBJECT_INVALID);
object RetrievePFCampaignObject(string sCampaignName, string sVarName, location locLocation,
    object oOwner = OBJECT_INVALID, object oPlayer=OBJECT_INVALID);

// Use this function to delete data
void DeletePFCampaignVariable(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID);

// IMPLEMENTATION:

/*  Uncomment the following line to use the built-in Bioware
    persistence
*/
//#include "pf_bio_persist"

/*  Import HCR and pf_hcr_persist, then uncomment the following line to use HCR
    persistence, which dumps nwscript to the server log file.
*/
//#include "pf_hcr_persist"

/*  Import pf_aps_persist and uncomment the following line to use APS/NWNX
    database persistence. You must also add the command
        ExecuteScript("aps_onload", GetModule());
    somewhere in your module's OnModuleLoad script
    (or use aps_onload as your module's OnModuleLoad script).
*/
#include "pf_aps_persist"

/*  Local "Persistence" emulation
    (for testing without writing any permanent data)
    This persistence system simply calls the equivalent
    SetLocal<VarType> function
*/
//#include "pf_lcl_persist"


And here's the pf_aps_persist called:
Code:

/*  Persistence Facade v1.2, by benton
    This is the front-end for aps/nwnx
    It just adds a few functions for HCR compatibility
*/
#include "aps_include"

// This is the table name were all HCR data for this module
// will be stored. If you're not using HCR, it's not used.
string sHCRTableName = "WoGpwdata";

int GetPFCampaignInt(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { return GetPersistentInt(oPlayer, sVarName, sCampaignName); }

float GetPFCampaignFloat(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { return GetPersistentFloat(oPlayer, sVarName, sCampaignName); }

location GetPFCampaignLocation(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { return GetPersistentLocation(oPlayer, sVarName, sCampaignName); }

string GetPFCampaignString(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { return GetPersistentString(oPlayer, sVarName, sCampaignName); }

vector GetPFCampaignVector(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { return GetPersistentVector(oPlayer, sVarName, sCampaignName); }


void SetPFCampaignInt(string sCampaignName, string sVarName, int nInt,
    object oPlayer=OBJECT_INVALID, int expire = 0)
    { SetPersistentInt(oPlayer, sVarName, nInt, expire, sCampaignName);}

void SetPFCampaignFloat(string sCampaignName, string sVarName, float flFloat,
    object oPlayer=OBJECT_INVALID, int expire = 0)
    { SetPersistentFloat(oPlayer, sVarName, flFloat, expire, sCampaignName);}

void SetPFCampaignLocation(string sCampaignName, string sVarName, location locLocation,
    object oPlayer=OBJECT_INVALID, int expire = 0)
    { SetPersistentLocation(oPlayer, sVarName, locLocation, expire, sCampaignName);}

void SetPFCampaignString(string sCampaignName, string sVarName, string sString,
    object oPlayer=OBJECT_INVALID, int expire = 0)
    { SetPersistentString(oPlayer, sVarName, sString, expire, sCampaignName);}

void SetPFCampaignVector(string sCampaignName, string sVarName, vector vVector,
    object oPlayer=OBJECT_INVALID, int expire = 0)
    { SetPersistentVector(oPlayer, sVarName, vVector, expire, sCampaignName);}

void DeletePFCampaignVariable(string sCampaignName, string sVarName, object oPlayer=OBJECT_INVALID)
    { DeletePersistentVariable(oPlayer, sVarName, sCampaignName); }

void DestroyPFCampaignDatabase(string sCampaignName)
    { SQLExecDirect("DELETE from " + sCampaignName); }

// This does nothing in APS, because it doesn't support object storage
int StorePFCampaignObject(string sCampaignName, string sVarName, object oObject, object oPlayer=OBJECT_INVALID)
    { return 0; }

object RetrievePFCampaignObject(string sCampaignName, string sVarName, location locLocation,
    object oOwner = OBJECT_INVALID, object oPlayer=OBJECT_INVALID)
    { return OBJECT_INVALID; }

//==================   HCR compatibilty functions ===================//

// These functions are put in so HCR will compile and use the facade
void DeletePersistentString(object oTarget, string sName)
    { DeletePersistentVariable(oTarget, sName, sHCRTableName);}
void DeletePersistentInt(object oTarget, string sName)
    { DeletePersistentVariable(oTarget, sName, sHCRTableName); }
void DeletePersistentFloat(object oTarget, string sName)
    { DeletePersistentVariable(oTarget, sName, sHCRTableName); }
void DeletePersistentLocation(object oTarget, string sName)
    { DeletePersistentVariable(oTarget, sName, sHCRTableName); }
void DeletePersistentObject(object oTarget, string sName)
    { DeletePersistentVariable(oTarget, sName, sHCRTableName); }

// These do nothing in APS, because it doesn't support object storage
//void SetPersistentObject(object oObject, string sVarName, object oObject2, int iExpiration = 0, string sTable = "pwobjdata");
//    object GetPersistentObject(object oObject, string sVarName, object oObject2, int iExpiration = 0, string sTable = "pwobjdata")

// These do nothing in APS since all saving is done on-the-fly to DB
// They are put in so HCR will compile if this file is included with HCR
//void PWDBSaveAll()
//void PWDBSaveChanged()


I commented out the last six lines myself just to stop a compile error.
The aps_include file has not been altered.

Thanks for any help with this mess...
Back to top
View user's profile Send private message
Raine



Joined: 28 Jul 2006
Posts: 23

PostPosted: Mon Nov 13, 2006 17:36    Post subject: Reply with quote

I guess I should give you the entire dcorpse script in its entirety as well:

Code:

// HCR v3.2.0 - Fix to make HotU's selectable corpses "static". - Sunjammer.
//::////////////////////////////////////////////////////////////////////////////
//:: FileName:  HC_Inc_DCorpse
//::////////////////////////////////////////////////////////////////////////////
/*
   Various functions to create, move and destroy the visible player corpse.
*/
//::////////////////////////////////////////////////////////////////////////////
#include "HC_Id"
#include "HC_Inc_PWDB_Func"
//::////////////////////////////////////////////////////////////////////////////


//  ----------------------------------------------------------------------------
//  CONSTANTS
//  ----------------------------------------------------------------------------

//  Controls the inventory slots that will be cleared.
//  - set to 14 to clear PC slots and leave Creature (hides) slots.
//  - set to 18 to clear PC and Creature (hides) slots.
int NUM_PC_INVENTORY_SLOTS = 14;


//  ----------------------------------------------------------------------------
//  VARIABLES
//  ----------------------------------------------------------------------------

int nStrip = GetLocalInt(GetModule(), "INVSTRIP");
int nLoot = GetLocalInt(GetModule(), "LOOTSYSTEM");


//  ----------------------------------------------------------------------------
//  PROTOTYPES
//  ----------------------------------------------------------------------------

//  Creates a visible corpse of oPC and destroys equiped and iventory items as
//  required. Called when oPC dies.
void CreateCorpse(object oPC);

//  Destroys the exsisting visible corpse belonging to oPC and destorys equipped
//  and inventory items as required. Called when player is revived.
void DestroyCorpse(object oPC);

//  Creates a copy of oDC in fugue and destroys the original visible corpse.
//  Called when a visible corpse is picked up.
void CopyToFugue(object oDC);

//  Creates a visible corpse for the player corpse token oDropped and destroys
//  the copy corpse in fugue.  The new corpse is located either where the token
//  was put down or where the player originally died. Called when corpse is put
//  down or when the player carrying it logs out.
//  - oOwner:   (legacy - not used but must be included)
//  - oDropper: player who was carrying the corpse token
//  - oDropped: the corpse token
object CopyFromFugue(object oOwner, object oDropper, object oDropped);


//  ----------------------------------------------------------------------------
//  FUNCTIONS
//  ----------------------------------------------------------------------------

//::////////////////////////////////////////////////////////////////////////////
void CreateCorpse(object oPC)
{
    string sID = GetsID(oPC);
    object oMod = GetModule();

location GetPersistentLocation(object oObject, string sVarname, string sTable="WoGpwdata");

    // use current location as default unless logging in dead
    location lLoc = GetLocation(oPC);
    if(GetLocalInt(oPC, "LOGINDEATH"))
    {
        lLoc = GetPersistentLocation(oMod, "DIED_HERE" + sID);
        DeleteLocalInt(oPC, "LOGINDEATH");
    }

    // create HotU friendly player corpse
    object oDC2 = CopyObject(oPC, lLoc, OBJECT_INVALID);
    AssignCommand(oDC2, SetIsDestroyable(FALSE, FALSE, FALSE));
    ChangeToStandardFaction(oDC2, STANDARD_FACTION_COMMONER);

    // associate with invisible corpse and store this corpse
    object oDeathCorpse =  GetLocalObject(oMod, "DeathCorpse" + sID);
    SetLocalString(oDeathCorpse, "DC2Key", sID);
    SetLocalObject(oMod, "DC2" + sID, oDC2);

    // remove gold
    int nGold = GetGold(oDC2);
    AssignCommand(oDC2, TakeGoldFromCreature(nGold, oDC2, TRUE));

    // remove inventory items
    object oItem = GetFirstItemInInventory(oDC2);
    while (GetIsObjectValid(oItem))
    {
        DestroyObject(oItem);
        oItem = GetNextItemInInventory(oDC2);
    }

    // remove equipted items if required
    if (nLoot && !nStrip)
    {
        int i;
        for(i = 0; i < NUM_PC_INVENTORY_SLOTS; i++)
        {
            DestroyObject(GetItemInSlot(i, oDC2));
        }
    }
}
//::////////////////////////////////////////////////////////////////////////////
void DestroyCorpse(object oPC)
{
    string sID = GetsID(oPC);
    object oMod = GetModule();
    object oDC2 = GetLocalObject(oMod, "DC2" + sID);

    // revival VFX
    effect eEff = EffectVisualEffect(VFX_IMP_RAISE_DEAD);
    DelayCommand(2.1, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEff, GetLocation(oDC2)));

    // disassociate from ivisible corpse and clean up
    object oDC = GetLocalObject(oMod, "DeathCorpse" + sID);
    DeleteLocalString(oDC, "sID");
    DeleteLocalObject(oMod, "DC2" + sID);

    // remove inventory items
    object oItem = GetFirstItemInInventory(oDC2);
    while (GetIsObjectValid(oItem))
    {
        DestroyObject(oItem);
        oItem = GetNextItemInInventory(oDC2);
    }

    // remove equipted items if required
    if (!nLoot || nStrip)
    {
        int i;
        for(i = 0; i < NUM_PC_INVENTORY_SLOTS; i++)
        {
            DestroyObject(GetItemInSlot(i, oDC2));
        }
    }

    // destroy HotU friendly player corpse
    AssignCommand(oDC2, SetIsDestroyable(TRUE, FALSE, FALSE));
    DestroyObject(oDC2);
}
//::////////////////////////////////////////////////////////////////////////////
void CopyToFugue(object oDC)
{
    string sID = GetLocalString(oDC, "DC2Key");
    object oMod = GetModule();
    object oDC2 = GetLocalObject(oMod, "DC2" + sID);

    // create copy of HotU friendly player corpse
    object oCopyDC = CopyObject(oDC2, GetLocation(GetObjectByTag("HC_CORPSELOC")), OBJECT_INVALID);
    AssignCommand(oCopyDC, SetIsDestroyable(FALSE, FALSE, FALSE));

    // update stored corpse
    SetLocalObject(oMod, "DC2" + sID, oCopyDC);

    // remove inventory items
    object oItem = GetFirstItemInInventory(oDC2);
    while (GetIsObjectValid(oItem))
    {
        DestroyObject(oItem);
        oItem = GetNextItemInInventory(oDC2);
    }

    // remove equipted items if required
    if (!nLoot || nStrip)
    {
        int i;
        for(i = 0; i < NUM_PC_INVENTORY_SLOTS; i++)
        {
            DestroyObject(GetItemInSlot(i, oDC2));
        }
    }

    // destroy original HotU friendly player corpse
    AssignCommand(oDC2, SetIsDestroyable(TRUE, FALSE, FALSE));
    DestroyObject(oDC2);
}
//::////////////////////////////////////////////////////////////////////////////
object CopyFromFugue(object oOwner, object oDropper, object oDropped)
{
    string sID = GetLocalString(oDropped, "Name") + GetLocalString(oDropped, "Key");
    object oMod = GetModule();
    object oDC2 = GetLocalObject(oMod, "DC2" + sID);

    // if a corpse is still in area do not create new one.
    if(GetArea(oDC2) == GetArea(oDropper))
        return OBJECT_INVALID;

    // use drop location as default unless oDropper is logging out or dead
    location lLoc = GetLocation(oDropper);
    if(GetArea(oDropper) == OBJECT_INVALID || GetLocalInt(oDropper, "DEAD"))
    {
        lLoc = GetPersistentLocation(oMod, "DIED_HERE" + sID);

        // create random location to prevent stacking corpses
        float fRand = IntToFloat(d20(1))/10.0;
        vector vRand = Vector(0.0 + fRand, 0.6 + fRand, 0.0);
        vector vCorpse = GetPositionFromLocation(lLoc) + vRand;
        lLoc = Location(GetAreaFromLocation(lLoc), vCorpse, 0.0);

        DeleteLocalInt(oDropper, "DEAD");
    }

    // create copy HotU friendly player corpse
    object oCopyDC = CopyObject(oDC2, lLoc, OBJECT_INVALID);
    AssignCommand(oCopyDC, SetIsDestroyable(FALSE, FALSE, FALSE));
    ChangeToStandardFaction(oDC2, STANDARD_FACTION_COMMONER);

    // update association with new invisible corpse and store copy corpse
    object oDeathCorpse = CreateObject(OBJECT_TYPE_PLACEABLE, "DC", GetLocation(oCopyDC));
    SetLocalString(oDeathCorpse, "DC2Key", sID);
    SetLocalObject(oMod, "DC2" + sID, oCopyDC);

    // destroy original HotU friendly player corpse
    AssignCommand(oDC2, SetIsDestroyable(TRUE, FALSE, FALSE));
    DestroyObject(oDC2);

    return oDeathCorpse;
}
//::////////////////////////////////////////////////////////////////////////////
//void main(){}
Back to top
View user's profile Send private message
Frang



Joined: 22 May 2005
Posts: 32

PostPosted: Tue Nov 14, 2006 9:28    Post subject: Reply with quote

Adding in the line of code to the dethbag and time script is the problem...the hcr code has changed and those functions in the dbag and time script are no longer there so just skip those parts and not add the code in. Remove the code you added to these 2 scripts and all should be fine.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group