Author Topic: Sci newbie  (Read 2525 times)

0 Members and 1 Guest are viewing this topic.

Offline Lancelot

Sci newbie
« on: January 10, 2004, 08:31:30 AM »
How can i let a character guard a room like in walk around it all the time.



Offline Nychold

Re:Sci newbie
« Reply #1 on: January 10, 2004, 07:26:35 PM »
The easy answer is:

(send theGuard:setMotion(Wander))

or

(Guard:setMotion(Wander))

where theGuard is a pointer and Guard is an instance, or something like that.  I forget the technical terminology. ^_^  However, when I tried to set up it, I noticed a small issue.  You'll want to set up the looper as well:

(send theGuard:setCycle(Walker))
(Guard:setCycle(Walker))

Otherwise, he "floats". XD

The more difficult answer involves writing your own "wander" class, but that's a bit beyond my scope at the moment. ^_~
« Last Edit: January 10, 2004, 07:28:45 PM by Nychold »

Offline Cloudee1

Re:Sci newbie
« Reply #2 on: January 11, 2004, 05:51:15 AM »
Hey I was thinkin about your question and with wander the guard is going to go all over the screen, you could set up a changestate method and set it up so that he'll walk to one point before he walks to another point and so on.

or, a simpler but but more fun approach...

set up a method doit that goes something like
if guard on control colour red then setmotion walk to xy1, else if guard on control colour green then setmotion walk to xy2
now add the two colours to your pictures each surrounding the appropriate set of xy
when init the guard be sure to set him on one of the two colors, and he should just truck back and forth.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline Lancelot

Re:Sci newbie
« Reply #3 on: January 11, 2004, 10:44:19 AM »
Thanks that did it.
I had the problem by using the wander method.

Offline robingravel

Re:Sci newbie
« Reply #4 on: January 11, 2004, 11:44:03 AM »
Here a scrip with wander is used:

Quote
/******************************************************************************/
(include "sci.sh")
(include "game.sh")
/******************************************************************************/
(script 32)
/******************************************************************************/
(use "controls")
(use "cycle")
(use "door")
(use "feature")
(use "game")
(use "inv")
(use "main")
(use "obj")
(use "wander")
/******************************************************************************/
(instance public rm032 of Rm
 (properties
  picture scriptNumber
  north 35
  east 33
  south 0
  west 0
 )
 (method (init)
  (super:init())
  (self:setScript(RoomScript))

  (switch(gPreviousRoomNumber)
   (case north
    (send gEgo:
     posn(120 173)
     loop(2)
    )
   )
  )
  SetUpEgo()
  (send gEgo:init())
  (robot:init()setCycle(Walk)setMotion(Wander))
  )
 )
)
/******************************************************************************/
(instance RoomScript of Script
 (properties)
 (method (handleEvent pEvent)
  (super:handleEvent(pEvent))
  (if(Said(look>'))
   (if(Said('[/*,!*]'))
     Print("Empty room")
   )
  )
 )
)
(instance robot of Act
 (properties
  x 240
  y 183
  view 79
  xStep 5
  yStep 5
 )
)

Robin Gravel

Offline Nychold

Re:Sci newbie
« Reply #5 on: January 11, 2004, 02:01:12 PM »
There is also a DPath class (which I found after I had finished a Path class) which allows you to add points (x,y) to a List, and then those points get cycled through.  Unfortunately, I didn't see a way to pause the actor, which I'm currently working on.  You may want to look into using this class, as well.  :)


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

Page created in 0.151 seconds with 21 queries.