[adv3lite] CommandTopic and referring to objects.

I’m fairly sure this is simple, but:++CommandTopic @Take // Being a ghost, Shamus can't pick things up. { topicResponse () { "<.p><q>How can I pick {that dobj} up? I'm a ghost!</q>, Shamus sighs.</p>"; } }

I want to give specific reactions to certain objects. I’ve tried everything that looks promising according to the documentation, but no dice. So I’d imagine I’m overlooking something fairly simple. Any help, please?

Just riffing’ here (haven’t actually tried it), but how about something like…

topicResponse()
{
    if(dobj.name == 'chain')
        "<q>Chains and ghosts...a matchup.</q>";
    else if(dobj.ofKind(shovel))
        "<q>I'm a ghost, how could I possibly pick up something like that?</q>"
}

Jerry

According to the Library Reference Manual, CommandTopic has a matchDobj property. You should be able to write all of the CommandTopics you like, giving each of them its own matchDobj.

I’m wondering if possibly this isn’t working for you because you’re attaching CommandTopics to the class rather than to the individual NPC. I’m guessing, but that would be a possible source of problems.

The CommandTopic is attached to the NPC’s ActorState.

That said, I suspect I’m doing something wrong with my topics and actor states code anyway, because I also have this:++AskTopic @npcLostSpirit "TODO" ;

It works if the NPC in question is in the same location as the player and other NPC from the start. It does not work if the NPC is not in the room to start with, and does not work if the NPC enters the room at a later point.

Anyway, here is the complete code, if anyone has any ideas:[code]///
/// npcShamus - Shamus - the “spirit guide” for the player.
///

npcShamus: claGhost ‘Shamus;;spirit guide;’
{
location = romAutopsyExaminationRoom
isHim = true
desc ()
{
/*
Salient points - transparent blue; looks as if he’d be in his early 30s if alive; mid-late 50s fashion (sweatshirt, casual shirt, trousers); trimmed looking beard and moustache; cheerful looking; no Irish
accent.
*/
“<.p>TODO: Shamus desc

”;
}
}

// This is Shamus’s default state.
+acsShamusNormal: ActorState
{
isInitState = true
specialDesc = “Shamus is, as always, floating by your side.”
}

++AskTopic @npcLostSpirit
“TODO”
;

++AskTopic @objAutopsyOrganMeasurementsBoard
“ABCDEF”
;

++CommandTopic @Take // Being a ghost, Shamus can’t pick things up.
{
topicResponse ()
{
“<.p>How can I pick {that dobj} up? I’m a ghost!, Shamus sighs.

”;
}
}

++DefaultCommandTopic
“<.p>You’d probably have more luck than I would., Shamus grumbles.


;

++DefaultAnyTopic
“<.p>Shamus just shrugs his shoulders.


;

// This actor state is activated by the “warning” event for the epiphany triggering.
+acsShamusEpiphany: ActorState
{
specialDesc = “Shamus is looking staggered.”
}

++DefaultCommandTopic
“<.p>Shamus is in no condition to do anything right now, it seems.


;

++DefaultAnyTopic
“<.p>Shamus is in no condition to talk about anything right now, it seems.


;[/code]

So what is it that isn’t working?

Your original post said you wanted to have different responses for attempts to take different objects, but I don’t see any attempt in your latest code posting to define alternate responses.

Jerry

NPC scope isn’t working. There isn’t anything else there yet because I removed my failed attempts to define alternate responses.

Okay.

So, you have two states defined for Shamus, and you say you get response sometimes.

Could it be you are shifting Shamus’s state from Shamus Normal, where the command topic is located, and Shamus Epiphany which does not have a command topic?

That would account for the topic response being valid sometimes and not others.

Jerry

I’m really not doing a good job at all of explaining this; my communication skills are woeful.

dl.dropboxusercontent.com/u/677 … Source.zip is the source code as-is.

The issues are:
:arrow_right: I want to give specific reactions to certain objects. I’ve tried everything that looks promising according to the documentation, but no dice. There isn’t anything else there yet related to it because I removed my failed attempts to define alternate responses from the code.
:arrow_right: NPC scope (asking about the NPC as a topic, in this case) isn’t working as I’d expect. It works if the NPC in question is in the same location as the player and other NPC from the start. It does not work if the NPC is not in the room to start with, and does not work if the NPC enters the room at a later point. Actor state, by the way, is changed only when the scnEpiphanyCountdown.EventIsGoingToHappen fuse is triggered.; all attempts are with the default actor state acsShamusNormal. I created a topic as an attempt at a workaround, but no success there either.

I hope this is remotely understandable.

Jim has already given you the correct answer to that one. You need to use the matchDobj (and/or matchIobj) property on the CommandTopic. The Adv3Lite library manual gives the following example:

+ CommandTopic @Take
    "<q>Bob, be a good fellow and pick up that red ball will you?</q> you
    request.\b
    <q>Very well,</q> he agrees.<.p>"
    
    allowAction = true
    matchDobj = redBall
    isActive = !redBall.isIn(bob)
;

This will match BOB, TAKE RED BALL when Bob doesn’t already have the red ball. Defining allowAction = true means that Bob will then go ahead and take the red ball when this CommandTopic is triggered.

If I understand you correctly this is because moving the NPC into the location of the player character isn’t registering the NPC as seen by the player character. This may occur if you’re using moveInto(loc) instead of actionMoveInto(loc) to move the NPC in question into the player character’s location, in which case you need to change moveInto() to actionMoveInto(). If that’s not the reason then try calling noteSeen() on the NPC object in the code that moves it into the player character’s location.

Clearly, I’m not being accurate enough here. I don’t want the NPC to perform the action, I want the NPC to give a different refusal message depending upon which object the player is trying to tell them to pick up.

That solves half of my issue - now I can ask Shamus about the lost spirit when the lost spirit is moved into the location. But I still cannot ask him about the lost spirit when it is not in the location, and I’m not entirely sure why; I’m not understanding the documentation on this.

Has the player seen the lost spirit? If so, the library should mark it as familiar. If not, you may need to mark it as familiar yourself. Or alternatively, create a Topic object.

But that is precisely the point of the example I gave. Defining matchDobj = redBall on the CommandTopic means that the CommandTopic will only be matched when the direct object of the command given to the player is the redBall. In other words this CommandTopic:

+ CommandTopic @Take
    "<q>Bob, be a good fellow and pick up that red ball will you?</q> you
    request.\b
    <q>Certainly now!</q> he cries.<.p>"
    
    
    matchDobj = redBall    
;

Will be matched when the player types the command BOB, TAKE RED BALL, but not if the player commands Bob to take anything else. This allows you to define different CommandTopics giving different refusal messages based on their matchDobj property.

Once again Jim’s answer is correct. The player character can only discuss things s/he knows about. The player character knows about things either if s/he has seen them or if their familiar property is true. So you need to define familiar = true on the lost spirit.

OK, I think I was reading this completely and utterly wrong. I’m so used to the way I write objects I totally misread matchDobj. And as for the scope problem… I’d been trying stuff like isKnown. I shall try familiar instead!

All appears to be working for now. Thanks!