FORUM ARCHIVED

Use of custombreakables to create interactive objects

Discussion in 'Modding' started by bluehinter, Feb 19, 2014.

  1. bluehinter

    bluehinter Member

    I've been using custombreakables quite a bit in my Monstrous Megapack, and created a number of interesting interactive objects that don't (at least superficially) appear to be breakables. It's been a series of trial and error trying to determine exactly what effects you can get depending on what information you do and don't include in the breakable code, whether they're visible or invisible, and how you layer them with other objects. I think I've found out what some of those interactions are, but any experienced modders, please let me know if I'm wrong about any of these things.

    First up though, a couple of disclaimers:
    • While you can disguise the breakable nature of an object (Ie: make it so it doesn't pop up an outline or say "Beat it" or "Break" when you hover the mouse over it), you can't disguise the game's automatic use of the player attack animation when interacting with said object.
    • These are all custombreakables, meaning that they can only be used in rooms that you create yourself, and each one must be programmed individually. You can't use these tricks to create objects that appear randomly, or in previously created rooms.
    Now on to some of the interactions and what I think is happening:


    [​IMG]
    To create an invisible interactive object that never shows a colored outline or the break/beat interaction message:

    First, create a customblocker, or use an existing in-game item, like a bit of wall or a statue or something. This object gets any name or description text you want to show up when you hover your mouse over the location. (notice, no outline or "break" dialog in the photo above.
    Next, create a custombreakable that uses a blank.png and does not include name or description in the code.
    EX:
    <custombreakable x="11" y="4" png="dungeon/blank.png" visblock="0" can_push="0" passable="0" broken="dungeon/painting_destroyed.png" id="Fake Wall"/>
    <customblocker x="11" y="4" name="Mysterious Painting" png="dungeon/wizard_painting_orko.png" visblock="1" can_push="0" passable="0" id="Orko" description="Warning: There's no force in the multiverse more dangerous than a comedic sidekick wizard. Kill on sight."/>
    In this particular instance, I do not think the order of the breakable and blocker matters, since the breakable is blank. Other sorts of interactions might.

    Next what you need is a script that triggers when the breakable object is "broken" or "hit" (both have their uses, depending on what you're trying to accomplish), causes the desired effect, triggers a spell with soundFX if desired, and then removes the blocker and/or breakable if needed. For the above example, I was creating a super secret hidden passage, so I used:

    <script repeat="1">
    <condition condition_type="event" event_type="broken" id="Fake Wall"/>
    <action on="success" action_type="spell" casts="Wall Dig" targetx="11" targety="3"/>
    <action on="success" action_type="spell" casts="Wall Dig" targetx="11" targety="4"/>
    <action on="success" action_type="remove" id="Orko"/>
    <action on="success" action_type="spell" casts="Wood Break Sound" targetx="11" targety="4" />
    </script>


    In this instance, I'm removing the blocker but leaving the breakable, because I want to show some debris on the floor after you break through the wall. I could also have used action_type="create" to create another customblocker that was passable (if I wanted there to be a jagged hole in the wall, for example.)
    I also cast a dummy spell that triggers a 2-frame blank animation that plays the "wood breaking" soundfx, because I'm a masochist like that.


    [​IMG] [​IMG]
    To create an interactive object that does shows a colored outline, but no break/beat interaction message:

    If you want the outline to show up around the object, still make sure your custombreakable has no name or description, but give the breakable object the same .png file as the customblocker underneath. For example, here's what I used for sinks:

    <customblocker name="Sink" id="Full Sink" x="3" y="2" png="dungeon/sink_full.png" passable="0" visblock="0" can_push="0" description="Cool refreshing tap water to cleanse the filth from your body."/>
    <custombreakable id="Sink Break" x="3" y="2" png="dungeon/sink_full.png" hitsNeededToBreak="99" visblock="0" can_push="0" passable="0" broken="dungeon/blank.png"/>


    [​IMG]

    Going above and beyond with your objects:

    One downside to these breakable objects is that they will trigger from explosions, traps, and/or projectiles as well as. If you want to restrict that, you needs to get a bit creative with your scripting.

    For the sinks in my mod, I wanted them to be one-time use objects like fountains that cleanse the player of negative status ailments, but only when the player is standing next to it. To do that, I first set the hitsNeededToBreak to an artificially high number:

    <customblocker name="Sink" id="Full Sink" x="3" y="2" png="dungeon/sink_full.png" passable="0" visblock="0" can_push="0" description="Cool refreshing tap water to cleanse the filth from your body."/>
    <custombreakable id="Sink Break" x="3" y="2" png="dungeon/sink_full.png" hitsNeededToBreak="99" visblock="0" can_push="0" passable="0" broken="dungeon/blank.png"/>


    Then I use 8 of the following scripts to specify each of the cells around the sink, and use the event_type="hit" rather than event_type="broken" (since it's take you 99 tried before you actually broke it). Since the successful script removes both the custombreakable and the customblocker, before replacing it with a new Empty Sink customblocker, the object can only be triggered once, and only when the player is standing next to it.

    <script repeat="1">
    <condition condition_type="event" event_type="hit" id="Sink Break"/>
    <condition condition_type="at" x="2" y="2" id="player"/>
    <action on="success" action_type="spell" casts="Squeaky Clean"/>
    <action on="success" action_type="ticker" text="You take a moment to wash your face and hands."/>
    <action on="success" action_type="remove" id="Sink Break"/>
    <action on="success" action_type="remove" id="Full Sink"/>
    <action on="success" action_type="create" create_type="customblocker" name="Sink" id="Empty Sink" x="3" y="2" png="dungeon/sink_empty.png" passable="0" visblock="0" can_push="0" description="Sorry, you can't use this any more. Water go down the hole." />
    </script>


    Technically, the sink will still activate, if you're standing next to it and it accidentally gets hit by an explosion or trap projectile, but that should be a relatively uncommon occurance.

    You can also use this trick to create a giant combination lock of sorts, where hitting custombreakableA (which takes 99 hits to break) triggers a script that removes custombreakableA and customblockerA and replaces it them with two B's (also with 99 hits). Hit the B's and they get replaced with C's, etc... on down the line until the last one loops back around to the A's again. Line up 3 of these in a row, and toss in a guess lever, and voila... instant combination lock.
     
    Alistaire likes this.