A scene for any occassion?

Hi,
I am not sure how to properly phrase this so I’ll do my best to explain. The scene below works for a very specific NPC in a very specific room. But I have a grid of rooms and two other NPCs sprinkled about. The PC can use the potion on any of the NPCs but only once. Can I re-write this scene to apply to any room/NPC that the PC might enter first?
I’ve looked for a way to start the scene when the PC is in the same room as one of the NPCs, because it is impossible to predict which room the PC will enter first, but I haven’t had any luck.
I do move the potion to nil after it is used, so I suppose I could duplicate this scene for the other two NPCs, I just thought there might a better way.

//encounter Fafnir scene
sky2CScene: Scene
startsWhen = (me.isIn(sky2C))
endsWhen = (gActionIs(Pour))
whenStarting(){
      "The terrible dragon Fafnir is here, preventing you from going any farther. ";
      if(!potion.isIn(me))
    {
    "With nothing to use against Fafnir, you meet your untimely demise. ";
        finishGameMsg('Please do try again. ',ftDeath);
    }
}
;
1 Like

I don’t know if I fully grasp, but are you looking for this?:

npcList = [fafnir, zofnir, mufnir]
startsWhen = me.getOutermostRoom().ofKind(GridRoom) &&
             npcList.indexWhich({npc: me.canSee(npc)})

(may need to translate some of that logic into Lite terms?)

And if the scene could apply to one of several NPCs, you won’t want to hardcode the name Fafnir in the string either…

That looks interesting. Let me try it. I’ll let you know!
Thank you!

1 Like

I can’t remember (without looking up) if you have to use the Query object in Lite, instead of canSee, so just be aware…

Any progress?

Hello,

Yes and no. I don’t think I got the condition for the scene to start quite right.
And as I was messing with that I realized I have an afterAction() in each of the rooms that have the NPCs in them to finish off the scene.
So I do have everything working by duplicating the scene code based on which NPC and Room the PC is in. That will work for me for now.

Thank you for checking! I might explore this more a bit later.

Deborah

1 Like