Please login or register.

Login with username, password and session length
Advanced search  

News:

IRC channel - server: waelisch.de  channel: #wme (read more)

Author Topic: the same NPC in diferent rooms in "real time" how to?  (Read 5564 times)

0 Members and 1 Guest are viewing this topic.

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
the same NPC in diferent rooms in "real time" how to?
« on: November 12, 2010, 01:54:27 PM »

hello, I have 1 question, I want that one of my NPC´s stay in the village, but in some time, this NPC go to the forest and there he/she make firewood, returns to his/her house and stay there many time.

in theory I will make a global NPC, I want real time (if in my PC is 1:30 pm the NPC goes to make firewood and if I stay in the minimap I see him to go to the forest, for example, and when I go to the forest I see him making firewood) or make that the NPC goes to the forest every hour and stay there 15 minutes and return to his house and stay there 44 minutes and return to the forest, something like this.
it´s posible?
how many scripts I have to make, one per scene?
where I make the scripts?

I read some post about this, not exactly to this, and I dont understand how works and how I make the script/scripts
thanks for reply and sorry for my bad english
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #1 on: November 12, 2010, 04:40:21 PM »

Actually, if you want to do it realtime ( you have to be careful with such things, don't do things like: PLayer HAS to meet NPC x at 6pm in THAT scene... ) , you should simply do a script in every scene you want the NPC to act, and simply check time.

Pseudo Code :

scene1:
if time > 3pm and time < 6 pm {
 
  actor load
  do things
}

scene2:
if time > 6pm and time < 9 pm {
  actor load
  do other things
}


That's the way I would approach this.

Greets,

Spellbreaker
Logged

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #2 on: November 12, 2010, 10:31:45 PM »

thanks!!!!
I think the idea of make one NPC in one time to talk with the actor, but this is horrible, a bad idea, my intention is that one NPC goes to one Room stay there 30 minutes for example, and goes to other room stay there X time, and goes to other room and stay there some time, etc,

 I´m a beginner  in scripts, How I make to link the PC time with the game time to make the NPC to stay in one Room or in other room? with the Game.CurrentTime?

thanks for reply so fast

Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #3 on: November 15, 2010, 04:56:31 PM »

I have more problems, when I write the code of the one scene in Scene_init the NPC runs ok, but only if I go out of the room the script runs, if I stay in the same room with the NPC, this repeat always the same animations, and never put NPC.Active= false the code is this:
Code: [Select]

var WindowsTime = new Date();
var cocineroOcupado = false;
var sitioCocinero = 0;

while (true)
{
if (NPC.Ready)
{
if(cocineroOcupado == false)
{

cocineroOcupado = true; //
tiempoInicio = Game.WindowsTime; //
}
else
{
if (WindowsTime.GetMinutes() > 27 && WindowsTime.GetMinutes() < 35)
{
if (sitioCocinero == 0)
{
NPC.Direction=DI_UP;
NPC.GoTo(485,525);
NPC.GoTo(389,400);
Sleep(3000);

if (WindowsTime.GetMinutes==34)
{
NPC.GoTo(686,454);
NPC.Active=false;
sitioCocinero = 1;
}


}
}
else NPC.Active=false;
}

}
else
{
cocineroOcupado = false;
}

Sleep(100);
}


if I stay with the NPC in the same room, this code never runs:

Code: [Select]
if (WindowsTime.GetMinutes==34)
{
NPC.GoTo(686,454);
NPC.Active=false;
sitioCocinero = 1;
        }

and the question is: How I make the scripts to see the NPC in specific one minute the NPC go out of the room and if I go to the other room the NPC stay there walking?
I try with CurrentTime too, but the result is the same.
I want that the NPC stay in one room a few time, 35 minutes for example making some animations, and I want that the NPC when the time arrive at the 35 minute, the NPC go out of the room, it goes around the minimap, and arrives at the forrest and stay there playing some animations 24 minutes, for example, but in real time, not when I enter in the scene the NPC start his animation,

I dont know if I explain very well,
if some one can help me...
thanks!!!
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #4 on: November 15, 2010, 08:58:44 PM »

I don't understand your code there, you use WindowsTime.GetMinutes >27 < 35  ... That means the if only happens if the time is for example between 9:27 and 9:35 ...

You can for example simply do the following:

Player enters scene -> save Game.CurrentTime();
Player re-enters the scene later -> Check Game.CurrentTime() against the saved time, so you know how much time has passed.

Of course, when player exits the game and re-enters, CurrentTime() starts from zero. But that shouldn't be a problem at all.
Logged

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #5 on: November 15, 2010, 09:29:31 PM »

mmm, what I want is that one entity, no my player, make some animations until one time, when the entity arrives at any time in the hour for example the minute 30, the entity plays the animation to go out of the room, I want NPCs like the game Lure of the tempress, that his NPCs walk in some rooms, I want to do something like this

the mistakes in this code is that when I enter the room the script execute, but the entity(is one actor in NPC mode) only executes the code at the time I entered in the room, if the state is this (WindowsTime.GetMinutes() > 27 && WindowsTime.GetMinutes() < 35) alwais execute this animations in looping, but when the time pass, the animations doesnt chage, although the time are 40 for example, but if I go out of the room and enter the entity executes the other animations, or is inactive, but not execute this code if I stay in the same room that the entity
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English

Spellbreaker

  • Supporter
  • Frequent poster
  • *
  • Karma: 4
  • Offline Offline
  • Gender: Male
  • Posts: 376
    • View Profile
    • Apeiron Studios
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #6 on: November 18, 2010, 08:42:52 PM »

I know what you mean, of course you have to "deactivate" the actor when the time is NOT between your two minute values. And once again, do not use WindowsTime, use the time passed since game started for such activities....Otherwise you could create stuff a player will never ever see ;)


Logged

YO

  • Our first adventure:
  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 32
    • View Profile
Re: the same NPC in diferent rooms in "real time" how to?
« Reply #7 on: November 18, 2010, 09:09:02 PM »

ok, I created one code and one script, I see this script in one post of this forum that was created by mnemonic, and I make some changes to run as I want, this is the script that I see in this post:
Code: [Select]

#include "scripts\base.inc"


TimerValue = 0;

while (true)
{
  TimerValue = TimerValue + 1;
  Sleep(1000);
}

and this is the code modified, that reset every 60 seconds, in the game will be more time but this is a test:
Code: [Select]
 
#include "scripts\base.inc"


TimerValue = 0;

while (true)
{
  TimerValue = TimerValue + 1;
  Sleep(1000);
    if (TimerValue==59)
    {
TimerValue = TimerValue - 59;
    }
}


and the code of the NPCin the Scene_init in one room is this (in the other room is the same but with other times):

Code: [Select]

var cocineroOcupado = false;
while (true)
{
if (NPC.Ready)
{
if(cocineroOcupado == false)
{

cocineroOcupado = true;

}
else
{
if (TimerValue > 20 && TimerValue < 35)
{
NPC.Active=true;   
NPC.Direction=DI_UP;
NPC.GoTo(485,525); //
NPC.GoTo(389,400);
Sleep(3000);


}
else if (TimerValue >34 && TimerValue <45)
{
NPC.Active=true;
NPC.GoTo(686,454);
}
else NPC.Active=false;
}

}
else
{
cocineroOcupado = false;
    TimerValue = TimerValue;
}

Sleep(100);
}

the script of the NPC order to the TimerValue that if the NPC is talking the TimerValue is paused, but I have one bug, when Im talking with the NPC all is correct, but when I stops talking the NPC doesnt play his animations, I go out of the room and go in other time to the same room and the script runs ok, but the bug is this, after I was talking with him, he doesnt move, and do nothing

Something Im doing wrong but I dont know what
Logged
Henry y El libro magico, proximamente sacaremos la demo en español...
Henry and the magic book, demo coming soon in English
 

Page created in 0.027 seconds with 23 queries.