Author Topic: PLANNED DESIGN: Friedrich's Fault  (Read 6703 times)

Online manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9764
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #45 on: December 20, 2013, 08:47:55 PM »
Quote
each combat round, DC will check the combatants for a script 'StartCombatRound'. 

At the start of combat, each combatant has
exactly one Special Ability, namely "Competing".

If a combatant is to have another special
ability, it must somehow be given to him.

Quote
The SA containing this script <StartCombatRound>(whether given to NPC or monster) is given to the combatant.

That is good.  But you have not told us how the Special
Ability named "monster_Regeneration" is given to
the combatant.

You seem to be saying, Paul, that if I create a monster and attach a SA to it, that there is not way that on it's own the SA will be on the combatant. (by on it's own I mean without Competing calling it or a spell being cast on the combatant, etc) Is this correct? I am sure we must be misunderstanding one another, because this would make it seem like it's kind of worthless to assign any SAs to monsters.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #46 on: December 21, 2013, 02:34:50 PM »
We are probably talking apples versus oranges
here.

I was talking specifically about the Hook (Script name)
named "StartCombatyRound".

The documentation says that the engine searches for
this Hook only in the 'Combatant' Special Abilities.

The combatant has only one Special Ability at the start
of combat: namely "Competing".  The Combatant will not
have a Special Ability named "monster_Regeneration"
unless you somehow give it that Special Ability.

Giving a Special Ability to a 'Monster Type' in the editor
will not give it to a monster Combatant during
runtime unless you take some special
action to have it happen.  An obvious place for you
to do this would be in the global Hook named
"CreateMonsterCombatant".

I think all of this is correct.  Speak up if you disagree;
perhaps I added some automatic SA transfer that
I have forgotten.

Online manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9764
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #47 on: December 21, 2013, 03:16:13 PM »
We are talking about different things. Which is good. :D

I wanted to have this conversatoin here in the forums so that folks will walk away with two things, 1) SAs work in different settings and 2) that we are both open to discussion about how they work and why they work the way they do.

While I do completely understand what you are saying now, Paul, my earlier comment about needing to fix some SAs still holds. A quick glance through the database shows me a number of them that will never be called. Hopefully they are ones that I wrote long ago and never updated. :)
« Last Edit: December 21, 2013, 04:40:38 PM by manikus »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #48 on: December 21, 2013, 03:40:33 PM »
Quote from: Manikus
SAs work in different contexts

Unfortunately, we have not mentioned 'contexts'
yet.  That is an entirely different topic that causes
confusion among even the guild leaders.  I fear
you may have just used the word in an improper context.
 ::)

Offline Dinonykos

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2312
    • Dinonykos Dungeon Craft
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #49 on: December 21, 2013, 04:36:24 PM »


On the right side, you can see the Styracosaurus in combat...
« Last Edit: December 21, 2013, 04:53:46 PM by Dinonykos »
Find four contributions to the Pre-Generated Character Mini-Module Design Contest on my homepage.
New: THE AMBASSADOR'S LETTER, my contribution to the 7-day-challenge.
DINONYKOS DUNGEON CRAFT DESIGN HOMEPAGE

Online manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9764
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #50 on: December 21, 2013, 04:59:35 PM »
Quote from: Manikus
SAs work in different contexts

Unfortunately, we have not mentioned 'contexts'
yet.  That is an entirely different topic that causes
confusion among even the guild leaders.  I fear
you may have just used the word in an improper context.
 ::)

You are correct. I changed my above post to use "setting", as context does indeed mean something else. :)

Offline Milos Gulan

  • Hero Member
  • *****
  • Posts: 3107
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #51 on: December 21, 2013, 05:08:04 PM »
That pic looks great :) i definitely like your cartoonish style of your characters.

Online manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9764
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #52 on: December 23, 2013, 07:14:27 PM »


On the right side, you can see the Styracosaurus in combat...

I bet you thought that I forgot...it just took me a while to get to it. ;)

Okay, in this example, I've used an SA on my NPC called "_NPC_Regenerate"

And then I added this code into the Competing SA, in the OnStartCombat script...
Code: [Select]
$IF ($GET_CHARACTER_SA($CharacterContext(),"_NPC_Regenerate") != "-?-?-")
{
$DEBUG ("Competing - OnStartCombat");
$SET_COMBATANT_SA($CharacterContext(),"_NPC_Regenerate","");
};
 
You can take the debug out, but leave it in at first to make sure it's being called.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #53 on: December 23, 2013, 08:54:46 PM »
Ok.  Now that you have shown us how the
'Combatant' gets the "_NPC_Regenerate", might
it be nicer if we search additional places for
"OnStartCombat" hooks?

If we search the 'Character' and 'Monster-type'
for hooks named "OnStartCombat" then you can
dispense with the "$IF" statement and have
everything take place in the monster definition
or the NPC definition and not diddle with the
'Competing' Special Ability.  Do you see how this
would remove one layer of reference and get
rid of the conditional statement?  And make it
the whole structure more scalable since you would
not have to add dozens of "$IF" statements to the
"Competing" hooks.

I'll change UAFWin for free if you will promise to
attempt to take advantage of the feature.  I'd like
it much better if scripts did not have to search for
Special Abilities but rather that Special Abilities do
the work themselves.  That is the grand design.
Besides, it is very easy for me to add additional
search locations for existing hooks.  And it is relatively
efficient at runtime.

P.S.
Watch out!  After we agree to this, I may want to remove
yet another layer of reference! 8)  So don't rewrite
everything instantly.
« Last Edit: December 23, 2013, 08:58:24 PM by Paul R. Stevens »

Offline Dinonykos

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2312
    • Dinonykos Dungeon Craft
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #54 on: December 24, 2013, 07:00:36 PM »
Okay, in this example, I've used an SA on my NPC called "_NPC_Regenerate"

And then I added this code into the Competing SA, in the OnStartCombat script...
Code: [Select]
$IF ($GET_CHARACTER_SA($CharacterContext(),"_NPC_Regenerate") != "-?-?-")
{
$DEBUG ("Competing - OnStartCombat");
$SET_COMBATANT_SA($CharacterContext(),"_NPC_Regenerate","");
};
 
You can take the debug out, but leave it in at first to make sure it's being called.

I admit at the moment this is beyond my limits - but maybe I will come back to this topic next year.
Find four contributions to the Pre-Generated Character Mini-Module Design Contest on my homepage.
New: THE AMBASSADOR'S LETTER, my contribution to the 7-day-challenge.
DINONYKOS DUNGEON CRAFT DESIGN HOMEPAGE

Online manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9764
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #55 on: December 24, 2013, 08:50:11 PM »
Paul, I am more than happy to take away a layer. :) IN fact the more layers taken away the better..

I will not start rewriting all of the SAs just yet, then. But if I rewrite and then have to rewrite again, at least I'm getting some good practice in. :D

Dinonykos, it's really not as difficult as it seems, but as Paul has said, if you wait a little bit, it will get easier because he will remove a layer of what we need to do with scripts (having one point to another in this instance).

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #56 on: December 24, 2013, 09:25:43 PM »
This is at once exquisitely simple and totally mind-boggling.
Mind-boggling in the sense that it is requires a lot of time
to twist one's mind around the structure of Special Abilities
and hooks.  And mind-boggling in the sense that something
so simple can be so powerful when used --correctly--,
whatever that means.

I will explain but I do not expect instant understanding.

During Combat we want to add hitPoints every round
to some particular type of monster.

It just so happens that the engine runs Scripts (Called
'Hooks' in this case) for every combatant at the start
of every round.  That seems like an ideal place for a
script to add points to certain monsters.  The name of
this hook is "StartCombatRound".  This hook is documented
at:
http://dianneandpaul.net/UAF/Help/SAStartCombatRound.html
This document says that the engine searchs the Special
Abilities for each combatant, looking for a script named
"StartCombatRound".

Well, the only Special Ability that a combatant has by
default is the Special Ability Named "Competing".  So we
could add the script named "StartCombatRound" to the
Special Ability named "Competing" and the script could
check to see if the monster is special and, if so, add some
hitpoints.  This is what Manikus did at first.  I complained.

I don't like scripts that look like this:
If (monster is goul) hp+3
If (monster is skeleton)  hp+4
If (monster is wisp) hp+5
If (monster ........  etc etc etc

So Manikus did it better than that.  He gave
the special monster a Special Ability named
'monster_Regeneration'.  Now the script can
handle any such special monster with one
statement:

If (monster has "monster_Regeneration") hp+SAparameter.

So, in the case of the three monsters in our example, we
would use the editor to give a Special Ability to each:
goul gets monster_Regeneration,3
skeleton gets monster_Regeneration,4
wisp gets monster_Regeneration,5

And the script uses the fact that the monster has
such a Special Ability (plus the parameter of that
Special Ability) to update each monster's hitpoints.
But I complained once again.  I don't like scripts
that look like this:

If monster has monster_Regeneration then do AAA
If monster has monster_Speed then do BBB
If monster has monster_Disease then do CCC
etc etc etc.

I said that if a monster has (for example)
monster_Regeneration then that Special Ability
should do whatever work is necessary without
having a script check to see if it is present and then
doing whatever work the Special Ability should have
done for itself.  So, my first plan (the one described
but which will be further crafted in the future) does
it this way:  The Special Ability "monster_Regeneration"
will add an additional Special Ability to the combatant.
That new special ability will implement the hook named
"StartCombatRound" and will add the hitpoints itself.

So....it would work like this:
1) Start of combat.  Run the "OnStartCombat" hook
that is attached to the "monster_Regeneration"
Special Ability.  That hook adds a Special Ability
named (for example) "AddHpEveryRound" to the
combatant (and provides the parameter #hitpoints).
2) The Special Ability "AddHpEveryRound" has a
script named "StartCombatRound".  This script
adds hitpoints to the combatant to which it is
attached.
3) At the start of every round we search the combatant
for a hook named "StartCombatRound".  We find one
in the combatant's Special Ability named
"AddHpEveryRound".  The engine runs that script and
the monster gets regenerated.

Now the Special Ability "Competing" will have a script
named "StartCombatRound" that will look like this:

<empty>  // All work done by the Special Abilities that want it done.

As I say, however, I will complain about this, too.
But let us take one step at a time.  When we are
finished with all the steps, the whole process will
take place very smoothly, automatically, and even
a little bit more transparently.  And the engine will
do all the work quickly and for for free. 

I think the power comes from the two layers of
indirection with each layer being a content addressable
database with arbitrary names.  It is said that any
problem can be solved with additional layers of
indirection.  Solved in theory at least.

Any more questions?
« Last Edit: December 24, 2013, 09:50:06 PM by Paul R. Stevens »

Offline Orgetorix

  • Newbie
  • *
  • Posts: 49
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #57 on: December 25, 2013, 09:33:13 AM »
Any more questions?

Certainly, how would for instance a Troll's regeneration be handled? Considering the fact that by rule they only start to regenerate 3 rounds after they have first sustained damage. Also any damage they have taken from fire or acid can not be regenerated. If not killed outright by unregenerateable damage, eg... fire or acid, and only incapacitated. They will continue to regenerate lost HP, until they are at a positive number, then they will stand back up and be able to continue the fight. The trick in the goldbox games was to have one of your players stand on the spot where the troll fell, so that they could not stand back up. I consider this an exploit.

In another vein, what would be required to have an odd number of regeneration per round, eg... a creature that regenerates at the rate of 3 HP every 2 rounds, or in other words 1.5 HP a round? 

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #58 on: December 25, 2013, 10:00:12 AM »
Quote
what would be required to have an odd number of regeneration per round, eg... .... 3 HP every 2 rounds

That one is pretty easy..... (pseudo-code)

HP =+ (1 + ( roundNumber%2 ))

Notice the absence of "IF" statements...usually good.

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2220
Re: PLANNED DESIGN: Friedrich's Fault
« Reply #59 on: December 25, 2013, 10:16:57 AM »
Trolls?  Hmmmm...fun stuff.

Firstly, it seems we need to know in which round
the creature first sustained damage.  So, when he
sustains damage we do the following: (pseudo-code)

*****firstDamageRound is an SA to be attached to the creature*****
If 'firstDamageRound' == 0) then firstDamageRound = currentRound.

There.  Now we know the first round in which the creature was
damaged.

Next, we need to know how many regeneratable HP have
been subtracted so that we can add that many back as he
regenerates them.  So, when the creature suffers damage
we need to do the following:

********regeneratableHP is an SA attached to the creature****
if (damage is not fire or acid) then regeneratableHP += damage.

Now we know how many points can be regenerated.

And modify the regneration script to :
1) Skip regeneration if round is not three greater
than firstDamageRound.
2) limit the regeneration to regeneratableHP
3) (I suppose but it is not perfectly clear from your
explanation) subtract the amount of regeneration from
regeneratableHP.
4) Make the creature status 'OK' if HP is positive.

Make sense?

 

anything