Outfit- and Equip-Dependent Messages and Interactions

Today I added the capability to return different interaction windows and different messages from objects based on which outfit the player is wearing and which item they currently have equipped. The process was kind of exhausting, so I will explain it here.

Firstly in the HTML, the element div has a class of interact or message as usual, but they also need a new class: outfit-dependent or equip-dependent or both. Then inside the div, instead of just having one span that contains the message or interaction, the div contains multiple spans, each of which are tagged with classes that look like this: “interact outfit0” or “message equip1″ where the number on the end of the equip or outfit matches with the player.outfit or player.playerSprite. The program then reads this number and returns the correct message or interactions based on what you’re holding or wearing.

The part that gave me trouble was priority. What if you have an message that needs to be returned for your outfit and a message that needs to be returned for your equipped item? That’s where the order of the spans come in. You enter them from least importance to greatest. So the last span in the div is the most important scenario. I’ll use a real game example for reference:

<div title=”The Earl of Southwestington” class=”stuck message person earl outfit-dependent equip-dependent”>

    <span class=”message outfit0″>”What are you doing outside in your underwear?”</span>

    <span class=”message outfit1″>”Hello. I’m not doing anything suspicious. I am the Earl of Southwestington.”</span>

    <span class=”message equip1″>”What are you going to do with that cake?”</span>

    <span class=”message equip2″>”HELP! A GUN!”</span>

</div>

As you can see, in this scenario, the equipped items take precedence over the outfit you’re wearing. So regardless of the outfit you have on, if you are waving a gun around Earl’s face, he’s going to talk about it. Spans that are both outfits or both equips have equal weight, so you don’t need to worry about what order you put them in.

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment: