Author Topic: Help with script  (Read 511 times)

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Help with script
« on: September 09, 2016, 05:03:38 PM »
Paul, this is a script that you wrote for NPCs memorizing spells when they joined the party. It does not compile.

Also, I remember that at some point later, we did this a different way, but I can't find that info anywhere (searched home computer, this computer, gmail and forum).

This script makes my head hurt when I try to figure out how it works. :D

Code: [Select]
$VAR spellbook;
$VAR schoolBook;

$FUNC MemorizeLevel(levelBook)
{
  $VAR numSpell;
  $VAR i;
  $VAR spellName;
  $DEBUG("levelSpells = " + levelBook);
  levelBook = $DelimitedStringTail(levelBook);
  numSpell = $DelimitedStringCount(levelBook);
  i = 0;
  $WHILE (1)
  {
    spellName = $DelimitedStringSubstring(levelBook,i);
    spellName = $DelimitedStringHead(spellName);
    $IF ($SelectSpell($CharacterContext(),spellName))
    {
      $DEBUG("Selecting " + spellName);
    }
    $ELSE
    {
      $RETURN;
    };
    i = (i +# 1) %# numSpell;
  };
} MemorizeLevel;

$FUNC MemorizeSchool(schoolBook)
{
  $VAR levelBook;
  $DEBUG("school spells = " + schoolBook);
  $WHILE (schoolBook)
  {
    levelBook = $DelimitedStringHead(schoolBook);
    MemorizeLevel(levelBook);
    schoolBook = $DelimitedStringTail(schoolBook);
  };
} MemorizeSchool;


spellbook = $GET_SPELLBOOK($CharacterContext(),"%@#&");

$WHILE (spellbook)
{
  schoolBook = $DelimitedStringHead(spellbook);
  MemorizeSchool(schoolBook);
  spellbook = $DelimitedStringTail(spellbook);
};
$Memorize($CharacterContext());

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #1 on: September 09, 2016, 05:15:33 PM »
$GET_SPELLBOOK is s marked as "Deprecated".  That's
Micro$oft talk meaning we don't support it any more.

I'll see what I can do to modify the script to work with
whatever we provided to replace that particular function.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #2 on: September 09, 2016, 05:33:05 PM »
Okay. :)

I don't know what we replaced it with, though. I will remove it from the Help docs

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #3 on: September 09, 2016, 06:32:18 PM »
I am going to try to restore this function.  It was
deprecated because it was very different after
we introduced the new spell id scheme.

Can I have a mini-mod, please?  With several
spells in several schools at several levels?

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #4 on: September 09, 2016, 06:37:17 PM »
Absolutely. I will make it tonight and attach it here when I get in tomorrow.

Thank you, Paul.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #5 on: September 10, 2016, 02:03:47 PM »
Mini-mod attached to this post.

I didn't know what they should do...so they don't do anything. You need to add the two characters to your party. One is a pre-generated NPC, one is a player generated PC. Both have spells from multiple Spell Schools.  Why a PC? Essentially the same thing as a pre-gen NPC, but more importantly, the PC has a class with 4 baseclasses, which NPCs cannot do.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #6 on: September 10, 2016, 03:35:28 PM »
I add the two characters.  Nothing happened.  Is a script
supposed to run?  What is supposed to trigger it?

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #7 on: September 10, 2016, 04:19:46 PM »
I add the two characters.  Nothing happened.  Is a script
supposed to run?  What is supposed to trigger it?

Nothing is supposed to happen. The script at the beginning of this thread doesn't compile, so I have never added it to the default database. I got this via an email exchange between you and I and it was provided in a data folder. The script was for a hook called JoinParty in an SA called JoinParty. JoinParty was added to the NPC. If you want me to set that up in the mini-mod I will do.
I'm usded to showing bugs with existing, not bugs with stuff we almos tadded, so wasn't sure how to proceed.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #8 on: September 10, 2016, 04:40:10 PM »
I'll try to add it myself.  If I fail, I will return.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #9 on: September 10, 2016, 05:06:06 PM »
Try this one...

Add the two characters to party and look to see if they have any spells memorized. They both have JoinParty attached.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #10 on: September 10, 2016, 06:07:05 PM »
Do you realize that the hook "JoinParty" is not implemented.
And not documented.  It is mentioned but nowhere that I
can find does it say when it is activated of what parameters it
might have, etc.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #11 on: September 10, 2016, 07:21:11 PM »
Also, nowhere does your script actually memorize a spell.
It simply prints the name of each spell using "$DEBUG".


Edit:  Sorry, I see it now.  You do "Selects" for each spell
followed by "Memorize". 
« Last Edit: September 10, 2016, 08:27:17 PM by Paul R. Stevens »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2139
Re: Help with script
« Reply #12 on: September 11, 2016, 03:09:45 PM »
Editor and engine version 2.53 worked for me to
memorize all those spells at the time the character
joined the party.  Here is the script I used:
Code: [Select]
$VAR spellbook;
$VAR schoolBook;

$FUNC MemorizeLevel(levelBook)
{
  $VAR spellName;
  //$DEBUG("levelSpells = " + levelBook);
  // Discard the level number
  levelBook = $DelimitedStringTail(levelBook);
  $WHILE (levelBook)
  {
    spellName = $DelimitedStringHead(levelBook);
    levelBook = $DelimitedStringTail(levelBook);
    spellName = $DelimitedStringHead(spellName);
    $SelectSpell($CharacterContext(),spellName);
    //{
    //  $DEBUG("Selecting " + spellName);
    //}
    //$ELSE
    //{
    //  $DEBUG("Failed to select" + spellName);
    //};
  };
} MemorizeLevel;

$FUNC MemorizeSchool(schoolBook)
{
  $VAR levelBook;
  $DEBUG("school spells = " + schoolBook);
  // Discard the school ID
  schoolBook = $DelimitedStringTail(schoolBook);
  $WHILE (schoolBook)
  {
    levelBook = $DelimitedStringHead(schoolBook);
    MemorizeLevel(levelBook);
    schoolBook = $DelimitedStringTail(schoolBook);
  };
} MemorizeSchool;


spellbook = $GET_SPELLBOOK($CharacterContext(),"%@#&");

$WHILE (spellbook)
{
  schoolBook = $DelimitedStringHead(spellbook);
  MemorizeSchool(schoolBook);
  spellbook = $DelimitedStringTail(spellbook);
};
$Memorize($CharacterContext());

I have updated some documentation and will update
some more later today or tomorrow.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #13 on: September 12, 2016, 04:48:28 PM »
Do you realize that the hook "JoinParty" is not implemented.
And not documented.  It is mentioned but nowhere that I
can find does it say when it is activated of what parameters it
might have, etc.

I copied this exactly from the email you had sent me. :) I hadn't gotten as far as trying to use it because the script would not compile

Also, nowhere does your script actually memorize a spell.
It simply prints the name of each spell using "$DEBUG".


Edit:  Sorry, I see it now.  You do "Selects" for each spell
followed by "Memorize". 
You wrote the original script. Creating functions is beond my skill level :) Well, I use them in the talk.bin but not in the special abilities database.

Editor and engine version 2.53 worked for me to
memorize all those spells at the time the character
joined the party.  Here is the script I used:
Code: [Select]
$VAR spellbook;
$VAR schoolBook;

$FUNC MemorizeLevel(levelBook)
{
  $VAR spellName;
  //$DEBUG("levelSpells = " + levelBook);
  // Discard the level number
  levelBook = $DelimitedStringTail(levelBook);
  $WHILE (levelBook)
  {
    spellName = $DelimitedStringHead(levelBook);
    levelBook = $DelimitedStringTail(levelBook);
    spellName = $DelimitedStringHead(spellName);
    $SelectSpell($CharacterContext(),spellName);
    //{
    //  $DEBUG("Selecting " + spellName);
    //}
    //$ELSE
    //{
    //  $DEBUG("Failed to select" + spellName);
    //};
  };
} MemorizeLevel;

$FUNC MemorizeSchool(schoolBook)
{
  $VAR levelBook;
  $DEBUG("school spells = " + schoolBook);
  // Discard the school ID
  schoolBook = $DelimitedStringTail(schoolBook);
  $WHILE (schoolBook)
  {
    levelBook = $DelimitedStringHead(schoolBook);
    MemorizeLevel(levelBook);
    schoolBook = $DelimitedStringTail(schoolBook);
  };
} MemorizeSchool;


spellbook = $GET_SPELLBOOK($CharacterContext(),"%@#&");

$WHILE (spellbook)
{
  schoolBook = $DelimitedStringHead(spellbook);
  MemorizeSchool(schoolBook);
  spellbook = $DelimitedStringTail(spellbook);
};
$Memorize($CharacterContext());

I have updated some documentation and will update
some more later today or tomorrow.

Thank you, Paul. I will check this out this evening. What is the Hook to be used? I will go look through the documentation and see if I can find it.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9589
Re: Help with script
« Reply #14 on: September 12, 2016, 07:40:13 PM »
I guess I won't do this tonight - I can't seem to find the editor or engine anywhere.