Author Topic: Firebat Crash  (Read 201 times)

Offline StultusTemporis

  • Newbie
  • *
  • Posts: 38
Firebat Crash
« on: August 26, 2017, 12:40:07 PM »
Hello,

The firebat crashes Dungeon Craft after it attacks.  I am using DC 3.08 (which I think is the most recent version) on a Windows 10 computer.

I think this might be related to the fact that the SA's "monster_FireBatLink" and "monster_FireBatBloodCap" do not appear to be written yet.

Mini mod is attached.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9809
Re: Firebat Crash
« Reply #1 on: August 26, 2017, 02:12:13 PM »
Thanks for the mini-mod. :) I'll check it out.

Offline StultusTemporis

  • Newbie
  • *
  • Posts: 38
Re: Firebat Crash
« Reply #2 on: September 03, 2017, 07:40:54 PM »
I'm going over the SA's for the firebat, in part so I can figure out how GPDL works, and in part to help find a solution to the crash.  I figure that if I break it down here, someone would be able to confirm if I'm understanding the parts to the function correctly.

There are 5 SA's that are linked to the firebat's drain attack: "monster_FireBatAttack", "monster_FireBatDrain", "monster_FireBatDrainee", "IsHugged", and "IsFleeing".  In addition, the scripts make mention of two other SA's that are not found elsewhere in specialAbilities.txt: "monster_FireBatLink" and "monster_FireBatBloodCap".  Let's start with "monster_FireBatAttack".

\(BEGIN)
name = monster_FireBatAttack     //Initiates the function.
[InvokeSpellOnTarget] = $VAR atk; // attacker     //Defines the variable "atk".  The firebat's bite casts the "monsterFireBatAttack" spell, which initiates this SA for a value of 2.
-$VAR tgt; // target     //Defines the variable "tgt".  Does not set it to a value yet.
-$VAR link;     //Defines the variable "link".  Does not set it to a value yet.
-atk = $IndexOf($AttackerContext());     //Sets "atk" to the firebat's ID.
-tgt = $IndexOf($TargetContext());     //Sets "tgt" to the bitten target's ID.
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatDrain","");     //Gives the firebat the "monster_FireBatDrain" SA.
-$IF ($GET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap") == "-?-?-")     //Checks if the firebat has the SA "monster_FireBatBloodCap", and whether that SA is equal to "-?-?-".  If yes, it continues.  If no, ?????.
-   {
-      $SET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap",3);     //Sets the SA "monster_FireBatBloodCap" to 3.
-   };
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatLink",tgt);     //Give the firebat the SA "monster_FireBatLink", with a value equal to "tgt" (previously defined as the attacked creature).
-$SET_COMBATANT_SA($TargetContext(),"monster_FireBatDrainee","");     //Give the target the "monster_FireBatDrainee" SA, which is not set to a value.
-$SET_COMBATANT_SA($TargetContext(),"IsHugged",1);     //Gives the target the "IsHugged" SA, which is set to a value of 1.
-link = $GET_COMBATANT_SA($TargetContext(),"monster_FireBatLink");     //Sets the variable "link" to the target of the attack, and to the combatant with the SA "monster_FireBatLink" (that is, the firebat).
-$IF (link == "-?-?-")     //Checks the value of "link".  If "link" is "-?-?-", then proceed.  If not, go to $ELSE.
-   {
-      $SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink","$255$" + atk);     //Gives the target the "monster_FireBatLink" SA, with a value equal to 255 plus the firebat's ID. 
-   }
-$ELSE     //If "link" is not equal to "-?-?-"
-   {
-      link = link + "$" + atk;     //Sets "link" to its current value plus the value of "$", plus the firebat's ID.
-      $SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink",link);     //Set's the target's instance of "monster_FireBatLink" to the new value of link.
-   };
\(END)     //Ends the script.

So, to summarize, we have told the program who the attacker and the target is, we've instructed the attacker to run the script "monster_FireBatDrain", we've instructed the target to run the script "monster_FireBatDrainee", and we've given both the firebat and the target the SA's "monster_FireBatLink".  We have also given the target the "IsHugged" SA.  We have also checked the firebat for the SA "monster_FireBatBloodCap", and, if it is equal to the default null value, set it to 3.  (Note that firebats do not, by default, have the "monster_FireBatBloodCap" SA). 

Please advise whether I have broken this down correctly, or if there is anything I am misunderstanding. 

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2229
Re: Firebat Crash
« Reply #3 on: September 03, 2017, 07:58:43 PM »
Manikus will return on Tuesday.  He wrote this and
will be able to reply more authoritatively.
You say:

Quote
we've instructed the target to run the script "monster_FireBatDrainee
and
we've instructed the attacker to run the script "monster_FireBatDrain

You may consider this a quibble with words but I don't believe
what you said is true.  What has happened is that the
target receives an SA named monster_FireBatDrainee  and  the
attacker receives an SA named monster_FireBatDrain.

Those two Special Abilities may have scripts that will be run
under some future circumstance (perhaps once per combat round,
for example) but they are not themselves scripts.

Special Ability processing is difficult to get one's head
around and I think that precise terminology is important
to avoid total confusion.

Offline StultusTemporis

  • Newbie
  • *
  • Posts: 38
Re: Firebat Crash
« Reply #4 on: September 03, 2017, 08:15:15 PM »
I think I understand.  That would explain why the SA "monster_FireBatLink" can be defined directly in the script that is attached to "monster_FireBatAttack" without having its own script written out defining it.  The SA is defined within the text of the script that references it.

Offline StultusTemporis

  • Newbie
  • *
  • Posts: 38
Re: Firebat Crash
« Reply #5 on: September 03, 2017, 08:33:02 PM »
In that case, should there be a line somewhere setting the default value of "monster_FireBatBloodCap" to "-?-?-", or does DC automatically assign the value to undefined SA's that work as variables?  The firebat does not currently have that SA listed in its entry in the Monster database, and it's not set elsewhere in SpecialAbilities.txt.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2229
Re: Firebat Crash
« Reply #6 on: September 03, 2017, 09:07:15 PM »
I have not the slightest idea what you said.  I think
you know what you said.  In any case, all of this is
hard work to understand.  How many times have I
had to explain it?  Each time I have to back off and
reprogram myself to get a good feel for it.

What is a special ability?
It is nothing more than a pair of character strings.
We call the first of the pair its 'name'.  We call the second
of the pair its 'value'.

Example:
$SET_COMBATANT_SA($TargetContext(),"IsHugged",1);

This gives the target a pair of strings: the name is "IsHugged"
and the value is "1".  It is like giving you a coin.  For example:
$GIVE_StultusTemporis_SA("Quarter", "25");
That is all that has happened.  You have a quarter worth 25 cents.

Later in the game a script may ask:
$GET_StultusTemporis_SA("Quarter");
Asking if you have a quarter and, if so, how much it
is worth.  If you do have a quarter, the answer will be "25".
If you don't have a quarter, the answer will be "-?-?-".

A script can give StultusTemporis a Special Ability with
any arbitrary name.  The letters in the name need not
ever have been written before that moment.  For example:

$GIVE_StultusTemporis_SA("X" + $RANDOM(3000), $RANDOM(25));

Mr. Temporis is now burdened with a Special Ability that
can never be removed because nobody can possibly know
what it is called (The first string of the pair; the SA's name).
I guess it could be removed by attempting
to remove all SA's starting with X0, X1, X2, X3,....., X2999.

[[[  Aside: If there are scripts associated with each of these then they could delete the SA ]]]
[[[  Aside: Might this be a useful way to run random scripts???  ]]]

==============================
Now, of course, there may be side-effects of your having
a quarter.  There is a database of scripts that are indexed
by names.  for example:
"Penny" has a script named "El-Cheapo".
"Penny" has a script named "Copper".
"Dollar" has a script named "Good-Tipper".
"Dollar" has a script named "Paper".
"Quarter" has a script named "Silver".

Scripts are associated with these names by
the designer.  They are permanent attributes
of the names.  They are not added or changed
during gameplay.  It may or may not be that any
Special Ability exists with the same names.  The
engine does not care.

At times during the play, the engine looks for scripts to
run.  For example, at the end of each diner, it might want
to run any "Good-Tipper" scripts for a character.  Does the
character have a "Good-Tipper" script?  To find out it looks
in the character's Special Abilities.  It looks at StultusTemporis'
SpecialAbilities.  It finds a "Quarter".  It then looks into its
database of scripts and finds "Quarter".  But "Quarter" does not
have any script named "Good-Tipper".  So no script is run.
If SutltusTempois had a SpecialAbility named "Dollar" then
the engine would run the script associated with that name
and the script might give Mr. Temporis an added hit-point.

Any questions, anybody?




Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9809
Re: Firebat Crash
« Reply #7 on: September 15, 2017, 04:57:05 PM »
Okay, I am looking into this right now....I cna't get it to crash, it just hangs on me. However, if I go and try to do some clicks in the hung engine window, it will then crash ( I did this after letting it sit for many, many minutes in the 10 to 15 range).

Unless there is some kind of recursive loop, the SAs are not the cause of this bug. After the current bug, this will the next one i send to Paul.

Offline ProphetSword

  • Mod Designer
  • Administrator
  • Hero Member
  • *****
  • Posts: 2898
  • FRUA Lives!
    • Lands of Adventure
Re: Firebat Crash
« Reply #8 on: September 16, 2017, 11:24:16 AM »
Not that this has anything to do with anything, but in case you guys didn't know, the forums allow for a "CODE" tag for printing code.  Just encase the beginning with the word "code" surrounded by brackets and the end with the word "/code" surrounded by brackets.

Using an example from above, makes it look like this:

Code: [Select]
name = monster_FireBatAttack     //Initiates the function.
[InvokeSpellOnTarget] = $VAR atk; // attacker     //Defines the variable "atk".  The firebat's bite casts the "monsterFireBatAttack" spell, which initiates this SA for a value of 2.
-$VAR tgt; // target     //Defines the variable "tgt".  Does not set it to a value yet.
-$VAR link;     //Defines the variable "link".  Does not set it to a value yet.
-atk = $IndexOf($AttackerContext());     //Sets "atk" to the firebat's ID.
-tgt = $IndexOf($TargetContext());     //Sets "tgt" to the bitten target's ID.
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatDrain","");     //Gives the firebat the "monster_FireBatDrain" SA.
-$IF ($GET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap") == "-?-?-")     //Checks if the firebat has the SA "monster_FireBatBloodCap", and whether that SA is equal to "-?-?-".  If yes, it continues.  If no, ??.
-   {
-      $SET_COMBATANT_SA($AttackerContext(),"monster_FireBatBloodCap",3);     //Sets the SA "monster_FireBatBloodCap" to 3.
-   };
-$SET_COMBATANT_SA($AttackerContext(),"monster_FireBatLink",tgt);     //Give the firebat the SA "monster_FireBatLink", with a value equal to "tgt" (previously defined as the attacked creature).
-$SET_COMBATANT_SA($TargetContext(),"monster_FireBatDrainee","");     //Give the target the "monster_FireBatDrainee" SA, which is not set to a value.
-$SET_COMBATANT_SA($TargetContext(),"IsHugged",1);     //Gives the target the "IsHugged" SA, which is set to a value of 1.
-link = $GET_COMBATANT_SA($TargetContext(),"monster_FireBatLink");     //Sets the variable "link" to the target of the attack, and to the combatant with the SA "monster_FireBatLink" (that is, the firebat).
-$IF (link == "-?-?-")     //Checks the value of "link".  If "link" is "-?-?-", then proceed.  If not, go to $ELSE.
-   {
-      $SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink","$255$" + atk);     //Gives the target the "monster_FireBatLink" SA, with a value equal to 255 plus the firebat's ID. 
-   }
-$ELSE     //If "link" is not equal to "-?-?-"
-   {
-      link = link + "$" + atk;     //Sets "link" to its current value plus the value of "$", plus the firebat's ID.
-      $SET_COMBATANT_SA($TargetContext(),"monster_FireBatLink",link);     //Set's the target's instance of "monster_FireBatLink" to the new value of link.
-   };
\(END)
« Last Edit: September 16, 2017, 11:26:06 AM by ProphetSword »
LANDS OF ADVENTURE: An Old-School Style CRPG

More Information Here: http://landsadventure.blogspot.com/

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9809
Re: Firebat Crash
« Reply #9 on: September 28, 2017, 04:01:21 PM »

Offline StultusTemporis

  • Newbie
  • *
  • Posts: 38
Re: Firebat Crash
« Reply #10 on: September 28, 2017, 07:18:33 PM »
Wonderful!  The firebat is working beautifully now.  Thank you for the fix to the script and for the update to the engine to prevent similar hangups from occurring in future scripts.

Also, thank you ProphetSword for the instructions on how to use the CODE tag.  I had not known about it.  It should prove useful if I have future questions about scripts in GPDL.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9809
Re: Firebat Crash
« Reply #11 on: September 29, 2017, 12:40:46 PM »
There was this funny moment when I was testing my script, where i couldn't figure out what was going on - why the Fire bat wasn't fleeing, and then I realized it was teh combat map, which had the thing trapped and no place to flee to. (I did not spend a long time on this, so don't worry - I just had to check the error log to seee what the monster was doing).

 

anything