View previous topic :: View next topic |
Author |
Message |
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Thu Apr 09, 2009 17:41 Post subject: letoscript and subraces |
|
|
I've been trying to get a subrace system to work with letoscript, but to no avail. I'm not exactly sure what I'm doing wrong as I am not too familiar with leto. I do know that my character deletion functions work fine though.
This is the log of a simple ability adjustment
Code: |
$RealFile = q<C:/NeverwinterNights/NWN/servervault/graysage313/belilutgenk.bic>;$EditFile = $RealFile + '.utc';FileRename $RealFile, $EditFile;%bic = $EditFile or die;/Dex = /Dex + -2;/Con = /Con + 2;%bic = '>';close %bic;FileRename $EditFile, $RealFile;
|
and here are the functions used
Code: |
string LetoAdjustAbility(int iAbility, int iModifier) {
string sAbility;
if (iAbility == ABILITY_STRENGTH) sAbility = "Str";
else if (iAbility == ABILITY_DEXTERITY) sAbility = "Dex";
else if (iAbility == ABILITY_CONSTITUTION) sAbility = "Con";
else if (iAbility == ABILITY_INTELLIGENCE) sAbility = "Int";
else if (iAbility == ABILITY_WISDOM) sAbility = "Wis";
else if (iAbility == ABILITY_CHARISMA) sAbility = "Cha";
else sAbility = "ABILITY ERROR!";
return "/" + sAbility + " = /" + sAbility + " + " + IntToString(iModifier) + ";";
}
void ApplyLetoScriptToPC(string Script, object oPC) {
string BicFile = LetoGetBicFilePath(oPC);
Script =
"$RealFile = q<" + BicFile + ">;" +
"$EditFile = $RealFile + '.utc';" +
"FileRename $RealFile, $EditFile;" +
"%bic = $EditFile or die;" +
Script +
"%bic = '>';" +
"close %bic;" +
"FileRename $EditFile, $RealFile;";
PrintString(Script);
SetLocalString(oPC, "LetoScript", Script);
string sMessage = "Please relog to apply your modifications.";
DelayCommand(1.0, PopUpDeathGUIPanel(oPC, FALSE, FALSE, FALSE, sMessage));
}
void LetoPCEnter(object oPC) {
SetLocalString(oPC, "LetoScript", "");
}
void LetoPCExit(object oPC) {
string Script = GetLocalString(oPC, "LetoScript");
if( Script != "" ) {
DeleteLocalString(oPC, "LetoScript");
LetoScript(Script);
}
}
|
Any help or advice would be greatly appreciated! |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Fri Apr 10, 2009 17:22 Post subject: |
|
|
What exactly isn't working? One thing I see offhand is this:
/Dex + -2
You don't need the plus there, though I somewhat doubt that's the issue. The most likely problems are:
-You haven't installed the leto plugin in the right place - check your nwnx.txt log in logs.0 to see if it says the leto plugin is loading.
-You're using a bad way of getting the bic file to edit. Confirm that the file name in the leto log matches the name of the character you attempted to apply those edits to, and not the character you had logged in BEFORE that character. You should also post your LetoGetBicFilePath(oPC) function.
Funky |
|
Back to top |
|
|
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Fri Apr 10, 2009 18:47 Post subject: |
|
|
The main problem is simply that the abiity modifiers dont apply. The player is presented with the death GUI, just no mods when you log back in. I did check carefully to make sure that it was the right toon being editied.
leto plugin is definitely lodaing and has been functioning properly for character deletion for a good month now.
Here is the GetBic function I am using.
Code: |
string LetoGetBicFilePath (object oPC) {
//you MUST put the correct path for your servervault in this string, samples below:
//string sVaultPath = "/home/funkyswerve/nwn/servervault/";
string sVaultPath = "C:/NeverwinterNights/NWN/servervault/";
string sBicPath = sVaultPath + GetPCPlayerName(oPC) + "/";
return LetoScript("print q<" + sBicPath + "> + " + "FindNewestBic q<" + sBicPath + ">;");
}
|
I thought that I had gotten the plugin from the Vault where HGLL is. I could be mistaken though. If you think that's the problem then I can attempt to re-install it again. |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Sat Apr 11, 2009 3:06 Post subject: |
|
|
That's your problem. FindNewestBic requires an Export well before it fires, to update the character timestamp so that the correct bic is found. It's editing the wrong ones.
This code shows one way to achieve that, though not the best:
Code: | string LetoScript(string script) {
// Stores a var in the module which NWNX LETO then takes and works with.
SetLocalString(GetModule(), "NWNX!LETO!SCRIPT", script);
// Gets the var now changed by NWNX LETO back from the module and returns it.
return GetLocalString(GetModule(), "NWNX!LETO!SCRIPT");
}
string GetBicPath(object PC)
{
string VaultPath = "C:/NeverwinterNights/NWN/servervault/";//this should be set to the path of your servervault
string Player = GetPCPlayerName(PC);
string BicPath = VaultPath + Player + "/";
return LetoScript(
"print q<" + BicPath + "> + " +
"FindNewestBic q<" + BicPath + ">;"
);
}
void RepeatFloatingTextStringOnCreature(object Object, string String, float Delay = 3.0, int Times = -1)
{
if(GetPCPlayerName(Object) == "") return;
if(Times == 0) return;
FloatingTextStringOnCreature(String, Object);
DelayCommand(Delay, RepeatFloatingTextStringOnCreature(Object, String, Delay, Times));
if(Times) Times--;
}
void ApplyLetoScriptToPC(string Script, object oPC)
{
//object M = GetModule();
string Player = GetPCPlayerName(oPC);
string BicFile = GetBicPath(oPC);
Script =
"$RealFile = q<" + BicFile + ">;" +
"$EditFile = $RealFile + '.utc';" +
"FileRename $RealFile, $EditFile;" +
"%bic = $EditFile or die;" +
Script +
"%bic = '>';" +
"close %bic;" +
"FileRename $EditFile, $RealFile;";
SetLocalString(oPC, "LetoScript", Script);
//Ask player to relog rather than booting them since they could crash server if they log out after boot delaycommanded but before executed
//alternatively you can boot with a validity check
RepeatFloatingTextStringOnCreature(oPC, "Please relog for feat addition.");
}
void SetPCName(object oPC, string sFirstName, string sLastName)
{
ExportSingleCharacter(oPC);
//below string should contain all the changes you want to make - in this case, just first and last name
string Script = "/FirstName = q~" + sFirstName +"~';/LastName = q~" + sLastName + "~;";
//this is delayed so that the export can complete updating (saving) the bic before leto looks for the newest bic with FindNewestBic
AssignCommand(oPC, DelayCommand( 3.0f, ApplyLetoScriptToPC(Script, oPC)));
} |
Sorry for lack of indents, I have that saved on my forum board and it kills them.
The above way will work about 99% of the time, but will occasionally fail in lag. Here's a thread explaining the best, foolproof way to get bic path, and why:
http://nwn.bioware.com/forums/viewtopic.html?topic=637992&forum=47&highlight=specialist
Funky |
|
Back to top |
|
|
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Sun Apr 12, 2009 11:30 Post subject: |
|
|
First off, thank you Funky for the help.
Ok I went ahead and expanded the time between the export I have in my on enter script that fires the subrace script
Here is a segment from the onenter script
Code: |
ExportSingleCharacter(oPC);
SetCutsceneMode(oPC, TRUE);
DelayCommand(10.0, SetCutsceneMode(oPC, FALSE));
DelayCommand(2.0, FloatingTextStringOnCreature("Applying subrace...", oPC));
DelayCommand(2.0, ApplyEffectToObject(0, EffectVisualEffect(VFX_FNF_SUMMON_GATE), oPC));
DelayCommand(3.0, ApplySubraceToPC(oPC, sSubrace));
|
.. and then there is a further delay before leto is applied
Code: |
ExportSingleCharacter(oPC);
DelayCommand(6.0, ApplyLetoScriptToPC(sLeto, oPC));
|
I double checked to see if the correct file was being selected for edits. From the logs and the .utc's I ascertained that this was highly likely.
I also checked to see if maybe the '+ - 2 Dex' was causing the problem by just using the +2 Con modification and still to no effect. I also made sure that my leto plugin was up to date as per the HGLL leto plugin available on IGN Vault.
I am still not getting any results. As I mentioned before, my character deletion using leto is working great. |
|
Back to top |
|
|
FunkySwerve
Joined: 02 Jun 2005 Posts: 377
|
Posted: Mon Apr 13, 2009 7:47 Post subject: |
|
|
Exports fail oncliententer, as I explain in the post I linked you to.
Funky |
|
Back to top |
|
|
sificvoid
Joined: 01 Dec 2008 Posts: 9
|
Posted: Mon Apr 13, 2009 9:16 Post subject: |
|
|
Thanks for pointing that detail out. There is quite a bit of info in that one post so I guess I overlooked that.
After following up on your suggestion I realized that the problem was that I forget to put the call for LetoPCExit() in my on client exit script for my test module. Everything seems to work fine now, once again the help was greatly appreciated! |
|
Back to top |
|
|
|
|
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
|