Jump to content

differentiating between joinable and non-joinable NPCs


Recommended Posts

NPCLEVEL only works for NPCs in the .gam file, so you're looking at more pain than you realize--certainly a lot more than your original problem--as you would have to add the NPCs to the .gam file and then find and disable their scripted spawns.

Link to comment

Really close to allowing NPCs to fill out their proficiencies by dialogue, but having a bit of trouble. The innate ability summons a creature, and teh creature runs a script that includes this (in part):

 

 

IF
    NumTimesTalkedTo(0)
    CLASS(LastSummonerOf(Myself),DRUID)
    CLASS(LastSummonerOf(Myself),FIGHTER_DRUID)
THEN
    RESPONSE #100
    SetGlobal("D5_DRUID","GLOBAL",1)
END

IF
    NumTimesTalkedTo(0)
THEN
    RESPONSE #100
    SetGlobal("D5_WEPPR","GLOBAL",1)
    SetNumTimesTalkedTo(1)
    ActionOverride(LastSummonerOf(Myself),StartDialogOverride("d5_weppr",Myself))
END

IF
    True()
THEN
    RESPONSE #100
    SetGlobal("D5_WEPPR","GLOBAL",0)
    SetGlobal("D5_DRUID","GLOBAL",0)
    SetNumTimesTalkedTo(0)
    DestroySelf()               // reset global variables, then destroy self
END

 

(Plus more global variables for different classes.) And the dialogue includes this:

 

 

BEGIN ~D5_WEPPR~

IF ~Global("D5_WEPPR","GLOBAL",1)~ THEN BEGIN d5_weppr
SAY @12352
IF ~GlobalLT("D5_THIEF","GLOBAL",1) GlobalLT("D5_MAGE","GLOBAL",1) GlobalLT("D5_DRUID","GLOBAL",1) GlobalLT("D5_CLERIC","GLOBAL",1) GlobalLT("D5_MONK","GLOBAL",1) CheckStatLT(myself,1,"PROFICIENCYTWOHANDEDSWORD")~ THEN REPLY @12301 GOTO d5_weppr_1
IF ~GlobalLT("D5_MAGE","GLOBAL",1) GlobalLT("D5_DRUID","GLOBAL",1) GlobalLT("D5_CLERIC","GLOBAL",1) CheckStatLT(myself,1,"PROFICIENCYLONGSWORD")~ THEN REPLY @12303 GOTO d5_weppr_2
IF ~GlobalLT("D5_MAGE","GLOBAL",1) GlobalLT("D5_CLERIC","GLOBAL",1) CheckStatLT(myself,1,"PROFICIENCYSCIMITARWAKISASHININJATO")~ THEN REPLY @12305 GOTO d5_weppr_3
 
...
 
IF ~~ THEN BEGIN d5_weppr_1
 SAY @12301
 IF ~~ THEN REPLY @12329 DO ~ApplySpellRES("D5P2SWO",myself)~ EXIT
 IF ~~ THEN REPLY @12330 GOTO d5_weppr
END

 

The idea being, Jaheira shouldn't be able to use this to gain proficiency in 2-handed swords (she can't equip them, anyway). But when she uses the innate ability, the filter isn't working, and she can choose 2-handed swords. Can anybody see why?

Link to comment

Ah. Duh. I'm rubbish with scripting. So it should look like this?

IF
    NumTimesTalkedTo(0)
    OR(2)
    CLASS(LastSummonerOf(Myself),DRUID)
    CLASS(LastSummonerOf(Myself),FIGHTER_DRUID)
THEN
    RESPONSE #100
    SetGlobal("D5_DRUID","GLOBAL",1)
END

Yes

maybe better to use

IF
    NumTimesTalkedTo(0)
Global("D5_DRUID","LOCALS",0)
OR(2)
    CLASS(LastSummonerOf(Myself),DRUID)
    CLASS(LastSummonerOf(Myself),FIGHTER_DRUID)
THEN
    RESPONSE #100
    SetGlobal("D5_DRUID","LOCALS",1)
END

Otherwise, you set a global for all NPCs in the whole game, while maybe the idea is to make the same function available for another Druid as well?

Or you reset the global to 0 after the whole operation for one NPC?

Edited by Roxanne
Link to comment

After the dialogue is finished and kicks back out to the script, the globals are set to 0 and the invisible script creature destroys itself.

 

I'm not sure about using locals, because the script is run by the creature... so would the local variable be set on the creature? Whereas, the dialogue is started by the creature's LastSummonerOf, so locals checks in the dialogue might return false even when they should be true.

 

EDIT - I suppose I could use ActionOverride to set the local variable on the LastSummonerOf (?)... but that seems like overkill. Global seems fine since they are only ever non-zero in the few seconds while the dialogue is active.

Edited by subtledoctor
Link to comment

After the dialogue is finished and kicks back out to the script, the globals are set to 0 and the invisible script creature destroys itself.

 

I'm not sure about using locals, because the script is run by the creature... so would the local variable be set on the creature? Whereas, the dialogue is started by the creature's LastSummonerOf, so locals checks in the dialogue might return false even when they should be true.

 

EDIT - I suppose I could use ActionOverride to set the local variable on the LastSummonerOf (?)... but that seems like overkill. Global seems fine since they are only ever non-zero in the few seconds while the dialogue is active.

Setting the global back to 0 should do it. It just was not visible from the one code snippet, but in context it should work, also it was not clear that it was an invisible helper running the script, although I was assuming as much.

Link to comment

Can that be done within a dialogue too? I.e., to allow a player to move to 4 stars in shortbows only if 1) they already have 3 stars, and 2) they are either a fighter or an archer:

 

IF ~OR(2) Class(myself,FIGHTER) Global("D5_ARCHER","GLOBAL",1) CheckStat(myself,3,"PROFICIENCYSHORTBOW")~ THEN REPLY @12327 GOTO d5_wepx_55
Link to comment

Can that be done within a dialogue too? I.e., to allow a player to move to 4 stars in shortbows only if 1) they already have 3 stars, and 2) they are either a fighter or an archer:

 

IF ~OR(2) Class(myself,FIGHTER) Global("D5_ARCHER","GLOBAL",1) CheckStat(myself,3,"PROFICIENCYSHORTBOW")~ THEN REPLY @12327 GOTO d5_wepx_55

If Global("D5_ARCHER","GLOBAL",1) means that they are archer, then, yes, but who is *Myself* in your dialogue case? Depending on dialogue structure and talkers it may be better to use LastTalkedToBy to prevent checks and actions being applied to the protagonist.

Edited by Roxanne
Link to comment

but who is *Myself* in your dialogue case?

The LastSummonerOf the invisible creature. The script starts the dialogue like so:

ActionOverride(LastSummonerOf(Myself),StartDialogOverride("d5_weppr",Myself))
That way the dialogue can use (Myself) and it won't have anything to do with the invisible creature, it will act directly on the NPC. Edited by subtledoctor
Link to comment

Can that be done within a dialogue too? I.e., to allow a player to move to 4 stars in shortbows only if 1) they already have 3 stars, and 2) they are either a fighter or an archer:

 

IF ~OR(2) Class(myself,FIGHTER) Global("D5_ARCHER","GLOBAL",1) CheckStat(myself,3,"PROFICIENCYSHORTBOW")~ THEN REPLY @12327 GOTO d5_wepx_55

Dialogues use the same trigger/actions that scripts do, so yes, they can do anything you can script. The only tricky bit is that they do not necessarily do it instantly--so if you set a variable in your first reply of dialogue, it may not actually get set in time for a fork later in the dialogue.

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...