Random objects

Special tutorials, usually for the exporter plugin, but also general modeling tutorials.
Locked
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Random objects

Post by D'Lanor »

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
D'Lanor
Posts: 1980
Joined: Sat Sep 29, 2007 4:24 am

Re: Random objects

Post by D'Lanor »

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
Nadnerb
Posts: 1057
Joined: Fri Sep 28, 2007 8:01 pm
MOULa KI#: 23247
Location: US (Eastern Time)
Contact:

Re: Random objects

Post by Nadnerb »

Looks good. Merged. :)
Image
Live KI: 34914 MOULa KI: 23247 Gehn KI: 11588 Available Ages: TunnelDemo3, BoxAge, Odema
User avatar
Grogyan
Posts: 1203
Joined: Thu Oct 11, 2007 1:27 am
MOULa KI#: 0

Re: Random objects

Post by Grogyan »

Great work :)
Better to have loved and lost than never to have loved at all
Locked

Return to “Tutorials”