Hello Guest, please login or register.
Did you miss your activation email?
Login with username, password and session length.

Pages: [1]   Go Down

Author Topic: [Example /Listing] NPC Engine *GM6*  (Read 2176 times)

0 Members and 1 Guest are viewing this topic.
[Example /Listing] NPC Engine *GM6*
« on: May 08, 2006, 05:53:12 pm »
  • ^This is my sprite comments char
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 226
 ;D hi this is my first  *hard* engine made:

NPC ENGINE:
you should add this on a Step Event

Code: [Select]
if place_meeting(x,y+4,objlink){
  if keyboard_check(ord('X')){
   if distance_to_object(objlink)<10{
    screen_redraw();
    Say("I'm AN NPC BRO!",true,true,true);
    }}}

Eplanation:
if place_meeting(x,y+4,objlink){  This line tells the objcet if link's is in the position y+4 or +3 +2 +1 +0 go to the next line
if keyboard_check(ord('X')){ If thew KEY "X" (can be replaced) is pressed when links is at the psotion y+4 y+3 +2 +1 0 next line
if distance_to_object(objlink)<10{ If the distance is minor to 10, the Say line should apear
Say("I'm AN NPC BRO!",true,true,true); TRW engine, you should wirte in here the NPC Dialog

so, try to fool aroud whit this... if you want an npc that vanish after he talks, add the line instance_destroy() after the Say line

YOU NEED: TRW's TEXT ENGINE, an object for the npc, and a link char(replace the objlink on the code for the name of you link object)
« Last Edit: February 10, 2012, 02:41:50 pm by Niek »
Logged



i'm working on:

I support and i'm part of the team of:
Re: NPC Engine *GM6*
« Reply #1 on: May 09, 2006, 11:08:09 am »
  • Master Of Disaster
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 2330
Hmm... Nothing i haven't seen before... But still useful to some people who are just starting with gamemaker :)
Logged


.TakaM was here
  • Lumeuni

master414

Re: NPC Engine *GM6*
« Reply #2 on: May 09, 2006, 12:36:12 pm »
Will the npc it self walk random ?
Logged

A Storm in the Desert

Eternal Triangle
Re: NPC Engine *GM6*
« Reply #3 on: May 09, 2006, 01:16:04 pm »
  • Wear the Deku Sprout Smile :]
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Gender: Male
  • Posts: 222
I believe this is an NPC dialogue engine. It doesn't make the NPC move. But if the NPC were walking, you'd need additional code to make sure that you could only talk to it while it was facing you. To tweak for a moving NPC:

Code: [Select]
switch (npcdir)
{
case "down"
if place_meeting(x,y+4,objlink){
  if keyboard_check(ord('X')){
   if distance_to_object(objlink)<10{
    screen_redraw();
    Say("I'm AN NPC BRO!",true,true,true);
    }}}
case "up"
if place_meeting(x,y-4,objlink){
  if keyboard_check(ord('X')){
   if distance_to_object(objlink)<10{
    screen_redraw();
    Say("I'm AN NPC BRO!",true,true,true);
    }}}
case "left"
if place_meeting(x-4,y,objlink){
  if keyboard_check(ord('X')){
   if distance_to_object(objlink)<10{
    screen_redraw();
    Say("I'm AN NPC BRO!",true,true,true);
    }}}
case "right"
if place_meeting(x+4,y,objlink){
  if keyboard_check(ord('X')){
   if distance_to_object(objlink)<10{
    screen_redraw();
    Say("I'm AN NPC BRO!",true,true,true);
    }}}
}

That should work for multiple directions, you'd need to declare 'npcdir' in the NPC's movement script so that the program knows the value you're declaring, there are probably a few bugs with this...might want to make a handler for whether or not the player is facing the NPC...I could probably refine this script a bit more, seeing as I only duplicated the script, added a switch and changed a few variables. If anyone wants a refined version, either PM me or post a request in this thread. I'll write a comprehensive NPC engine if anyone needs one.

EDIT: And an explanation of how the whole thing works would go with the engine as well. ;P
« Last Edit: May 09, 2006, 01:19:22 pm by A Storm in the Desert »
Logged
Surely you can do it!
Believe in your strengths...Believe...

        -Happy Mask Salesman

master414

Re: NPC Engine *GM6*
« Reply #4 on: May 27, 2006, 10:29:09 am »
I would like one :P
Logged
Re: NPC Engine *GM6*
« Reply #5 on: May 27, 2006, 01:11:20 pm »
  • ^This is my sprite comments char
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 226
i' workin on a moving engine.
Logged



i'm working on:

I support and i'm part of the team of:

master414

Re: NPC Engine *GM6*
« Reply #6 on: May 27, 2006, 01:58:45 pm »
For npc ? and do you gonna publish it :P ?
Logged
Re: NPC Engine *GM6*
« Reply #7 on: June 04, 2006, 05:55:03 pm »
  • *
  • Reputation: +0/-0
  • Offline Offline
  • Posts: 351
Nice, good work man.
Logged
"May the innovation be with you."

www.guffa.smf4free.com
Pages: [1]   Go Up

 


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Page created in 0.055 seconds with 53 queries.