Author Topic: How to do special Death-handler code  (Read 8246 times)

0 Members and 1 Guest are viewing this topic.

Offline jtyler125

How to do special Death-handler code
« on: January 12, 2007, 09:53:13 AM »
Ok,

The Death handler code in the SCI tutorial explains how to type die and then the person dies.  How often do you type die in a game?  How do you create situations where the ogre chases you and then when it gets you it kills you. 

1) How do you make and actor kill you when you get too close to it?

2)  How do you make an actor chase you and then kill you?

3)  How do you make an event happen say walk to close to tree shredder and it kills you?

4)  Fall off a cliff and die?

5)  How do you make a car run you over when you walk in the street?

Any suggestions on a better tutorial for dieing other than typing the word die?

Finally, how can you use a weapon of some sort to make other actors on the screen die?

I hate to be so obsessed with death but let's face it, this is a very important part of any sci game.

PS.  Anyone that can answer these questions is totally awesome, and shall be deemed Sci Studio King for a Week.

Thanks,
JT


Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline Doan Sephim

Re: How to do special Death-handler code
« Reply #1 on: January 12, 2007, 11:44:32 AM »
1) How to make an actor kill you when you get too close -and-
2) How yo make an actor chase and kill you are very similar.

They could be done in the following way:
Code: [Select]
(method (doit)
  (super:doit)
  (var dyingScript)
  (if(< (send gEgo:distanceTo(knifeMan)) 15)
    = dyingScript ScriptID(DYING_SCRIPT)
    (send dyingScript:caller(3)
    register("Why so suprised? He was juggling knives.")
  )
(send gGame:setScript(dyingScript))
)
And to get the guy to follow Ego, you have to add the "follow" script to your room script. So with the ("use controls") and ("use main") you add ("use follow") and then make following Ego part of your actor:
Code: [Select]
(knifeMan:init()setCycle(Walk)setMotion(Follow gEgo))
3) How do you make an event happen when too close to a tree shredder -and-
4) Fall off a cliff and die -and-
5) Car run over and kill you when you walk out on the street all follow the same basic idea. Most likely you will want to set up control colors in your (method (doit) so that when your Ego steps on them you trigger the deathScript or an forced animation that ends with the deathScript.
Code: [Select]
(method (doit)
  (super:doit)
  (if(== (send gEgo: onControl()) ctlSILVER)
    = dyingScript ScriptID(DYING_SCRIPT)
    (send dyingScript: caller(100)
      register("Despite your heroic attempt to defy gravity's power, you ended up the worse for it.")
     )
   (send gGame:setScript(dyingScript))
)

I have not ran or tested any of the code, but I think it should be correct.

Offline Cloudee1

Re: How to do special Death-handler code
« Reply #2 on: January 12, 2007, 04:04:37 PM »
It's a good thing I typed all that in yesterday in the sci how to's board  ;D

http://emptysacdesigns.com/sciforum/index.php?topic=62.0

If anyone would like to explore the death handler further, I'll add all of the examples we come up with here to the death handler section thread of how-to, just to make it more comprehensive and to keep all of it in one place.
« Last Edit: January 12, 2007, 04:16:17 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline jtyler125

Re: How to do special Death-handler code
« Reply #3 on: January 12, 2007, 08:26:39 PM »
Sorry to create repetition, I am a newbie still...to tell the truth I am still getting used to the site and not sure where everything is.  Sorry Cloudee!.....Doan is SCI king for the day though...
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline Cloudee1

Re: How to do special Death-handler code
« Reply #4 on: January 12, 2007, 10:09:38 PM »
Sorry to create repetition, I am a newbie still...to tell the truth I am still getting used to the site and not sure where everything is.  Sorry Cloudee!.....Doan is SCI king for the day though...

It's fine, any discussion is good discussion. If anything it provides an opportunity for people to provide more examples of code which can then be added to the how-to making it ever more in depth.

Take your time getting to know the place, it is a lot bigger than our old single board. But two years from now I think it will be alot easier to find things. I don't mind moving topics around, it's something that is going to happen from here on in and not just yours, so don't even worry about it.

« Last Edit: January 12, 2007, 10:18:19 PM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline jtyler125

Re: How to do special Death-handler code
« Reply #5 on: January 12, 2007, 10:46:48 PM »
Ok I tried the Death handler suggested by Doan but I couldn't get it to compile and I played around with it for about an hour trying the other death handlers from the site...I still have problems with the variable line, do I have to add (use "deathhandler") or something at the top...AHHHHH!
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline jtyler125

Re: How to do special Death-handler code
« Reply #6 on: January 13, 2007, 12:35:03 AM »
I got it see below:  this is actually using Cloudee1's death handler and I have four things that can kill me in this room...

Code: [Select]
(instance RoomScript of Script
 (method (handleEvent pEvent)
 (var dyingScript)
 (super:handleEvent(pEvent))
)

             (properties)
 (method (doit)
 (var dyingScript)
 (super:doit())

    (if(not(gProgramControl))
    (if(< (send gEgo:distanceTo(aMan)) 15)  
       ProgramControl()

      = dyingScript ScriptID(DYING_SCRIPT)
      (send dyingScript:
       caller(3)
       register("You're dead")
       )
      (send gGame:setScript(dyingScript))
       )




    (if(not(gProgramControl))
    (if(< (send gEgo:distanceTo(aMan2)) 15)  
       ProgramControl()

      = dyingScript ScriptID(DYING_SCRIPT)
      (send dyingScript:
       caller(4)
       register("You're dead")
       )
      (send gGame:setScript(dyingScript))
       )
      
           (if(not(gProgramControl))
    (if(< (send gEgo:distanceTo(aMan3)) 15)  
       ProgramControl()

      = dyingScript ScriptID(DYING_SCRIPT)
      (send dyingScript:
       caller(5)
       register("You're dead")
       )
      (send gGame:setScript(dyingScript))
       )

           (if(not(gProgramControl))
    (if(< (send gEgo:distanceTo(aMan4)) 15)  
       ProgramControl()

      = dyingScript ScriptID(DYING_SCRIPT)
      (send dyingScript:
       caller(6)
       register("You're dead")
       )
      (send gGame:setScript(dyingScript))
       )
            (if(Said('look'))
            Print("You are in a room...ahhhh there are ghosts all around you stay away from them!!!")
 )
 )
 )
 )
 )
 )
 )

(instance aMan of Act
  (properties
    y 185
    x 220
    view 3
  )
)
(instance aMan2 of Act
  (properties
    y 18
    x 20
    view 4
  )
)
(instance aMan3 of Act
  (properties
    y 85
    x 200
    view 5
  )
)
(instance aMan4 of Act
  (properties
    y 50
    x 10
    view 6
  )
)
« Last Edit: January 13, 2007, 02:51:03 AM by Cloudee1 »
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline Cloudee1

Re: How to do special Death-handler code
« Reply #7 on: January 13, 2007, 02:29:43 AM »
Ok j, I cleaned up your code a little bit you had a couple of funny things going on. Methods should never appear inside of each other. You can have several types of methods acting in a roomscript, but they each close before a new one starts, just like instances, you'll notice that the entire roomscript is an instance of a script and it ends before the other instances begin. Each method has kind of different rules to go by just like instances. For instance it doesn't make sense to apply motion to an instance of sound or to play() a view, certain methods are used for certain things.  doit method checks your if statements every cycle. the handle event method is used to get user input either from the keyboard, mouse, or joystick, if there is no input then it doesn't bother doing anything. The changestate is used to change things around sequentially, but only when its told to.

Also instead of checking for program control around each statement in the doit method, we can just check once and stick those other if statements inside of it. But remember only the things you want to happen when program control is set should go inside there, If you want something checked regardless, it would still need to be in the doit method but outside of the "(if(not(gProgramControl))  ...  ) // ends not program control" statement

Here is what I got out of your roomscript instance. You may want to take a moment to compare yours and this.
Code: [Select]
(instance RoomScript of Script
(properties)
 (method (doit)
 (var dyingScript)
 (super:doit())

 (if(not(gProgramControl))
    (if(< (send gEgo:distanceTo(aMan)) 15)  
       ProgramControl()
       = dyingScript ScriptID(DYING_SCRIPT)
       (send dyingScript:caller(3)register("You're dead"))
       (send gGame:setScript(dyingScript))
    )

    (if(< (send gEgo:distanceTo(aMan2)) 15)  
       ProgramControl()
       = dyingScript ScriptID(DYING_SCRIPT)
       (send dyingScript: caller(4)register("You're dead"))
       (send gGame:setScript(dyingScript))
    )

    (if(< (send gEgo:distanceTo(aMan3)) 15)  
       ProgramControl()
       = dyingScript ScriptID(DYING_SCRIPT)
       (send dyingScript:caller(5)register("You're dead"))
       (send gGame:setScript(dyingScript))
    )

   (if(< (send gEgo:distanceTo(aMan4)) 15)  
       ProgramControl()
       = dyingScript ScriptID(DYING_SCRIPT)
       (send dyingScript:caller(6)
       register("You're dead"))
       (send gGame:setScript(dyingScript))
    )
  ) // ends not program control
 )// end method

 (method (handleEvent pEvent)
 (super:handleEvent(pEvent))

   (if(Said('look'))
    Print("You are in a room...ahhhh there are ghosts all around you stay away from them!!!")
   )// end said look

 ) // end method
) // end roomscript instance

(instance aMan of Act  (properties y 185 x 220  view 3))
(instance aMan2 of Act  (properties y 18 x 20    view 4))
(instance aMan3 of Act (properties y 85 x 200 view 5))
(instance aMan4 of Act (properties y 50 x 10 view 6))

Hope this helps clear some things up.
« Last Edit: January 13, 2007, 04:26:42 AM by Cloudee1 »
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition

Offline jtyler125

Re: How to do special Death-handler code
« Reply #8 on: January 13, 2007, 11:51:33 AM »
Do you need those "//end method" and "//end program control" lines.  Once they turned blue in my script I thought they were the same as entering "/*something not to be included in the script*/"

Just wondering...

Ok I am going to plot your code into my game and give you credit next to it...like this... "/*Code help from Cloudee1*/"

According to Brian, if someone helps you, you should give them credit...I don't want to be a "lamer."
Life is getting better all the time.
Groundhog Day Competition New Year's Competition

Offline Cloudee1

Re: How to do special Death-handler code
« Reply #9 on: January 13, 2007, 01:57:37 PM »
you do need the ) that comes before those // blah blahs but no you don't need the // blah blahs

you are right, they are very simialar to the /* blah blah */. Those are two different ways of adding comments. The /* */ make everything that falls between them a comment and // makes everything following it on the same line a comment. Comments are part of the source code that you can see, but the compiler doesn't. It's like putting notes in there for yourself. Really I put those in there just to mark where the major statements end. All throughout my scripts you'll find where I mark the end of switches methods and instances with those comments. Just to help me find my way around my scripts.

You don't have to give me any credit for anything though, I don't need any kind of glory or recognition.
Halloween Competition Brass Lantern Prop Competition Groundhog Day Competition


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

Page created in 0.036 seconds with 23 queries.