Random objects

Special tutorials, usually for the exporter plugin, but also general modeling tutorials.

Random objects

Postby D'Lanor » Tue May 13, 2008 6:41 pm

Remember that random Yeesha page in the Neighborhoods? Or the elusive Bahro stone by the Ferry Terminal? Here is how to make random objects like those. This code references two global Cyan Python files (without redistributing them of course).

Step 1. The Alcscript

Code: Select all
<object>:
    logic:
        modifiers:
          - tag: ProxiSensor_Enter
            cursor: nochange
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                remote: <region>
                triggers:
                  - enter
            conditions:
              - type: volumesensor
                satisfied: true
                direction: enter
            actions:
              - type: pythonfile
                ref: $RandomBool
          - tag: ProxiSensor_Exit
            cursor: nochange
            flags:
              - multitrigger
            activators:
              - type: objectinvolume
                remote: <region>
                triggers:
                  - exit
            conditions:
              - type: volumesensor
                satisfied: true
                direction: exit
            actions:
              - type: pythonfile
                ref: $RandomBool
        actions:
          - type: pythonfile
            tag: RandomBool
            pythonfile:
                file: xRandomBoolChange
                parameters:
                  - type: string
                    value: <object>Vis
                  - type: string
                    value: <object>Enabled
                  - type: string
                    value: <object>Chance
                  - type: string
                    value: <object>Proximity
                  - type: activatorlist
                    refs: ["logicmod:$ProxiSensor_Enter","logicmod:$ProxiSensor_Exit"]
                  - type: bool
                    value: true
                  - type: sceneobject
                    ref: scnobj:<object>
          - type: pythonfile
            tag: BoolShowHide
            pythonfile:
                file: xAgeSDLBoolShowHide
                parameters:
                  - type: string
                    value: <object>Vis
                  - type: bool
                    value: true

Replace <object> with the name of your object and replace <region> with the name of your region, without the <>.
Note the activatorlist under the pythonfilemods. That one was a pain to figure out. :|

You may wonder why we need a region for this. In a multiplayer environment the object could show up right under the nose of another player. A strategically placed region prevents that. As long as there is a player in the region the visibility state of the object will not change.


Step 2. The SDL variables

Code: Select all
STATEDESC MyAge
{
   VERSION 1

# Random objects
    VAR BOOL    <object>Vis[1]       DEFAULT=1  DEFAULTOPTION=VAULT
    VAR BOOL    <object>Enabled[1]   DEFAULT=1  DEFAULTOPTION=VAULT
    VAR BYTE    <object>Chance[1]    DEFAULT=50 DEFAULTOPTION=VAULT
    VAR BOOL    <object>Proximity[1] DEFAULT=0  DEFAULTOPTION=VAULT
}

Again replace <object> with the name of your object, without the <>. You can set the chance variable to any number between 0 and 100.

That is all. There is no need to program any Python script since Cyan has already done that for us. :D


Edit: I could probably turn this into a quickscript that only requires a few lines of input.
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Random objects

Postby D'Lanor » Wed May 14, 2008 12:54 pm

Quickscript submitted. If this is implemented I will move the tutorial to the wiki with this much shorter Alcscript *

Code: Select all
<object>:
    quickscript:
        sdl:
            type: randombool
            region: <region>


* not yet in the trunk so don't try this
"It is in self-limitation that a master first shows himself." - Goethe
User avatar
D'Lanor
 
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Random objects

Postby Nadnerb » Wed May 14, 2008 2:20 pm

Looks good. Merged. :)
Image
Live KI: 34914 MOULa KI: 23247 Gehn KI: 11588 Available Ages: TunnelDemo3, BoxAge, Odema
Nadnerb
 
Posts: 1057
Joined: Fri Sep 28, 2007 8:01 pm
Location: US (Eastern Time)

Re: Random objects

Postby Grogyan » Thu May 15, 2008 1:25 am

Great work :)
Better to have loved and lost than never to have loved at all
User avatar
Grogyan
 
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am


Return to Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest

cron