Author Topic: Priority of overlapping views  (Read 1023 times)

0 Members and 1 Guest are viewing this topic.

Offline snobes

Priority of overlapping views
« on: September 15, 2023, 12:23:41 PM »
Hello.

I have a use case where an Actor (a hen) walks in front of a static Actor (an ogre). I want the hen Actor to always take priority when it walks in front of the ogre Actor. My issue is that when the hen enters the "boundary box" of the ogre (meaning the hen does not appear to be in front of the ogre but from a View perspective, the hen has entered the box around the whole ogre view), the hen is no longer clickable ("V_DO-able").

What is the correct way to keep a view on top of another view even within the boundary box.

I have a script that tries to do this, but, like I said, the hen is not clickable when it walks in front of the boundary box of the ogre. Here is my script:


   (method (changeState newState &tmp nextHenX nextHenY)
      (= state newState)
      (= nextHenX (Random 75 75))
      (= nextHenY (Random 140 140))
      (switch state
         (0
            (if (== gKeyholePic CABIN_KEYHOLE_PIC_SLEEP) (self cue:))
         )
         (1
            (ogre init: setCycle: Forward setSpeed: 60) ; init the ogre
                 (self cue:)
         )
         (2
            (if (not (gEgo has: INV_HEN))
               (hen posn: 87 159 init: ignoreActors: FALSE setSpeed: 3 setCycle: StopWalk -1) ; init the hen
               (self cue:)
            )
         )
         (3
            (hen setMotion: PolyPath nextHenX nextHenY self) ; move the hen (could possibly get moved in front of the ogre)
         )
         (4
            (= seconds 1)
         )
         (5
            (self changeState: 3)
         )
      )
   )


; the hen Actor
; this should take priority over the ogre
(instance hen of Actor
   (properties
      view HEN_VIEW
      signal ignAct
      loop 0
      cel 0
      noun N_HEN
   )
   
   (method (doVerb theVerb)
       (switch theVerb
           (V_DO
            (if (<= (self distanceTo: gEgo) 15)
               (rm1701 setScript: getHen)
            else
               (gMessager say: N_ROOM 0 C_NOT_CLOSE_HEN 0)
            )
           )
           (else
               (super doVerb: theVerb &rest)
           )
       )
   )
)

; the ogre
(instance ogre of Actor
   (properties
      view OGRE_SLEEPING_VIEW
      x 242
      y 170
      signal ignAct
      noun N_OGRE
   )
)


I don't know what I'm doing wrong to cause the hen to no longer be clickable when in the ogre's boundary box. Any suggestions would be helpful.

Thanks.



Offline doomlazer

Re: Priority of overlapping views
« Reply #1 on: September 15, 2023, 05:31:38 PM »
No idea if this would work, but you could try adding something like this to the hen's doit:

Code: [Select]
(instance hen of Actor
...
(method (doit)
(if (== (hen priority?) (ogre priority?))
(hen setPri: (+ (ogre priority?) 1))
else
(hen setPri: -1) ;let the game set priority
)
)

« Last Edit: September 15, 2023, 05:39:45 PM by doomlazer »


SMF 2.0.19 | SMF © 2021, Simple Machines
Simple Audio Video Embedder

Page created in 0.026 seconds with 23 queries.