Basic script file methods for a room with an item, an NPC, a virtual hotspot and two triggers

The following code shows an example room that contains an item, a hotspot, an NPC and both a circular trigger area and a rectangular one.


01 <?xml version="1.0" encoding="ISO-8859-1"?>
02 
03 <room scriptid="room1" scriptfile="./room1.bsh">
04   <hotspots>
05     <hotspot scriptid="hotpsot1" type="sphere" needsitem="true">
06       <position x="5.0" y="10.5" z="-2.5"/>
07       <name>Hotspot1 Screen Name</name>
08       <dimension radius="1.275"/>
09     </hotspot>
10   </hotspots>
11   <triggers>
12     <trigger enabled="true" scriptid="trigger1" type="circle">
13       <position x="3.5" z="1.4"/>
14       <dimension radius="1.25"/>
15     </trigger>
16     <trigger enabled="true" scriptid="trigger2" type="rect">
17       <position x="6.89" z="-3.0"/>
18       <dimension width="1.0" length="2.75"/>
19     </trigger>
20   </triggers>
21   <props/>
22   <items>
23     <item scriptid="pen" id="pen" type="ms3dascii" smooth="false" volume="sphere" shadow="false">
24       <name>Pen</name>
25       <image>./models/ms3d/stift/texture.jpg</image>
26       <pickable>true</pickable>
27       <file>./models/ms3d/stift/stift.txt</file>
28       <texture unit="0" mipmap="true" rotate="false" flip="false">./models/ms3d/stift/texture.jpg</texture>
29       <position x="0.0" y="0.0" z="0.0"/>
30       <rotation x="0.0" y="0.0" z="0.0"/>
31       <scale x="1.0" y="1.0" z="1.0"/>
32       <animation name="idle" start="1" end="1" timeperframe="100"/>
33     </item>
34   </items>
35   <characters>
36     <character scriptid="npc" id="npc" type="ms3dascii" smooth="false" volume="box" shadow="true">
37       <name>NPC Screen Name.</name>
38       <file>./models/ms3d/qinmae/quinmae.txt</file>
39       <texture unit="0" mipmap="true" rotate="false" flip="false">./models/ms3d/qinmae/texture.jpg</texture>
40       <position x="0.0" y="0.0" z="0.0"/>
41       <rotation x="0.0" y="0.0" z="0.0"/>
42       <scale x="1.0" y="1.0" z="1.0"/>
43       <animation name="idle" start="1" end="1" timeperframe="100"/>
44     </character>
45   </characters>
46 </room>
Java2html


After you've seen the room file, you should see the according BeanShell ".bsh" file that contains the neccessary empty method stubs for the room's interactive elements. You will have to place the actual code which determines what will happen, if the user looks at the pen, for example, inside these method stubs.

01 import de.rico.adventure.enums.State;
02 import de.rico.adventure.actions.*;
03 import de.rico.adventure.actions.custom.*;
04 import de.rico.adventure.actions.custom.concurrent.*;
05 
06 import de.rico.engine.path.*;
07 import de.rico.engine.effect.sound.*;
08 import de.rico.engine.camera.recorder.*;
09 
10 
11 room1OnEnter()
12 {
13 
14 }
15 
16 room1OnExit()
17 {
18 
19 }
20 
21 hotpsot1OnLookAt()
22 {
23 
24 }
25 
26 hotpsot1OnUse()
27 {
28 
29 }
30 
31 penOnLookAt()
32 {
33 
34 }
35 
36 penOnPickUp()
37 {
38 
39 }
40 
41 npcOnLookAt()
42 {
43 
44 }
45 
46 npcOnTalkTo()
47 {
48 
49 }
50 
51 npcOnUse()
52 {
53 
54 }
55 
56 trigger1OnEnter()
57 {
58 
59 }
60 
61 trigger1OnExit()
62 {
63 
64 }
65 
66 trigger2OnEnter()
67 {
68 
69 }
70 
71 trigger2OnExit()
72 {
73 
74 }
Java2html