Author Topic: Question about the Paladin NPC control ability  (Read 319 times)

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Question about the Paladin NPC control ability
« on: February 09, 2017, 02:51:59 PM »
(Question is aimed at Paul and Manikus, as they primarily handle the scripting/development -- but anyone can answer if they know. Also, I am not sure if this is the proper place to post this, so please feel free to move if needed)

tl;dr -- how does the paladin NPC control work, and is there a way to temporarily suppress that??

the full story here --> So, I am set on doing the 1 week challenge, and I decided that my idea cannot be done in FRUA. I tested out a key function (the Paladin NPC control) that works well in both, but one that I need more control over. What I was hoping to know, is how does this work? Specifically, can it be suppressed temporarily? As in, if I wanted to have one combat with the player able to (by virtue of the Paladin NPC control) be able to control the friendly NPCs in combat; and in another combat NOT follow player control.

Even better would be the ability to script switching this on or off at will

ST the control freak

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9544
Re: Question about the Paladin NPC control ability
« Reply #1 on: February 09, 2017, 02:59:16 PM »
I saw that my name was in your post under the section of people allowed to answer... ;)

Paladin control of NPCs in DC is 100% scripted. Look in the Special Abilities database. It's in the Competing SA, look for the words "Paladin Control". Let me know if you don't understand it.

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #2 on: February 10, 2017, 01:38:56 AM »
ok, thanks for the reply. I am looking in the editor for this, under "Competing" and I found this:

"AutoAction -- script -- $RETURN $GET_COMBATANT_SA($ComatantContext(), "PlayerControl");

did not see the paladin control there, but I also found "Paladin Leadership" in the text file specialAbilities.txt
(which has a bunch of stuff, which I am not quoting yet)

Actually, I searched for the word control, and I have a bunch of things I found interesting...

ST, the interested.

PS, I am going to test out some things, and will almost certainly come back w/ more questions for this

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9544
Re: Question about the Paladin NPC control ability
« Reply #3 on: February 10, 2017, 01:12:25 PM »
It is the paladin control bit that you want. Most of the stuff is to track what level the paladin is, and then compare it to the monster/enemy level and choose a result based on the outcome.

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #4 on: February 11, 2017, 02:21:44 AM »
I think can follow along well enough to understand the paladin leadership scripting in the specialabilities.txt (copied and broken down below):

Code: [Select]
// Paladin Leadership
controlNPC=0;
$SET_COMBATANT_SA(CharacterContext(),"endControl", 1);
lvl = $GET_CHAR_Lvl(me, "paladin");
$IF (In_Party($CharacterContext()) != "" && lvl ># 0)
{
modCha = ($GET_CHAR_LIMITED_CHA(me) -# 13) *# 5;
$IF (lvl >=# 3) {ControlNPC = modCha +# 79;};
$IF (lvl ==# 2) {ControlNPC = modCha +# 39;};
$IF (lvl ==# 1) {ControlNPC = modCha +# 19;};
$SET_PARTY_ASL("ControlNPC", controlNPC);
};

IF (GET_COMBATANT_SA(CharacterContext(), "side") == 1 && $RANDOM(100) <# $GET_PARTY_ASL("controlNPC"))
{
$SET_COMBATANT_SA($CharacterContext(), "playerControl", "CP");
};

---

breakdown:

Code: [Select]
// Paladin Leadership
controlNPC=0;
$SET_COMBATANT_SA(CharacterContext(),"endControl", 1);

header and nulling out any previous values in the variable "controlNPC", not entirely sure what the significance of the "1" at the end of this means --> $SET_COMBATANT_SA(CharacterContext(),"endControl", 1);

but this step (zeroing out any previous variable set) is common for functions before running program-flow checks

Code: [Select]
lvl = $GET_CHAR_Lvl(me, "paladin");
$IF (In_Party($CharacterContext()) != "" && lvl ># 0)

Check level of paladin character, and if one exists in party, and if both are true, then do this:

Code: [Select]
{
modCha = ($GET_CHAR_LIMITED_CHA(me) -# 13) *# 5;
$IF (lvl >=# 3) {ControlNPC = modCha +# 79;};
$IF (lvl ==# 2) {ControlNPC = modCha +# 39;};
$IF (lvl ==# 1) {ControlNPC = modCha +# 19;};
$SET_PARTY_ASL("ControlNPC", controlNPC);
};

set a temp variable named modCha, based upon Cha. Evaluates to (Charisma score - 13) * 5. Since paladins can only have 17 or 18 for Cha, then this will evaluate to 17-13=4 or 18-13=5 * 5 = 20 or 25

the three $IF statements then take the paladins level, 1 2 or 3+ and add the modCha to the percentage chance being set up for testing for chance of control of a given NPC. at 1st level, this is the modcha + 19, at 2nd level modcha + 39 and at 3rd and above the modcha is + 79. So, for 17 Charisma and 3rd level and above, modCha is 99%

Code: [Select]
IF (GET_COMBATANT_SA(CharacterContext(), "side") == 1 && $RANDOM(100) <# $GET_PARTY_ASL("controlNPC"))
{
$SET_COMBATANT_SA($CharacterContext(), "playerControl", "CP");
};

The last lines then verify the NPC in question is on the same side as you, as in, not an enemy combatant, and then checks ModCha versus a percentile roll (versus a 1-100 chance). If this evaluates to true then this happens --> $SET_COMBATANT_SA($CharacterContext(), "playerControl", "CP");
-- which is setting the SA for the NPC that lets players control the NPCs

---

Just in breaking this down into its component parts, I believe that I have the beginnings of a way to manipulate this the way that I want. Something akin to adding in an additional check, perhaps versus a quest stage or something.

ST the inspired

PS -- was going to start this reply the same way, and then launch into asking for help with something like this: "but I am not sure how to make this work" but by breaking this down into its simpler lines like this I realized how to do what I needed ;)
« Last Edit: February 11, 2017, 02:35:38 AM by SilentThief »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2131
Re: Question about the Paladin NPC control ability
« Reply #5 on: February 11, 2017, 10:48:48 AM »
I hope your 'code' is not a direct copy of the code in
SpecialAbilities.txt.  It is missing a dollar sign in many
places.  CharacterContext() would not work.
GET_COMBATANT_SA() would not work.  Except for
those things that stood out, I did not study the code.

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #6 on: February 11, 2017, 02:24:03 PM »
No, it wasn't a direct copy-paste. It was copied by me hand-typing it out from looking at it on another computer. I most likely didn't copy the code perfectly.

I found where in the editor the code for that is located, so I do not have to fool around with the specialabilities.txt file and then try to import it -- I can just alter the script

ST the alterer

PS will test this out later tonight (at work right now) and let you know if I have any issues

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #7 on: February 12, 2017, 05:39:57 PM »
Just in breaking this down into its component parts, I believe that I have the beginnings of a way to manipulate this the way that I want. Something akin to adding in an additional check, perhaps versus a quest stage or something.

Well, I am not sure if a check versus a quest stage will work, I may have to change to an ASL. The reason I cannot use a quest stage, as far as I can tell, is that its only possible to set quest stages not get them

$SET_QUEST(variable, variable) exists, and the variable variable part I interpret to mean quest-name and stage/number

But there is no $GET_QUEST(variable), I could not find this in the script function list. Do you check for the current quest stage with the SET command? I could not figure out how to do that either.

ST the novice scripter
« Last Edit: February 12, 2017, 06:52:53 PM by SilentThief »

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2131
Re: Question about the Paladin NPC control ability
« Reply #8 on: February 12, 2017, 08:53:59 PM »
Look at:

http://www.dianneandpaul.net/UAF/Help/GPDL$SET_QUEST.html

The first example is getting a quest variable

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #9 on: February 12, 2017, 10:24:29 PM »
right on, thank you Paul. I thought there had to be a way to check. Will use this right away!!

ST the quester

Offline Paul R. Stevens

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 2131
Re: Question about the Paladin NPC control ability
« Reply #10 on: February 13, 2017, 09:49:14 AM »
No problem.  I like to hear from people from people
who are actually using the program.  Be quick to
point out any other bugs/deficiencies.

Offline manikus

  • Skriptor
  • Administrator
  • Hero Member
  • *****
  • Posts: 9544
Re: Question about the Paladin NPC control ability
« Reply #11 on: February 13, 2017, 01:42:06 PM »
Just in breaking this down into its component parts, I believe that I have the beginnings of a way to manipulate this the way that I want. Something akin to adding in an additional check, perhaps versus a quest stage or something.

ST the inspired

PS -- was going to start this reply the same way, and then launch into asking for help with something like this: "but I am not sure how to make this work" but by breaking this down into its simpler lines like this I realized how to do what I needed ;)

Here is how I would do it - PC control does not work in a particular combat:
set another check for a combatant SA "Not This Time" or whatever
In the trigger for the combat, give everyone in the party the  combatant SA "Not This time"

Offline SilentThief

  • Dungeon Craft Tester
  • Hero Member
  • ***
  • Posts: 883
Re: Question about the Paladin NPC control ability
« Reply #12 on: February 19, 2017, 02:08:07 PM »
I managed to get the first version working, where it keyed off of a quest trigger, and was working with verifiable and consistent results. What would happen is if the quest "NPCcontrol" was active, it would allow the paladin to control the NPCs and if not, no such control.

I then tried to modify it and this broke it. I am at work again, so I will reply later if I have any questions or more information on this.

ST workin cuz Im broke ;)

 

anything