Community

SCI Programming => Mega Tokyo SCI Archive => Topic started by: Lancelot on January 10, 2004, 08:31:30 AM

Title: Sci newbie
Post by: Lancelot 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.
Title: Re:Sci newbie
Post by: Nychold 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. ^_~
Title: Re:Sci newbie
Post by: Cloudee1 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.
Title: Re:Sci newbie
Post by: Lancelot on January 11, 2004, 10:44:19 AM
Thanks that did it.
I had the problem by using the wander method.
Title: Re:Sci newbie
Post by: robingravel 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
Title: Re:Sci newbie
Post by: Nychold 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.  :)