moving While NPC animating?

Started by Timosity, Mon 26/05/2003 11:14:35

Previous topic - Next topic

Timosity

Is it possible to use the player character while npc's perform animations (not just walking)

obviously I need a way to perform an animation without using a wait command but this seems impossible.

I've got a room where after 20 secs a npc comes into the screen and performs an animation along with another npc. but I want this to happen in the background without pausing the game, so I can still walk around while it happens.

Is it posible

At the moment I can only regain control while the npc is walking off the screen.

Here is my code from the rooms repeatedly execute, cause it relies on a timer.

if (IsTimerExpired(1)==1){
 character[PIN].room = 17;
 character[PIN].x = 340;
 character[PIN].y = 133;
 SetGlobalInt(21,1);
MoveCharacterDirect(PIN,185, 151);
while (character[PIN].walking) Wait(1);
SetCharacterView(PIN,71);
AnimateCharacter(PIN,0,5,0);
while (character[PIN].animating) Wait(1);

****isert here another npc animation******

ReleaseCharacterView(PIN);
MoveCharacterDirect(PIN,340, 133);
SetTimer(2,800);
}

It seems asthough you can only have a npc walk around while you still have control of the player character and not while performing animations.

I know it is because of "while (character[PIN].walking) Wait(1);" and "while (character[PIN].animating) Wait(1);" but they are necessary for the animations to work.

Is it possible?

aussie

I haven't been able to come up with a satisfactory solution for myself, but what about setting up two timers?

Timer 1 tells the computer when your npc has to come into the screen.

Timer 2 one is set "on" as soon as the npc starts walking and lasts for as long as it takes him to get to the desired spot (even a bit longer, so the npc seems to pause before the spot).

Then you can run your animation, do whatever, and make him walk back out. Remember to set these timers off if required.
It's not the size of the dog in the fight. It's the size of the fight in the dog.

http://www.freewebs.com/aussiesoft/

Timosity

I'll give it a go and see if it works,

thanks aussie

Timosity

#3
A 2nd Timer doesn't seem to work instead of "while (character[PIN].animating) Wait(1);"

The timer waits for the period of time but it doesn't even let the character walk onto the screen.

I've tried a few variations but can't get it to work.

If anyone can post some script you think might work, would be appreciated, but otherwise I'll just have to go with the game pausing while the animations happen.

Erica McLane

As far as I know the engine is paused while an animation is running. Check the manual for AnimateCharacterEx or for an option in AnimateCharacter to make the animation non-blocking.

Timosity

Thanks Erica, but I had checked that out and it still doesn't allow control to the player character while it's happening.

It's important, what happens when the NPC's enter the screen, so pausing the game isn't too much of a problem, but not exactly what I wanted.

If there are any other suggestions to make it work it will be appreciated otherwise I would like to suggest maybe something like:

AnimateCharacterBackground similar to AnimateCharacterEx but doesn't stop you from walking around at the same time.

miguel

sorry but I've been listening behind the door,

another sugestion:
DisplaySpeechBackgroundTalkingView,

I have more or less the same problem as you, I also have a timer and I need that some npc's talk among them on the background
Working on a RON game!!!!!

Scorpiorus

The solution here is to remove the code:

while (character[PIN].animating) Wait(1);

****isert here another npc animation******

ReleaseCharacterView(PIN);
MoveCharacterDirect(PIN,340, 133);
SetTimer(2,800);


And just start the animation here.
Oh, if you want him to move elsewhere after the animation has been done just check it in repeatedly but separately instead:

room's repeatedly:


//the first part:
if (IsTimerExpired(1)==1){
character[PIN].room = 17;
character[PIN].x = 340;
character[PIN].y = 133;
SetGlobalInt(21,1);
MoveCharacterDirect(PIN,185, 151);
while (character[PIN].walking) Wait(1);
NPC_HasComeToTheScreen = 1; //he has arrived
SetCharacterView(PIN,71);
AnimateCharacter(PIN,0,5,0);
}


//the second part:

if (NPC_HasComeToTheScreen) { // some GlobalInt I think

 if (character[PIN].animating == 0) {
    ReleaseCharacterView(PIN);
    MoveCharacterDirect(PIN,340, 133);
    SetTimer(2,800);
    NPC_HasComeToTheScreen = 0; //so it wouldn't happen repeatedly!
 }

}

so this way :P

-Cheers

Timosity

That does work Scorpiorus, but the only problem now is that if I leave the screen during the animation, it stuffs it up, and if I leave while the character is walking off the screen, when I return he is just paused in the same spot as when I left.

I know you made the plugin CCS, but I haven't had a play around with that yet, but I noticed with the game keptosh that juncmodule made, the characters moved around even when you went to another room. I think he used your plugin.

But maybe I'll just have it so the game pauses, I haven't fully decided yet.

(plus my computer crashed yesterday and I had to format, lucky I back up daily)

Timosity

#9
Here's the script that works but I haven't added in any speech yet, that's the next step.
EDIT: I added some speech

   // script for room: Repeatedly execute
if (IsTimerExpired(1)==1){
character[PIN].room = 17;
character[PIN].x = 340;
character[PIN].y = 133;
SetGlobalInt(21,1);
MoveCharacterDirect(PIN,277, 139);
SetGlobalInt(33,1); //for next stage speech
}


if (GetGlobalInt(33)==1){
if (character[PIN].walking == 0) {
game.speech_text_gui=4;
DisplaySpeech(PIN,"Text goes here character is talking!");
Wait(1);
MoveCharacterDirect(PIN,248, 147);
SetGlobalInt(33,2); //for next stage speech
}
}


if (GetGlobalInt(33)==2){
if (character[PIN].walking == 0) {
DisplaySpeech(PIN,"Text goes here character is talking!");
Wait(1);
MoveCharacterDirect(PIN,222, 157);
SetGlobalInt(33,3); //for next stage speech
}
}


if (GetGlobalInt(33)==3){
if (character[PIN].walking == 0) {
DisplaySpeech(PIN,"Text goes here character is talking!");
Wait(1);
MoveCharacterDirect(PIN,185, 165);
SetGlobalInt(33,4); //for next stage
}
}



if (GetGlobalInt(33)==4){
if (character[PIN].walking == 0) {
SetCharacterView(TAW,75);
AnimateCharacter(TAW,0,5,0);

SetCharacterView(PIN,71);
AnimateCharacter(PIN,0,5,0);
SetGlobalInt(33,5); // for next stage

}

}


if (GetGlobalInt(33)==5) {

if (character[PIN].animating == 0) {
ReleaseCharacterView(PIN);

AnimateCharacterEx(TAW,0,5,0,1,0);

MoveCharacterDirect(PIN,340, 133);
SetTimer(2,800);
SetGlobalInt(33,0); //so it doesn't repeat
SetGlobalInt(26,1); // action complete so doesn't start over on re entry

}

}



And I figured out how to make it work if I leave the screen with this.



 // script for room: Player leaves screen
if (GetGlobalInt(26)==0) {
 SetGlobalInt(21,0);
 SetGlobalInt(33,0);
   
 character[PIN].x = 340;
 character[PIN].y = 133;
 ReleaseCharacterView(PIN);
 ReleaseCharacterView(TAW);
 
}

if (GetGlobalInt(26)==1) {
 ReleaseCharacterView(TAW);
 character[PIN].x = 340;
 character[PIN].y = 133;
}

There's also script for when I enter the screen but that's for setting the  1st timer and to know which stage I'm up to cause this script has 2 more parts for 2 more characters entering the screen.

I have it set up so if the npc has not finished what he does and you leave, it starts from scratch, but if he is walking off the screen when you leave, that section is over.

there are two more characters that  do the same thing and the same thing happens to each, if you leave the screen, they will start again too.

I posted it just incase anyone is interested or can think of something else.

~Tim

Scorpiorus

That is actually why I decided to write the CCS plugin. Here is the thread where I had a talk with junc about the same thing: http://www.agsforums.com/yabb/index.php?board=2;action=display;threadid=2959
You can see there that making the character perform a couple of actions took about 40 lines of code. And it just for one sequence! And those IFs......
Yep, the only possible solution to make such things is to write amount of IF statements. It's ok when you need it to happen only in one room but when not? So, yes, juncmodule had used CCS plugin instead. The plugin interface isn't perfect but anyway it does its job. Atleast it keeps the repeatedly execute function clean. :)

QuoteBut maybe I'll just have it so the game pauses, I haven't fully decided yet.
Years ago playing different quests I always wonder  why in some games you can't perform actions while the NPC is doing something. Now it's eviden why developers block the player (SpaceQuest). ....because when I would like to check what happens if I exit the room just before the NPC does. ;D

-Cheers

Timosity

Yeah that last point is a good one. I guess the Leave room feature works for that.

I've got it all working now but yeah, the repeatedly execute for the room goes up to line 425.

but It doesn't effect any other rooms in the game so I don't know if I'll need the plugin but I'll still check it out sometime.

Thanks for all the help

~Tim

SMF spam blocked by CleanTalk