TTLG|Thief|Bioshock|System Shock|Deus Ex|Mobile
Results 1 to 20 of 20

Thread: how to add lamp on/off in inventory

  1. #1
    Member
    Registered: Aug 2006
    Location: France (Saint-Gobain)

    how to add lamp on/off in inventory

    Does anyone knows how to add a lamp in Garrettīs inventory, and with the option to turn it on/off just like in the contest mission "The sinkhole"?

  2. #2
    Member
    Registered: Jan 2001
    Location: Pushing my luck with Dromed
    One of the NewDark features is that the AnimLight property has a 'dynamic light' checkbox, so perhaps you could use the NVFrobToggle script on the lamp (design note: NVFrobToggleTDest="[me]").

    You could also open the mission in Dromed and see how the author did it...

  3. #3
    Member
    Registered: Aug 2006
    Location: France (Saint-Gobain)
    i canīt manage to set this lamp properly to turn off and on, its been a long time i havenīt used dromed object settings that i am somehow rusty.

    i wonder if someone could set me that lamp to work properly in my mission?

  4. #4
    Member
    Registered: Jul 2002
    Location: Ames, IA, USA
    I don't know how it was done in The Sinkhole, but I played around for while and found a solution. NVFrobToggle won't turn the light on and off while held in the inventory, but if you drop the light after turning it on, it's lit and stays lit when you pick it up. Same holds true when you turn it off. Obviously, that's not particularly useful, but it was clear that getting the light out of inventory and back in was a necessary step.

    Here's the set up:

    • Add these Scripts: IllumeBearer, AnimLight, NVFrobToggle, and NVItemGiver.
    • Set Engine Features/FrobInfo for World Action to Move and Inv Action to Script.
    • Set the Renderer/AnimLight to minimum brightness, set some value for the maximum brightness (say 125), and check the Dynamic Light box.
    • If the light already has Renderer/Light, delete that.
    • Set the Inventory/Item Type to Item.
    • Add Editor/Design Note NVGiveWhat="[Me]"; NVFrobToggleTDest="[Me]"
    • ControlDevice link the light to itself.

    Once you've set this all up, you should see that DromEd has added a Dynamic Light set to 0 and Has Refs set to TRUE. You don't need to change these.

    Basically, NVItemGiver removes the light from inventory and puts it back in, giving the desiired on/off effect.

  5. #5
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Wouldn't it be simpler to give the lantern the equivalent of the LightFlare script, but with a LitLantern object?
    LightFlare
    gen.osm G/2

    On FrobInvEnd, creates a LitFlare and adds a Contains link from the frobber to the new object.
    Then to turn it off a 2nd FrobInvEnd could slay the LitLantern object. This should be possible with judicious use of NV scripts. I suggest adding and removing metaprops. One metaprop deals with lighting the lantern, removing itself when the lantern is lit, and adding the other metaprop. The 2nd deals with shuttering the lantern, removing itself when the lantern is shuttered, and adding back the first metaprop.


    Note the scripts on LitFlare:

    IllumeBearer
    gen.osm G/2

    Illuminates the container of the object. The container is lit when the object is added to the container. The effect is reversed when the object is removed, or Slain. The container is illuminated by copying the Renderer\Dynamic Light and Renderer\LightColor properties from this object. In Thief 2, if the M-Invisible meta-property is set, then the Light rating and Level of AI\State\Current visibility are set to the value of Renderer\Dynamic Light, and a Visible message is sent to the container. To un-illuminate the container, the Renderer\Dynamic Light and Renderer\LightColor properties are removed; Thief 2 sends an Invisible message to the container.

    InstantiateSuspicious
    gen.osm 2

    Make sure that the Engine Features\Suspicious property is on the concrete object. Activates on BeginScript.
    And the Delete Tweq. That's what makes flare burn out. Your lantern could run out of fuel, but not as fast as a flare ...

  6. #6
    Member
    Registered: Aug 2006
    Location: France (Saint-Gobain)
    Quote Originally Posted by LarryG View Post
    Wouldn't it be simpler to give the lantern the equivalent of the LightFlare script, but with a LitLantern object?


    Then to turn it off a 2nd FrobInvEnd could slay the LitLantern object. This should be possible with judicious use of NV scripts. I suggest adding and removing metaprops. One metaprop deals with lighting the lantern, removing itself when the lantern is lit, and adding the other metaprop. The 2nd deals with shuttering the lantern, removing itself when the lantern is shuttered, and adding back the first metaprop.


    Note the scripts on LitFlare:



    And the Delete Tweq. That's what makes flare burn out. Your lantern could run out of fuel, but not as fast as a flare ...
    Thanks both of you, the flare seems a very suitable object to iluminate, how could i turn it on/off?

  7. #7
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    This is just off the top of my head, but in general this is what you need to do:

    1. You need to make a new archetype called LitLantern. Basically copy everything from LitFlare (Physical > Tulz > FlareTypes > LitFlare) except the delete tweq and the shape. You might want to look at EngineFeatures > FrobInfo too, depending on whether you want to allow the lantern to be dropped or thrown while lit. If so, you will need to think about what should happen if that is done (Thrown => minor explosion? set things on fire? what?). You should also put NVSlayMe on the LitLantern with a custom message used instead of TurnOn, maybe "Suicide" LOL. The LitLantern object model (the .bin) should be identical to the Lantern object model, just with the glass material having the illumination property on, so that it looks like the lantern is lit.

    2. After you have the archetype figured out for LitLantern, you need to create two new MetaProperties, call them "M-LanternOn" and "M-LanternOff".

    3. M-LanternOn will add LitLantern to your inventory when your Lantern object gets a FrobInvEnd message. It will also add M-LanternOff to the lantern object and remove itself. To do these tricks you should read up on NVCreateAndLink and NVMetaTrap. Hint: you'll need to have NVCreateAndLink do what the LitFlare script does and add a Contains link to the player, and you'll need 2 NVMetaTrap scripts on each metaproperty.

    4. M-LanternOff will slay LitLantern to turn it off. To do this it will send a "Suicide" message to the LitLantern (TDest="*LitLantern"), then add M-LanternOn to the lantern object and remove M-LanternOff.

    5. Add M-LanternOn to your Lantern object via its archetype.

    I think that's pretty much it.
    Last edited by LarryG; 15th May 2013 at 11:08.

  8. #8
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Thinking more about it, I have come up with what may be a better approach. This approach eliminates the need for the MetaProperties and makes for a more natural user interface for turning the lantern on and off.

    The general idea is that when the Lantern object is frobbed in inventory the LitLantern is created, Contains linked to the player, and the Lantern object is slain. Similarly, when the LitLantern is frobbed in inventory the Lantern is created, Contains linked to the player, and the LitLantern is slain.

    So Lantern gets the NVCreateAndLink and NVSlayMeTrap added to it. The trick is to make sure that the Lantern does not get slain until the LitLantern is created and linked. I think that if you have NVCreateAndLink before NVSlayMeTrap in the list of scripts that should do it.

    LitLantern similarly gets the NVCreateAndLink and NVSlayMeTrap scripts added.

    The key is proper setting of the FrobInfo property so that a frob in inventory is sent to Scripts and an esc key press in inventory drops the lantern (lit or not). I just forget what the right settings are for that.
    Last edited by LarryG; 15th May 2013 at 15:48.

  9. #9
    Member
    Registered: Aug 2006
    Location: France (Saint-Gobain)
    iīm using a lit flare, and set its inventory type to "Item", also deleted its tweq delet state, still i donīt know how to make it turn on/off, any suggestions?

  10. #10
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Don't use the LitFlare archetype. Create a new archetype.

    Here, tell you what, I'll create a demo mission for you. Stay tuned.

  11. #11
    Member
    Registered: Jan 2001
    Location: Pushing my luck with Dromed
    I had a look at The Sinkhole but I thought the setup was way too complicated.

    Here's a simpler solution. I came up with it before I saw LarryG's idea, which also looks like it would work.

    Add a new line to Objnames.str:
    Name_Lant: "Lantern"

    In Dromed, create two new stims. Open the object hierarchy. From the Show Tree menu, select Act/React Simuli.
    Add a stim called LightOnStim, then add another called LightOffStim.
    (don't forget to save your gamesys)

    Create a new archetype, called DyanmicLightObject. Its location in the hierarchy doesn't matter. Add the property Renderer > Dynamic Light: 100
    (you will need to experiment with the value until you are happy with it)

    For the lantern, create any object that can be picked up. I used the NavGlobe for my test.
    Properties:
    Shape > Model Name: roblant
    Engine Features > FrobInfo: WorldAction: Move, InvAction: Script
    S > Scripts: NVFrobToggle
    (don't forget to install and load NVScript)

    Editor > Design Note:
    NVFrobToggleTOn="[5.00]LightOnStim"; NVFrobToggleTOff="[5.00]LightOffStim"; NVFrobToggleTDest="Player"
    (so, frobbing the lantern sends either of those stims to the palyer)

    Edit the Avatar > Garrett archetype.
    Add a Receptron for LightOnStim. Effect: Set Property, Target: Me, Agent: DynamicLightObject, Edit Effect, Prop name: selflit
    Add a Receptron for LightOffStim. Effect: Remove Property. Target: Me, Edit Effect, Prop name: selflit
    (for LightOnStim, it gets the value of Dynamic Light from DynamicLightObject)

  12. #12
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements

    Player Lit Lantern Tutorial

    Here ya go, demo attached (below). The lantern (lit and unlit) can be picked up and dropped ("R" key), and if frobbed in inventory, it will turn on and off. When turned on, it is suspicious. The only thing I didn't do is provide a TurnOn / TurnOff sound. I leave that as an exercise for the reader. It's not hard to do.


    To help you understand it, this is the process to add it to your mission:

    Create new archetypes:
    • Physical>Tulz>PortaLampTypes
    • Physical>Tulz>PortaLampTypes>PortaLampUnLit
    • Physical>Tulz>PortaLampTypes>PortaLampLit

    Edit PortaLampTypes and give it the following properties:
    • EngineFeatures>Frobinfo:{Move, FocusScript; Script, FocusScript; None}
    • EngineFeatures>Suspicious:{False; ; 0.00}
    • Inventory>ObjectName_PortaLamp: "Unlit Thief's Lantern"
    • Inventory>Type: Item
    • Renderer>DynamicLight: 0
    • Renderer>LightColor: {0.17; 0.30}
    • Renderer>RenderType: Normal
    • Renderer>SelfIllumination: 0.00
    • Scripts: {NVItemGiver; NVSlayMeTrap; ; ; False}
    • Shape>ModelName: roblant
    • MatMetal

    Edit PortaLampUnLit and give it the following properties:
    • Editor>DesignNote: NVItemGiverOn="FrobInvEnd";NVItemGiverOff="null"; NVGiveWhat="PortaLampLit"; NVSlayMeTrapOn="FrobInvEnd";
    • EngineFeatures>Suspicious:{False; ; 0.00}
    • Inventory>ObjectName_PortaLamp: "Unlit Thief's Lantern"

    Edit PortaLampLit and give it the following properties:
    • Editor>DesignNote: NVItemGiverOn="FrobInvEnd";NVItemGiverOff="null"; NVGiveWhat="PortaLampUnLit"; NVSlayMeTrapOn="FrobInvEnd";
    • EngineFeatures>Suspicious:{True; ; 0.00}
    • Inventory>ObjectName_PortaLamp: "Lit Thief's Lantern"
    • Renderer>DynamicLight: 80
    • Renderer>LightColor: {0.17; 0.30}
    • Renderer>SelfIllumination: 1.00
    • Scripts: {IllumeBearer; InstantiateSuspicious; ; ; False}


    Don't forget to script_load nvscript !

    Then just create a concrete instance of PortaLampUnLit in your mission. Go into Game mode. Pick it up and play with it. It's so cool, I'll have to have one on my campaign somewhere!

    Edit: The only nit I have with it is that you can use your bow while carrying it (!). I'm willing to buy that you can swing a sword and hold the lantern in your off-hand, but pull back a bow string and shoot an arrow?


    Note: I chose the roblant.bin object because a) it was handy and b) had the illum property on the glass material used in the model. Use whatever model you want.
    Attached Files
    Last edited by LarryG; 20th May 2013 at 11:54.

  13. #13
    Member
    Registered: May 2002
    Location: Between dreams and shadows...
    Quote Originally Posted by LarryG View Post
    Edit: The only nit I have with it is that you can use your bow while carrying it (!). I'm willing to buy that you can swing a sword and hold the lantern in your off-hand, but pull back a bow string and shoot an arrow?
    Well, there's nothing to say that Garrett needs to carry it in one hand or the other: you could use a model with a carabiner or something and say that it's clipped to his belt.

    Or give him a headband with a candle on it!

  14. #14
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    I'm not sure ...
    Click image for larger version. 

Name:	Sarcasm.jpg 
Views:	137 
Size:	30.9 KB 
ID:	1675

  15. #15
    Member
    Registered: May 2002
    Location: Between dreams and shadows...
    Heh, seriously, it's a very nice way of doing it, and there certainly are ways you can handwave the fact that Garrett still has full use of both hands with it turned on.

    I'd be tempted to try it, perhaps down the line in Shadowed Mayfield, as the second part of that has places it'd make sense to use (it won't work in Xavier's because of CENSORED).

    Thanks for putting together the tutorial!

  16. #16
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    For those who want it "old school", here's another approach (by Spitter) using conversations with rats, a blue room, sources and receptrons, and I don't know what all else:


    Portable lantern, Spitter-style.


    Starting babble

    First, there are some requirements for this tutorial:

    Mediocre or better understanding of linking
    At least basic understanding of Sources & Receptrons (Act/React)
    Ability to understand my babbling


    Sure, you *can* read this tutorial without the knowledge of the items above - the chances are that you just won't understand much. You may also be able to copy my lantern with ease, but that's not the point of this tutorial, but rather to show that it can be done (with relative ease) and this is just one way to do it. I'm pretty sure this whole thing can be done much more optimally and easily, but here's the way I made it.

    Oh, and I won't describe everything step-by-step. If you don't know how to set up a conversation or a custom gamesys, read a corresponding tutorial. Sorry, my space (and will to write) is limited Well, time to begin.


    Work, work, everyone loves work


    I'll start this tutorial by listing what we will want from this lantern (well, what I want anyway):

    The usual portable lantern with light.
    Player must be able to turn it on and off without the hassle of having to use other objects.
    The light must not stay or linger behind. In other words, it must not bug.
    Player must be able to use other objects while the lantern is on - so, even though the lantern is not currently active item from inventory, the light still works.


    Sounds good? I truly hope so, because that's what we're going to get.

    First, create a blueroom and set up two conversation markers in there, with rats as actors. Name the markers LitConv (this will turn our lantern on) and UnlitConv (vice versa - this turns our lantern off).

    Now, when writing this tutorial, I'm copying pretty much everything from the test level I made - this means names and objects. Since I didn't originally plan to do a portable and toggleable lantern, I used a shovel as my initial lantern object. Yes, that's right, a shovel. Since the effect is based upon the fact that I'm teleporting the unlit lantern away from inventory and putting the lit one in there instead, it's also useful for debugging - you can quickly see which one you have in your inventory.

    Anyway, on with it. Let's create the unlit lantern. As I stated already, I used a shovel. For sake of simplicity, put it right into Garrett's inventory (with Contains). Name it IllumiShovel, and give it following props:
    Engine Features: FrobInfo: World Action [none], Inv [Script, FocusScript], Tool [none]
    Scripts: TrigInvFrob (it allows you to send CD-messages from inventory.)
    Renderer: Render type: Not rendered (So that player can't see a glimpse of this shovel when it's teleported away)
    Inventory:
    Can't drop this: TRUE
    Object Name: Lantern:"Lantern" (or whatever you want)
    Type: Item


    Link IllumiShovel to LitConv. Now we need to do the lit lantern - I created a HackLight and named it LanternHack. Give it following props:

    Engine Features: Frob Info:
    [none], [Script, FocusScript], [none]
    Scripts: TrigInvFrob
    Shape: Model Name: roblant (this is the lantern model)
    Inventory:
    Can't drop this: TRUE
    Object name [use the same as in IllumiShovel]
    Type: Item


    ControlDevice-link this to UnlitConv.

    Great. We have now two lanterns, but we can't yet switch between them. And, we are still missing the light! Let us do it first.

    Create another HackLight somewhere, and name it LanternLight. Add the following props:
    Rendered: Dynamic Light: 65 (or whatever you want)
    Light Color: 0.14, 0.70 (your choice, again)

    Good. And now, a bit of Act/React.


    The Attack of the Flowerpots


    I used a bit of S&R to get the light to teleport to the right place. Use whatever stim you want, I created a new stim for myself, JaniStim. Remember that you need to restart Dromed before you can use your new stim. Don't forget to save you mission/gamesys, or everything made this far have been in vain!

    In LanternLight, add a new source. Set the stim to your custom stim, set propagator to radius and intensity to 5. In "Edit shape", set radius to 10, flags to none. In life cycle set flags to no max firings, and period to 20. This prodecure will make our light to fire a stim 50 times/second. We will continue this by giving Garrett a receptron which teleports the light next to Garrett when the light is in Garrett's vicinity. The radius is 10 since if Garrett is moving and we teleport the light next to Garrett (which we will do later on), Garrett may be too far away and the light may stay in the spot it was teleported to, and that's not quite what we want. Radius of 10 is sufficient to always "stick" the light into Garrett - at least if he's not under the effect of speed potion. I have not tested this, but it's quite likely that if you are giving speed potions to player, you need to increase that radius.

    Since we now have a radius stim in LanternLight which affects player, I suggest you position it to blueroom, so that player doesn't accidentally walk into its radius and launch it prematurely.

    So, we now need to add that receptron to Garrett. Do a "find_obj garrett" to get yourself to the Garrett archetype, and give him a new receptron. Put stimulus to JaniStim (or whatever you named your custom stim), min intensity to 4 and max intensity to 6. Set effect to "Teleport object", target object to Source (LanternLight gets teleported) and Agent to Me (teleport it at Garrett). Now, there's a nasty little bug (or a feature, if you prefer) in this - teleporting the light right into center of Garrett doesn't affect light gem at all - so we need to teleport it just a little bit away from him. In "Edit Effect" put positions into about following values: X=0.1, Y=0.1, Z=-0.1. That little trick now always teleports the Light into position (Garrett's X) + 0.1, (Garrett's Y) + 0.1, (Garrett's Z) - 0.1. That should do it.

    Now, don't close the receptron main dialog yet. Since we are going to teleport the light away when the lantern is turned off (for obvious reasons), we need to also ensure that the light can get back to Garrett - I did with a TeleportTrap which I teleport right at Garrett, quite similarly to how I did the LanternLight above. We haven't created the TeleportTrap yet, but while we are here, we might as well add the receptron already. For this I also used my JaniStim, but set the min and max intensities to 19 and 21. Again, effect is "Teleport object", target is Source and agent Me. This time we do not need to edit the teleporting position - Garrett's central guts are fine.


    Beam me up, Scotty!

    It is time for the teleporting stuff. Let's take a look into what we really want:

    Teleport our "Turned-off Lantern", in this case IllumiShovel, away when the Contains-link is broken (items which were previously in player's inventory appear into where Garrett was when the link was broken), to make sure that nothing funny happens, when the "Turned-on Lantern" gets moved into player's inventory.
    Teleport our "Turned-on Lantern", LanternHack, away when the Contains-link is broken and the "Turned-Off Lantern" gets returned to player's inventory.
    Teleport the light for lantern (LanternLight) next to Garrett when the lantern is turned on, so that the S&R trick we did earlier can kick in and stuck the light to Garrett.
    Teleport the light for lantern away from Garrett when the lantern is turned off, so that it's too far for that S&R trick to work.


    Start this by creating two buttons into the blueroom. We will use these to activate our TeleportTraps, and we'll activate these buttons themselves via a conversation. I named them TeleportShovel and TeleportLantern. Next, create four TeleportTraps, two for each button. They do not need names, really, but naming them doesn't hurt, so that it's easier to keep track of them. I didn't name the first two, but the other two I did: LightIn and LightOut. These are used to teleport the LanternLight.

    Anyway, now for some linkages. Link TeleportShovel (with ControlDevices) to one of the unnamed TeleportTraps and LightIn. Link this unnamed TeleportTrap to IllumiShovel and LightIn to LanternLight. Next step, link TeleportLantern into the two remaining TeleTraps. Link other one of them to LanternHack and LightOut to LanternLight. That part is ready.

    Now, back to some S&R. Give LightIn your custom stim as a source, set propagator to radius, intensity to 20, radius to 500, remove raycast-flag, no max firings and period to 500.

    Guess what - it's time to do something with those conversation markers, and then we're ready.

    First, open up LitConv and add following:

    Action 0:
    Add Link
    Contains
    LanternHack
    player
    (this bit puts the other lantern into player's inventory)
    Action 1:
    Remove Link
    Contains
    IllumiShovel
    player
    (this one removes the first lantern from player's inventory)
    Action 2:
    Frob object
    TeleportShovel
    (this bit activates the TeleTrap which moves IllumiShovel away from playing area and LanternLight near Garrett)


    That's it! Now, do the following for UnlitConv:

    Action 0:
    Add Link
    Contains
    IllumiShovel
    player
    (this puts the first lantern back into player's inventory)
    Action 1:
    Remove Link
    Contains
    LanternHack
    player
    (this one removes the second lantern from player's inventory)
    Action 2:
    Frob object
    TeleportLantern
    (this bit activates the TeleTrap which moves LanternHack away from playing area and LanternLight away from Garrett)


    Phew. I'm done. Go ahead, try it out, and send some death threats to jsaarijarvi@hotmail.com if it doesn't work. I truly hope you understood at least a word from what I just wrote up there. Spitter signing out.
    Last edited by LarryG; 19th May 2013 at 19:58.

  17. #17
    Member
    Registered: Aug 2006
    Location: France (Saint-Gobain)
    "Link IllumiShovel to LitConv. Now we need to do the lit lantern - I created a HackLight and named it LanternHack. Give it following props"

    Where is located the ltconv and the unlitconv ?

  18. #18
    Member
    Registered: Jan 2001
    Location: Pushing my luck with Dromed
    With all due respect to Spitter, his method is way too complicated. LarryG posted instructions further up. Use those instead, or my ones if you prefer.

  19. #19
    Member
    Registered: Aug 2007
    Location: LosAngeles: Between Amusements
    Agreed.

    With modern scripts there is no need to Rube Goldberg it like Spitter did. I just wanted to show that there are lots of solutions and that if you had a serious dislike of using scripts (why?? why would anyone hesitate to use these great scripts? they make life so much easier! but some people are so resistant to change that they would rather poke their eye out with a stick than use a new script, I guess.) you could still get it to work, it just would take a whole lot more time and effort.

    I did not seriously intend anyone to use that approach any more. Follow RSoul's or my tutorial above.
    Last edited by LarryG; 20th May 2013 at 11:49.

  20. #20
    Member
    Registered: Sep 2002
    Location: Pennsylvania
    I used the convoluted method that I did in the Sinkhole because I was working from an old tutorial by Ottoj55. I thought there must be a simpler way to do it, but I couldn't get other things to work (and I'm still somewhat of a Dromed noob). I did have to change a few things from his tutorial to get it to work properly, which was a good learning experience!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •