Adding Readable Books as Inventory Items

From FleshWorks

Jump to: navigation, search

by ProjectX


NOTE: This requires the changing of the gamesys, so make sure it's backed up

Contents

The Actor

1) First open the actor class browser. Expand WorldObj -> InventoryObject -> Potion. Add a new class called "InvBook". This will be our base folder for all the future types of book we make. I chose to put it in potions because potion has a lot of the base properties we need.

2) Create a new class under InvBook and give it a suitable name, right click on it and select placeable/unplaceable, your book can now be added to a level.


The Script

3) Open the script browser and create a script, we'll call it "InventoryBook". Our script is quite simple and will look like this:

InventoryBook

Image:Condition_icon.png CONDITIONS

Image:Condition_icon.png When I am used in a way from the inventory

Image:action_icon.png ACTIONS

Image:action_icon.png Show the book that this script is on
Image:action_icon.png Reset script conditions and actions

It really is that easy!


The Properties

4) Now select InvBook (the folder) and add the properties: book -> bIsBook and book -> BookFileName. Leave BookFileName blank but set bIsBook to true. Then add Frob -> FrobBias, IsFrobbable. Set FrobBias to 16 and bIsFrobbable to True. Next add Highlight -> HighlightDist and set that to 128.

5) Now we need to customize how it is used in the inventory. Add inventory -> bCanUseWhileClimbing, bDeleteOnUse, bDontUseOnFullHealth and bIsStackable and set these to false, add bIsInventory and set that to true. Then add InvType and MaxInventoryStack. Set InvType to ITEM and MaxInventoryStack to 0.

6) Now for adding the script, with the InvBook still selected, add the properties Scripts -> TriggerScripts and bEnableScriptInherit. Set ScriptInherit to true and add a script to the TriggerScripts array, set the script to the one we just made. Now go to File -> Save Selected Packages and File -> Export Changed Scripts.


Try it out!

7) Add the book subclass to your level, open it's concrete properties and add Book -> BookFileName, add the name of an existing book (.sch files found in CONTENT -> T3 -> Books -> English) except change the name from *.sch to *.txt. Now rebuild, save and run your map. When you frob the book the book will appear as readable, but is also selectable and usable from the item inventory (you'll have to select your items using the scroll item inventory buttons)

There's only one problem. The book's poorly aligned.


HUD Alignment

8) Go back to your InvBook class, right click and select "show links". Add a link from "InvBook" To "BookModelPageUI" with the flavor being "HUDRender". now save the packages, export the scripts, rebuild the map, run the game and try it out!


NOTE: This is also possible to add to the existing books in T3 OMs, all you have to do is change the Readable -> Book in the same way as above, although a few methods will need to be different, I'll leave you to have fun experimenting.


NOTE2: This was a rushed attempt to get the functonality working, it may need improvements. You may also want to add CastShadows too and physics properties too.


NOTE3: You can now add any type of book underneath InvBook and it will only need the absolute minimum of properties changed (just the mesh and the book reference)



Back to Mission Design: Gameplay Tutorials Page

Back to Mission Design Tutorials Page

Back to Main Tutorials Page

Personal tools