Tiens on 16/12/2008 at 18:48
How to create a lantern for the player's inventory, step-by-step tutorial:This lantern was made by me for The Cabal mini-campain but I'm sure it could be very useful in other TDS FMs. I know that some kind of a pocket light was already presented in TDS FM Silence by CrackedGear. I tried to find a tutorial but failed. That's why I decided to show my way to create it.
In short, the lantern contains of two parts: an object into the player's inventory and a light bulb, attached to Garrett's body. Every time the player uses the object from his inventory, the light turns on/off.
Now we shall begin:
1) open Actor Browser, add a new object into WorldObj/InventoryObject/PowerUp/Potion/ category and call it "PocketLight". Make it "placable". Set its properties to:
HTML:
* Inventory:
- bCanUseWhileClimbing = False
- bDeleteOnUse = False
- bDontUseOnFullHealth = False
- bIsInventory = True
- bIsStackable = False
- HelpText = <string=T_InventoryHelpTextPocketLight>
- InvName = <string=t_PocketLight>
- InvType = eIT_ITEM
- MaxInventoryStack = 0
* Render:
- ObjectMesh = GENHndLntrn1A (Default) -> a lantern mesh from "Light" category
* Scripts:
- TriggerScripts:
[0] PickUpPowerupSound -> This is the original script. Thanks to it, the game plays a sound, when the player frobbs the pocket light.
2) add two new scripts named "PocketLight" and "HelpPopUpPocketLight":
HTML:
* Scripts:
- TriggerScripts:
[1] PocketLight:
cond.:
- When I am used in a way from the inventory
act.:
- Send trigger message [PocketLight]
- Reset script conditions and actions
[2] HelpPopUpPocketLight:
cond.:
- Query if flag [HelpTextPocketLightDone] is set to [FALSE]
- Logic [OR] operator
- When I am frobbed by player
- When [PocketLight] count in inventory becomes [Greater Than][0]
act.:
- Set flag [HelpTextPocketLightDone] to [TRUE] expires on map change [FALSE] expires on mission [20]
- Popup a window with text from the file [InvHelp_PocketLight.txt]
Also we create the flag "HelpTextPocketLightDone" and the text file named "InvHelp_PocketLight.sch" (into the folder ...\CONTENT\T3\Books\English).
What is inside the "InvHelp_PocketLight.sch" file:
HTML:
-----------------------
VERSION 2.0
TextEntry
InvHelp_PoсketLight
lang_english 2004-03-08 10:25:16 "<font=Papyrus12>\n<dc=191,183,255>\n<shadow=0,0,0>\n<jc><string=t_PocketLight><p><jc><string=T_InventoryHelpTextPocketLight>\n"
lang_french 2004-03-08 10:25:16 "<font=Papyrus12>\n<dc=191,183,255>\n<shadow=0,0,0>\n<jc><string=t_PocketLight><p><jc><string=T_InventoryHelpTextPocketLight>\n"
lang_italian 2004-03-08 10:25:16 "<font=Papyrus12>\n<dc=191,183,255>\n<shadow=0,0,0>\n<jc><string=t_PocketLight><p><jc><string=T_InventoryHelpTextPocketLight>\n"
lang_german 2004-03-08 10:25:16 "<font=Papyrus12>\n<dc=191,183,255>\n<shadow=0,0,0>\n<jc><string=t_PocketLight><p><jc><string=T_InventoryHelpTextPocketLight>\n"
-----------------------
In the same time we add the Pocket Light's name and the Pocket Light's help text into the "Inventory.sch" file (into the folder ...\CONTENT\T3\Books\English\String_Tags):
HTML:
-----------------------
TextEntry
t_PoсketLight
lang_english 2004-02-29 21:48:00 "Pocket Lamp"
lang_french 2004-03-22 12:07:22 "Фонарик"
lang_german 2004-03-11 14:03:15 "Taschenlaterne"
lang_italian 2004-03-26 06:36:55 "Lanterna tascabile"
TextEntry
T_InventoryHelpTextPoсketLight
lang_english 2004-02-29 21:48:00 "The Pocket Lamp will illuminate any night for you."
lang_french 2004-03-26 06:50:20 "Фонарик осветит для Вас любую ночь."
lang_german 2004-03-20 17:14:06 "Die Taschenlampe erhellt die Umgebung."
lang_italian 2004-03-25 07:28:12 "La lampada tascabile illuminerа le tenebre."
-----------------------
3) now go to the category WorldObj/Light_/FlameLight/OilLamp/, add a new light and name it "GarrettPocketLightBulb". Make it "placable". Set its properties to:
HTML:
* Actor:
- bNotMovablePhysics = False
- bNotMovableRender = False
* Lighting:
- FleshLightType = FL_OmniNoShadow
- LightColor:
-> LightBrightness = 65
-> LightHue = 24
-> LightSaturation = 149
- LightShape:
-> LightRadius = 16, other positions = 0
* Render:
- CastShadows = ShadowCasting_False
- ObjectMesh = INVarrowBROADHEADicon(Default) -> a broadhead arrow icon mesh from "INV_WEAPON_UI/GarretInventory" category
4) add two new scripts named "GarrettPocketLightBulb" and "GarrettPocketLightBulb_OnStartToFalse":
HTML:
* Scripts:
- TriggerScripts:
[0] GarrettPocketLightBulb:
cond.:
- Received trigger message [PocketLight]
act.:
- Delay [0.01] GAME seconds
- Toggle [bLightOn] on linked objects of type [MYSELF]
- Reset script conditions and actions
[1] GarrettPocketLightBulb_OnStartToFalse:
cond.:
- When map starts, arriving from a different map
act.:
- Delay [0.01] GAME seconds
- Set [bLightOn] to [False] on linked objects of [MYSELF]
- Reset script conditions and actions
5) now come back to PocketLight actor and add a new "RiggidAttachment" link to it (from "PocketLight" to "GarrettPocketLightBulb"). Set its properties to:
HTML:
* Attachment:
- m_attachmentBone = CENTER
- m_parentBone = CENTER
* Lifetime:
- bDeleteChildOnDeath = True
6) now let's find the player's body. Go to Pawn/PlayerPawn/Garrett/ category, select "PlayerGarrett" actor and add a new "RiggidAttachment" link to it (from "PlayerGarrett" to "GarrettPocketLightBulb"). Set its properties to:
HTML:
* Attachment:
- m_attachmentBone = CENTER
- m_parentBone = Garrett L Hand
7) now you should export all scripts, save all packages and close Actor Browser.
That's all. You can place your new lantern into the default inventory or strait on the map. Use "PocketLight" actor for it.
NOTICE:The only one bug is: when the player turns the lantern on/off, the game plays the same sounds and Garrett plays the same animation as if the player throws a flash-bomb. To tell the truth, I'm not going to get rid of this bug. I prefer to leave these sounds/animation as they are now. It helps me to control the moment of "using" any new item.
massimilianogoi on 10/3/2009 at 19:04
Quote Posted by ShadowSneaker
I made this but whenever I use the lantern you hear that clicking sound and Garrett's sharp exhalation of breath like when he throws a flashbomb. The same thing happens with the edible food I made. It's slightly tedious.
Is there an inventory property I can alter to stop this?
Thanks.
I managed to do this, but I don't remember how... hmm...
Maybe, if I recall, it should be one property of the linked script.
Here's my linked script for edible food:
Triggerscript HelpPopBread:
Quote:
CONDITIONS
Logic [OR] operator
? When I am frobbed by player
? Query if flag [HelpTextBreadDone] is set to [FALSE]
ACTIONS
Set flag [HelpTextBreadDone] to [TRUE] expires on map change [FALSE] expires on mission [20]
Popup a windows with text from the file [InvHelp_Bread.txt]