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 
 
NWNX Letoscript - modifying PCs
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support
View previous topic :: View next topic  
Author Message
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Tue Mar 02, 2010 21:52    Post subject: NWNX Letoscript - modifying PCs Reply with quote

I feel sully and sick for my search on info about letoscript and I havent found heads or tails of it.

I DONT CARE ANYMORE
I just want it to work, I dont care wether I understand it or not.

What I need is a way to modify PC characters, preferably bootlessly, but not necessarily...
What I have accomplished so far is that "NWNX-Leto 03+26" is in and working.

...I dont have any "inc_letoscripts" (Or any other leto related scripts) which seems to be referenced EVERYWHERE, but offered nowhere. Mad

I would heartily appreciate if someone could help me with this. Confused
Back to top
View user's profile Send private message
ArielT



Joined: 26 Jan 2010
Posts: 30

PostPosted: Wed Mar 03, 2010 10:43    Post subject: Reply with quote

I would suggest digging through Primogenitor's script compilation here. It has the LETOscript include you want. To see it implemented, look for the PRC's script driven character creator in the vault.
Back to top
View user's profile Send private message MSN Messenger
Terra_777



Joined: 27 Jun 2008
Posts: 216
Location: Sweden

PostPosted: Wed Mar 03, 2010 14:39    Post subject: Reply with quote

The leto wrapper I wrote long ago. The functions "generates" a letoscript that is stacked into a string variable and passed to the read/write functions, not sure if it works nowdays but here goes:

Code:
//::Constants
//::---------------------------------------------------------------------------
const string    SERVERVAULT         = "./servervault/";

//::Prototypes
//::---------------------------------------------------------------------------

//::Returns true if leto is online
int Leto_GetIsOnline( );

//::Returns the path to oPC's file
string Leto_GetBicPath( object oPC );

//::Executes a letoscript that will alter the character file
//::This function will boot the PC
//::NOTE This function should not run on the PC as (s)he'll's getting booted
//::Use the GenerateLetoScript* functions to setup a script
//::Example:
//::string sScript = GenerateLetoScriptSetAbility( ABILITY_CHARISMA, 10 );
//::sScript += GenerateLetoScriptAddFeat( FEAT_EPIC_DEVASTATING_CRITICAL_HANDAXE );
//::ExecuteFileWritingOperation(oPC, sScript );
//::Result: The PC is booted and when he logs in he'll have devcrit handaxe and 10 cha
void Leto_ExecuteFileWritingOperation( object oPC, string sScript, int nBoot = TRUE );

//::Executes a file reading leto script
//::This does not require booting
//::Fields:
//::------
//::FirstName
//::LastName
//::Description
//::DescriptionOverr
//::IsPC
//::IsDM
//::Tag
//::Conversation
//::Interuptable
//::Age
//::Gender
//::Race
//::Subrace
//::StartingPackage
//::Deity
//::MClassLevUpIn
//::willbonus
//::fortbonus
//::refbonus
//::Gold
//::BaseAttackBonus
//::RefSaveThrow
//::WillSaveThrow
//::FortSaveThrow
//::ArmorClass
//::OverrideBAB
//::Str
//::Dex
//::Int
//::Wis
//::Con
//::Cha
//::NeutralAC
//::SoundSetFile
//::FootstepType
//::Plot
//::NoPermaDeath
//::Disarmable
//::BodyBag
//::HitPoints
//::CurrentHitPoints
//::MaxHitPoints
//::PregameCurrent
//::Experiance
//::MovementRate
//::Portait
//::GoodEvil
//::LawfulChaotic
//::Color_Skin
//::Color_Hair
//::Color_Tattoo1
//::Color_Tattoo2
//::Phenotype
//::Appearance_Type
//::Appearance_Head
//::Tail_New
//::Wings_New
//::FactionID
//::ChallengeRating
//::BodyPart_Neck
//::BodyPart_Torso
//::BodyPart_Belt
//::BodyPart_Pelvis
//::BodyPart_LShoul
//::BodyPart_LBicep
//::BodyPart_LFArm
//::BodyPart_LHand
//::BodyPart_LThigh
//::BodyPart_LShin
//::BodyPart_LFoot
//::BodyPart_RShoul
//::BodyPart_RBicep
//::BodyPart_RFArm
//::BodyPart_RHand
//::BodyPart_RThigh
//::BodyPart_RShin
//::BodyPart_RFoot
//::CompanionType
//::CompanionName
//::SkillPoints
//::DetectMode
//::StealthMode
//::MasterID
//::CreatureSize
//::IsDestroyable
//::IsCommandable
//::IsImmortal
//::Lootable
//::BodyBagId
//::DecayTime
//::TemplateResRef
//::ScriptHeartBeat
//::ScriptOnNotice
//::SctiptSpellAt
//::ScriptAttacked
//::ScriptDamaged
//::ScriptDisturbed
//::ScriptEndRound
//::ScriptDialogue
//::ScriptSpawn
//::ScriptRested
//::ScriptDeath
//::ScriptUserDefine
//::ScriptOnBlocked
//::CombatRoundData
//::AreaId
//::SitObject
//::AmbientAnimState
//::CreatnScrtFird
//::CreatnScrptFird
//::PM_IsPolymorphed
//::Listening
//::XPosition
//::YPosition
//::ZPosition
//::XOrientation
//::YOrientation
//::ZOrientation
//::AnimationDay
//::AnimationTime
//::EncounterObject
string Leto_ExecuteFileReadingOperation( object oPC, string sFieldToRead );

//::Return letoscript code to change the racial on oPC
//::Use ExecuteFileWritingOperation() to execute the script
//::All strings GenerateLeto* functions returns are stackable
//::Fields:
//::------
//::FirstName
//::LastName
//::Description
//::DescriptionOverr
//::IsPC
//::IsDM
//::Tag
//::Conversation
//::Interuptable
//::Age
//::Gender
//::Race
//::Subrace
//::StartingPackage
//::Deity
//::MClassLevUpIn
//::willbonus
//::fortbonus
//::refbonus
//::Gold
//::BaseAttackBonus
//::RefSaveThrow
//::WillSaveThrow
//::FortSaveThrow
//::ArmorClass
//::OverrideBAB
//::Str
//::Dex
//::Int
//::Wis
//::Con
//::Cha
//::NeutralAC
//::SoundSetFile
//::FootstepType
//::Plot
//::NoPermaDeath
//::Disarmable
//::BodyBag
//::HitPoints
//::CurrentHitPoints
//::MaxHitPoints
//::PregameCurrent
//::Experiance
//::MovementRate
//::Portait
//::GoodEvil
//::LawfulChaotic
//::Color_Skin
//::Color_Hair
//::Color_Tattoo1
//::Color_Tattoo2
//::Phenotype
//::Appearance_Type
//::Appearance_Head
//::Tail_New
//::Wings_New
//::FactionID
//::ChallengeRating
//::BodyPart_Neck
//::BodyPart_Torso
//::BodyPart_Belt
//::BodyPart_Pelvis
//::BodyPart_LShoul
//::BodyPart_LBicep
//::BodyPart_LFArm
//::BodyPart_LHand
//::BodyPart_LThigh
//::BodyPart_LShin
//::BodyPart_LFoot
//::BodyPart_RShoul
//::BodyPart_RBicep
//::BodyPart_RFArm
//::BodyPart_RHand
//::BodyPart_RThigh
//::BodyPart_RShin
//::BodyPart_RFoot
//::CompanionType
//::CompanionName
//::SkillPoints
//::DetectMode
//::StealthMode
//::MasterID
//::CreatureSize
//::IsDestroyable
//::IsCommandable
//::IsImmortal
//::Lootable
//::BodyBagId
//::DecayTime
//::TemplateResRef
//::ScriptHeartBeat
//::ScriptOnNotice
//::SctiptSpellAt
//::ScriptAttacked
//::ScriptDamaged
//::ScriptDisturbed
//::ScriptEndRound
//::ScriptDialogue
//::ScriptSpawn
//::ScriptRested
//::ScriptDeath
//::ScriptUserDefine
//::ScriptOnBlocked
//::CombatRoundData
//::AreaId
//::SitObject
//::AmbientAnimState
//::CreatnScrtFird
//::CreatnScrptFird
//::PM_IsPolymorphed
//::Listening
//::XPosition
//::YPosition
//::ZPosition
//::XOrientation
//::YOrientation
//::ZOrientation
//::AnimationDay
//::AnimationTime
//::EncounterObject
string Leto_GenerateLetoScriptChangeBicField( string sBicField, string sValue );

//::Return letoscript code to modify a skill on oPC
//::Use ExecuteFileWritingOperation() to execute the script
//::All strings GenerateLeto* functions returns are stackable
//::nLevel determines which level in the bicfield the modification
//::should be linked to if that level is undone so is the letochange
//::if nLevel = -1 no levellist changing will happen
//::SKILL_* constants are used
string Leto_GenerateLetoScriptModifySkill( int nSkill, int nModify, int nLevel = -1 );

//::Return letoscript code to add nFeat to oPC
//::Use ExecuteFileWritingOperation() to execute the script
//::All strings GenerateLeto* functions returns are stackable
//::nLevel determines which level in the bicfield the modification
//::should be linked to if that level is undone so is the letochange
//::if nLevel = -1 no levellist changing will happen
string Leto_GenerateLetoScriptAddFeat( int nFeat, int nLevel = -1 );

//::Return letoscript code to remove nFeat from oPC
//::Use ExecuteFileWritingOperation() to execute the script
//::All strings GenerateLeto* functions returns are stackable
string Leto_GenerateLetoScriptRemoveFeat( int nFeat );

//::Return letoscript code to modify a ability score on oPC
//::Use ExecuteFileWritingOperation() to execute the script
//::All strings GenerateLeto* functions returns are stackable
//::ABILITY_* constants are used to determin ability
//::Note nwn handles its own races for example if you want a elf
//::to have 10 con you'd have to set nSet to 12 as nwn is subracting 2
string Leto_GenerateLetoScriptModifyAbility( int nAbility, int nSet );

//::Function definitions
//::---------------------------------------------------------------------------
string Leto_GenerateLetoScriptModifySkill( int nSkill, int nModify, int nLevel = -1 ){

    if( nLevel == -1 )return  "/SkillList/["+ IntToString( nSkill ) +"]/Rank = /SkillList/["+ IntToString( nSkill ) +"]/Rank +"+IntToString( nModify )+"; ";
    nLevel--;
    return  "/SkillList/["+ IntToString( nSkill ) +"]/Rank = /SkillList/["+ IntToString( nSkill ) +"]/Rank +"+IntToString( nModify )+"; "+
            "/LvlStatList/["+ IntToString( nLevel ) +"]/SkillList/["+ IntToString( nSkill ) +"]/Rank = "+IntToString( nModify )+"; ";

}
//::---------------------------------------------------------------------------
string Leto_GenerateLetoScriptChangeBicField( string sBicField, string sValue ){

    return "/" + sBicField + "='" + sValue + "';";
}
//::---------------------------------------------------------------------------
string Leto_GenerateLetoScriptModifyAbility( int nAbility, int nMod ){

    string sAbility;

    switch( nAbility ){

    case ABILITY_CHARISMA: sAbility = "Cha";break;
    case ABILITY_CONSTITUTION: sAbility = "Con";break;
    case ABILITY_DEXTERITY: sAbility = "Dex";break;
    case ABILITY_INTELLIGENCE: sAbility = "Int";break;
    case ABILITY_STRENGTH: sAbility = "Str";break;
    case ABILITY_WISDOM: sAbility = "Wis";break;

    default: return "";
    }

    return "/"+sAbility+" += '" +IntToString( nMod )+ "';";
}
//::---------------------------------------------------------------------------
string Leto_GenerateLetoScriptRemoveFeat( int nFeat ){

    return "replace 'Feat', " + IntToString( nFeat ) + ", DeleteParent;";
}
//::---------------------------------------------------------------------------
string Leto_GenerateLetoScriptAddFeat( int nFeat, int nLevel = -1 ){

    if( nLevel == -1 )return "add /FeatList/Feat, "+IntToString( nFeat )+", gffWord;";
    nLevel--;
    return  "add /FeatList/Feat, "+IntToString( nFeat )+", gffWord;"+
            "add /LvlStatList/["+ IntToString( nLevel ) +"]/FeatList/Feat, "+IntToString( nFeat )+", gffWord;";

}
//::---------------------------------------------------------------------------
string Leto_ExecuteFileReadingOperation( object oPC, string sFieldToRead ){

    object oMod = GetModule();

    string sPath = Leto_GetBicPath( oPC );

    string sEXEScript =
        "$RealFile = q<" + sPath + ">;"    +
        "$EditFile = $RealFile + '.utc';"              +
        "FileRename $RealFile, $EditFile;"             +
        "%bic = $EditFile or die;"                     +
        "print /" + sFieldToRead + ";"                 +
        "%bic = '>';"                                  +
        "close %bic;"                                  +
        "FileRename $EditFile, $RealFile;";

    SetLocalString( oMod, "NWNX!LETO!SCRIPT", sEXEScript );

    return GetLocalString( oMod, "NWNX!LETO!SCRIPT" );
}
//::---------------------------------------------------------------------------
void Leto_ExecuteFileWritingOperation( object oPC, string sScript, int nBoot = TRUE ){

    string sPath = Leto_GetBicPath( oPC );

    if( nBoot )
        BootPC( oPC );

    string sEXEScript =
        "$RealFile = q<" + sPath + ">;"    +
        "$EditFile = $RealFile + '.utc';"              +
        "FileRename $RealFile, $EditFile;"             +
        "%bic = $EditFile or die;"                     +
        sScript                                        +
        "%bic = '>';"                                  +
        "close %bic;"                                  +
        "FileRename $EditFile, $RealFile;";

    SetLocalString( GetModule( ), "NWNX!LETO!SCRIPT", sEXEScript );
}
//::---------------------------------------------------------------------------
string Leto_GetBicPath( object oPC ){

    ExportSingleCharacter( oPC );

    object oMod     = GetModule();

    string sPath    = SERVERVAULT + GetPCPlayerName( oPC ) + "/";

    SetLocalString( oMod, "NWNX!LETO!SCRIPT", "print q<" + sPath + "> + FindNewestBic q<" + sPath + ">;" );

    return GetLocalString( oMod, "NWNX!LETO!SCRIPT" );
}
//::---------------------------------------------------------------------------
int Leto_GetIsOnline( ){
    SetLocalString( GetModule( ), "NWNX!LETO!SCRIPT", "print 'is_very_alive_today'" );
    return ( GetLocalString( GetModule( ), "NWNX!LETO!SCRIPT" ) == "is_very_alive_today" ? TRUE: FALSE );
}




//::Main; uncomment for testing
//::---------------------------------------------------------------------------
//void main(){}

_________________
I dun have any signature, I'm happy anyway.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Wed Mar 03, 2010 15:33    Post subject: Reply with quote

ArielT wrote:
I would suggest digging through Primogenitor's script compilation here. It has the LETOscript include you want. To see it implemented, look for the PRC's script driven character creator in the vault.


Thanks.

I took the includes and checked the PRC convo and replicated as best I could, but it didnt work at all...

Terra_777 wrote:
The leto wrapper I wrote long ago. The functions "generates" a letoscript that is stacked into a string variable and passed to the read/write functions, not sure if it works nowdays but here goes:


Thanks, this script looked very promising but... Well just read the //'s...
I named your script 'inc_letoscript' and set the servervault path correctly.
Code:

#include "inc_letoscript"
void main()
{
    object oPC = GetLastUsedBy();
    string sScript;
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_STRENGTH, 10);
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_DEXTERITY, 10);
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_CONSTITUTION, 10);
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_WISDOM, 10);
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_INTELLIGENCE, 10);
    sScript += Leto_GenerateLetoScriptModifyAbility(ABILITY_CHARISMA, 10);

    // Need a way to remove ALL feats and skills :<

    sScript += Leto_GenerateLetoScriptAddFeat(2);  // Heavy
    sScript += Leto_GenerateLetoScriptAddFeat(3);  // Light
    sScript += Leto_GenerateLetoScriptAddFeat(4);  // Medium
    sScript += Leto_GenerateLetoScriptAddFeat(32); // Shield
    sScript += Leto_GenerateLetoScriptAddFeat(42); // Finesse
    sScript += Leto_GenerateLetoScriptAddFeat(44); // Exotic
    sScript += Leto_GenerateLetoScriptAddFeat(45); // Martial
    sScript += Leto_GenerateLetoScriptAddFeat(46); // Simple

    // Need a way to set hitpoints too :s

    Leto_ExecuteFileWritingOperation(oPC, sScript);

    // Aaaand the thing isnt working at all... :C
}


This makes no sense! I did the test message thing and it worked just fine in both cases!
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Wed Mar 03, 2010 19:11    Post subject: Reply with quote

Wasn't there something about using letoscript 24 because it's the most stable?

Aside from that try to run this simple script to see if letoscript works at all

Code:
void main() {
   string sBic = "divinewarrior.bic";
   string sLeto = "%char= q{localvault/"+sBic+"}; print /FirstName; %char = '>'; close %char; ";
   SetLocalString(GetModule(), "NWNX!LETO!SCRIPT", sLeto);
   WriteTimestampedLogEntry(GetLocalString(GetModule(), "NWNX!LETO!SCRIPT"));
}


This prints the first name of divinewarrior.bic in the server's localvault folder to the server log.
I copied the divinewarrior.bic to the server's localvault folder but you can use any bic file you want.

Posting the nwnx_leto log might be helpful too.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Wed Mar 03, 2010 19:32    Post subject: Reply with quote

Never used log files before, I assume nwnx.txt is the server log?

Code:
NWN Extender V.2.6.1
(c) 2005 by Ingmar Stieger (Papillon) and Jeroen Broekhuizen
visit us at http://www.nwnx.org

* Loading plugins...
* Plugin leto is loaded.
* NWNX2 activated.
* NWNX2 shutting down...
* NWNX2 shutdown successfull.


And I assume the leto log is .txt too? (nwnx_leto.txt)

Code:
NWNX-Leto module (build 03 - FF)
(c) 2004 by David Frauzel (dragonsong), dragon@weathersong.net
Information and support: http://weathersong.infopop.cc

* Loading LetoScript.dll...
* LetoScript metamodule activated (27.62ms).
<306.8µs> Req:"SCRIPT", Param:"%char= q{localvault/haminmeyne.bic}; print /FirstName; %char = '>'; close %char; "
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Wed Mar 03, 2010 20:10    Post subject: Reply with quote

xardex wrote:
Never used log files before, I assume nwnx.txt is the server log?


The main server log is "nwserverlog1.txt" (It'll be there whether nwnx is used or not).

The letoscript part looks good to me, so if the server log shows the firstname of hamineyne.bic letoscript is setup correctly and we can go on to figure out why your scripts don't do what you want.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Wed Mar 03, 2010 22:12    Post subject: Reply with quote

No such file found on the entire hard drive!

Maybe some logging option is turned off?
Tried enabling some stuff on the .ini's but still no such file found.
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Thu Mar 04, 2010 5:22    Post subject: Reply with quote

xardex wrote:
No such file found on the entire hard drive!

Maybe some logging option is turned off?
Tried enabling some stuff on the .ini's but still no such file found.


Uhm.... Shocked
It should be in the same folder (is the server running on windows?) as nwnx.txt

I'm not sure if there is even an option to turn the log off but the standard server installation defenitly has it turned on.
Check the nwn.ini. There should be a line reading LOGS=.\logs
Maybe it's pointing to a nonexistent folder.

Anyways, just change the little script I posted earlier to the following
Code:
void main() {
   string sBic = "divinewarrior.bic";
   string sLeto = "%char= q{localvault/"+sBic+"}; print /FirstName; %char = '>'; close %char; ";
   SetLocalString(GetModule(), "NWNX!LETO!SCRIPT", sLeto);
   SendMessageToPC(GetFirstPC(), "::"+GetLocalString(GetModule(), "NWNX!LETO!SCRIPT"));
}

Make sure you are the only player on the server when you test this. Instead of going to the log file it will be sent to your character's combat log.
Back to top
View user's profile Send private message Send e-mail MSN Messenger
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Thu Mar 04, 2010 8:49    Post subject: Reply with quote

Well it sent me this...



And the logs=.\logs was there.
Back to top
View user's profile Send private message
Fireboar



Joined: 17 Feb 2008
Posts: 323

PostPosted: Thu Mar 04, 2010 12:19    Post subject: Reply with quote

As already mentioned, make sure you're using 3+24, not 3+26 or 3+25.
Back to top
View user's profile Send private message
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Thu Mar 04, 2010 12:43    Post subject: Reply with quote

Well I switched to 03+24, now there is no access violation but there isnt anything else either.
(just the "::")

*sigh* Crying or Very sad

I suppose it doesnt work then after all...
But why did the test message work and this not?..


Btw just a thought, but wouldnt it be possible to access and edit the games memory while its running instead of the files?
Assuming the server doesnt blow up or crash the clients, shouldnt it allow you to manipulate character stats on the fly?

You could store the character stuff on some objects locals in the game and apply them from there everytime the character reconnects, as it loads the stuff from the file...

...Im in way over my head... Laughing
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Thu Mar 04, 2010 18:44    Post subject: Reply with quote

You can have the memory edit option if you're running a linux server. I don't think anybody ever got around to port this to windows.

I know it sounds silly but: Is there actually a file called haminmeyne.bic in the localvault folder of the server?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
xardex



Joined: 02 Mar 2010
Posts: 40

PostPosted: Thu Mar 04, 2010 19:38    Post subject: Reply with quote

Mhh, thats a shame that no ones done it for windows. Confused
I dont have linux.

And I finally got the name to show up!
(It works now)

...I had mispelled the name...


EDIT

Alright, tested it out again. (The script I posted earlier)
Still didnt work... Confused
Back to top
View user's profile Send private message
MaxRock



Joined: 24 Jan 2008
Posts: 196

PostPosted: Thu Mar 04, 2010 20:41    Post subject: Reply with quote

can you post the nwnx_leto log again?
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    nwnx.org Forum Index -> Windows technical support All times are GMT + 2 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
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