oneshotmod: working or not?

If you feel like you're up to the challenge of building your own Ages in Blender or 3ds Max, this is the place for you!

oneshotmod: working or not?

Postby D'Lanor » Wed Feb 27, 2008 12:22 pm

I tried to make a button with avatar animation. The age compiled fine but when I loaded it up there was no avatar animation. The button still did everything it should. This is the alcscript I used (in PyPRP version 1.2.1):

Code: Select all
Button:
    quickscript:
        simpleclick:
            pythonfile: "SwapButton"
            region: "ButtonRegion"
            animation: "DoorButtonTouch"
            animtarget: "Button"


Here is the relevant part of the export logfile:

Code: Select all
  [QuickScript - Simple Clickable]
Resulting Code for .logic.modifiers:
- tag: AutoClick
  cursor: poised
  flags:
    - localelement
  activators:
    - type: objectinvolume
      remote: ButtonRegion
      triggers:
        - any
  conditions:
    - type: activator
      activators:
        - type: picking
    - type: objectinbox
      satisfied: true
  actions:
    - type: pythonfile
      ref: $AutoClick

Resulting Code for .logic.actions:
- type: pythonfile
  tag: AutoClick
  pythonfile:
      file: SwapButton
      parameters:
        - type: activator
          ref: logicmod:$AutoClick
        - type: string
          value: Button
        - type: behavior
          ref: oneshotmod:$AutoClick
- type: oneshot
  tag: AutoClick
  oneshot:
      animation: DoorButtonTouch
      seektime: 1.0
      remote: Button

Quickscripted Button
To: {'quickscript': {'simpleclick': {'region': 'ButtonRegion', 'animation': 'DoorButtonTouch', 'animtarget': 'Button', 'pythonfile': 'SwapButton'}}, 'logic': {'modifiers': [{'cursor': 'poised', 'tag': 'AutoClick', 'flags': ['localelement'], 'activators': [{'type': 'objectinvolume', 'remote': 'ButtonRegion', 'triggers': ['any']}], 'conditions': [{'activators': [{'type': 'picking'}], 'type': 'activator'}, {'type': 'objectinbox', 'satisfied': True}], 'actions': [{'type': 'pythonfile', 'ref': '$AutoClick'}]}], 'actions': [{'tag': 'AutoClick', 'type': 'pythonfile', 'pythonfile': {'file': 'SwapButton', 'parameters': [{'type': 'activator', 'ref': 'logicmod:$AutoClick'}, {'type': 'string', 'value': 'Button'}, {'type': 'behavior', 'ref': 'oneshotmod:$AutoClick'}]}}, {'type': 'oneshot', 'oneshot': {'seektime': 1.0, 'remote': 'Button', 'animation': 'DoorButtonTouch'}, 'tag': 'AutoClick'}]}, 'physical': {'physlogic': 'detect'}}


[Region Object ButtonRegion]
 Region type: unknown
 [LogicHelper]
   No actions in list
None
   Exporting modifiers
   No modifiers
None
 [Physical]
  HullBounds export
   Exporting 8 (8) vertices
  Setting Region-Specific settings....
  Object is Dynamic
 [Coordinate Interface ButtonRegion]

[Visual Object Button]
 [LogicHelper]
   Exporting actions
   [PythonFileMod Button_AutoClick]
    For python file mod Button_AutoClick, index 1 we're exporting value type 7, key string logicmod:$AutoClick
    Key string boiled down to:  00029B23,0000,002D,Button_AutoClick
    For python file mod Button_AutoClick, index 3 we're exporting value type 14, key string oneshotmod:$AutoClick
    Key string boiled down to:  00029B23,0000,0077,Button_AutoClick
   [OneShotMod Button_AutoClick]
   Exporting modifiers
   Exporting modifiers
  [LogicModifier Button_AutoClick]
   Initial self.fFlags is: BitVector: []
   Got flag: localelement - 0
   self.fFlags is now: BitVector: [   1]
   Conditions:
    Found Condition Button_AutoClick of type: activator
    Found Activator Button_AutoClick of type: picking
    Found Condition Button_AutoClick of type: objectinbox
   Activators:
    Found Activator Button_AutoClick of type: objectinvolume
   Actions:
[{'type': 'pythonfile', 'ref': '$AutoClick'}]
  Action is of type pythonfile
Locating python file reference '$AutoClick'
  Appending Receiver: 00029B23,0000,00A2,Button_AutoClick
 [Draw Interface Button]
  [Material MatButton]
  [DrawableSpans 00000000_0]
   Processing Faces per Material - Totalling 1 materials
   Material MatButton
    Object is Shadeless, not appending any lamps
 [ShadowCaster]
 [Physical]
  HullBounds export
   Exporting 66 (66) vertices
  Mass 1.0
  No Friction, disabling frictive setting
  No Elasticity set
  Pinning object
  Camera blocking enabled
  Object is Dynamic
 [Coordinate Interface Button]


If I leave out the animtarget the region (ButtonRegion) becomes the target. That would have been fine by me had it worked, but still no go. (I was going to tweak the target position later anyway if needed)

Does oneshotmod work in PyPRP 1.2.1? And if it does, what am I doing wrong?
"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: oneshotmod: working or not?

Postby Nadnerb » Wed Feb 27, 2008 4:10 pm

This is something that has always sorta bugged me about the way the simpleclick quickscript is designed. The click detector does not actually activate the animation. Instead, it passes it as a behavior to the python script. The python script is expected to activate the animation. You can get around this by using your own alcscript, probably based on the simpleclick quickscript, and adding an action reference for the oneshot to the click alcscript.
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: oneshotmod: working or not?

Postby Paradox » Wed Feb 27, 2008 5:18 pm

I have example alcScript that works for oneshotmods without the need for python.

Code: Select all
Door:
    type: object
    physical:
        physlogic: detect
    logic:
        actions:
          - type: responder
            tag: Clk
            responder:
                states:
                  - cmds:
                      - type: oneshotmsg
                        params:
                            receivers:
                              - oneshotmod:DoorSeekMod
                        waiton: -1
                    nextstate: 0
                    waittocmd: 0
        modifiers:
          - tag: Clk
            cursor: poised
            flags:
              - localelement
            activators:
              - type: objectinvolume
                remote: RgnDoorClk
                triggers:
                  - any
            conditions:
              - type: activator
                activators:
                  - type: picking
              - type: objectinbox
                satisfied: true
            actions:
              - type: responder
                ref: 007C:$Clk

#Animations (OneShotMods)
DoorSeekMod:
    type: oneshot
    oneshot:
        animation: DoorButtonTouch
        seektime: 2.0
        drivable: true
        smartseek: true
        noseek: false
        reversable: true

#Regions
RgnDoorClk:
    type: region
    region:
        type: logic
    physical:
        physlogic: detect


The Door is the clickable object, the DoorSeekMod is the point for the oneshotmod, and the RngDoorClk is the clickable region.

If this gives you any errors, try using the SVN plugin. This should work with the latest release though.
Paradox
 
Posts: 1295
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: oneshotmod: working or not?

Postby D'Lanor » Thu Feb 28, 2008 1:54 am

Thanks. It actually makes sense to pass it through Python if you want to setup your animation for a multiplayer environment. It is funny that nobody bothered to explain that part.

We have to use Python to make other players see the button pusher do the animation somehow and I don't think prp alone can do that.

And it is going to be tricky: While other players must see the animation they should not be forced to do it themselves. Bad examples of this can be seen in single player ages (Cleft windmill, Bahro cave pillars etc.).

Edit: Here is the Python code needed for the simple click (assuming my clickable is called 'Button').

Code: Select all
actClickableObject = ptAttribActivator(1, 'Act: Clickable Object')
ObjectMsg = ptAttribString(2, 'Object String')
Behavior = ptAttribBehavior(3, 'Avatar animation')

.....

    def OnNotify(self, state, id, events):
        if ((id == actClickableObject.id) and state):
            if (ObjectMsg.value == 'Button'):
                Avatar = PtFindAvatar(events)
                Behavior.run(Avatar)
                #do your other actions here (may need a timer to let the animation finish)


PtFindAvatar will make sure that the animation is applied to the correct avatar.
"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: oneshotmod: working or not?

Postby Paradox » Thu Feb 28, 2008 4:46 pm

Theoretically, you should be able to set SynchedObject flags on the OneShotMod, or the Responder to make it send the message to multiple clients.
Paradox
 
Posts: 1295
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada

Re: oneshotmod: working or not?

Postby D'Lanor » Thu Feb 28, 2008 6:48 pm

But wouldn't that make every avatar do the animation?
"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: oneshotmod: working or not?

Postby Robert The Rebuilder » Fri Feb 29, 2008 6:40 am

Paradox: if you could expand your sample script into a tutorial using a sample age, I'll incorporate seek points/linking book animations into Prin Pahts. [You and Aloys can fight over who does it for the city. ;-) ]

Since I'll need to use a Python script anyway (to calculate which spawn point to link to), I'll make sure I use PtFindAvatar(events) to keep it multiplayer friendly.
Can we rebuild it? Yes, we can - here's how.

MOULagain KI# 1299

Myst Movie coming soon - spread the word!
User avatar
Robert The Rebuilder
 
Posts: 1383
Joined: Sat Sep 29, 2007 7:24 am
Location: Virginia, US

Re: oneshotmod: working or not?

Postby Nadnerb » Fri Feb 29, 2008 12:25 pm

Paradox wrote:Theoretically, you should be able to set SynchedObject flags on the OneShotMod, or the Responder to make it send the message to multiple clients.

D'lanor wrote:But wouldn't that make every avatar do the animation?

D'lanor: Did you read what he said? If the client doesn't send any messages about the animation over the network to other clients, because the sync flag isn't set, then how are all the other clients going to do the animation that they didn't get a message about?

Edit:
Nadnerb: did you read what Paradox wrote? :?
Paradox: did you mean "to make it not send the message to multiple clients."?
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: oneshotmod: working or not?

Postby Paradox » Fri Feb 29, 2008 5:32 pm

There should be a flag to specify that other clients should see the avatar performing the animation. I'm fairly sure that Cyan does most of their animations with using a Python script.

Robert, the code for handling it with a Python script is in the QuickScripts file, I'll look into writing a tutorial for it.
Paradox
 
Posts: 1295
Joined: Fri Sep 28, 2007 6:48 pm
Location: Canada


Return to Building

Who is online

Users browsing this forum: No registered users and 4 guests