CCS plugin implicitly enables some parameters ??

Started by Silbad, Thu 18/12/2003 16:31:06

Previous topic - Next topic

Silbad

Hi !

I've downloaded the CCS plugin and I must admit that it's very ingenious.

But I still have a little problem with it. My purpose is the following :
When I interact with the character MAN, I want him to say me " No ! Let me alone ! " then to run away in another room. But I also want him to become " unclickable " while he’s walking to the room. So, in the Interact function, I wrote this :

DisplaySpeech(MAN,"No! Let me alone!");
SetCharacterClickable(MAN,0);
ccCreateCommand(1,"move:119,163;Room:2,158,128;");
ccExecuteCommand(MAN,1);

The problem is that I can still click on him, which runs the interaction script again. Does the CCS commands enable clicking when called ?

Another question :
Without using CCS, I’d like to make the  character MAN move to a point, then make him change room. While the character is walking, I also want to be able to control the player character.
But if I use this :
MoveCharacter(MAN,119,163) ;
character[MAN].room=3 ;
then MAN disappears instantly without walking to the point (since MoveCharacter is a non-blockable function).

If I use this :
MoveCharacterBlocking(MAN,119,163) ;
character[MAN].room=3 ;
I can’t control the player character until MAN has reached the point.

What can I do to perform an action only if the previous one is over without blocking the game ?

PS: Forgive my bad English, I'm French...  ::)

SSH

For your first problem, I must say that I never noticed that there was sucha function to control clickablitity! I woul dhave used a globalint and  put an if around his interaction! Sorry I can't help more...

For the second problem, you need to check the variable character[MAN].walking in your repeatedly_execute. You will probably need a variable to control the effect of this check, too.
12

juncmodule

#2
Quote
What can I do to perform an action only if the previous one is over without blocking the game ?
from the man himself:

Quote
hope the next is what you need....

//Room Script

int NeedChecking = 0; //is set to 1 after calling StartActions();
int ActionNumber = 0; //stores the next action to proceed.
int PauseCounter = 0; //is used for 'pause' action.

function StartActions() {
 NeedChecking = 1; //enables checking;
 ActionNumber = 1; //sets the first action to proceed;
}


function room_a() {
 // script for room: Player enters screen (after fadein)

 StartActions(); //or you may place it on some other event.
}



function room_b() {
 // script for room: Repeatedly execute
 if (NeedChecking == 1) { //if StartActions() has been called...

  //if paused then decrease pause.
  if (PauseCounter>0) PauseCounter--;

  //if character is doing nothing then proceed the next action...
  if ((character[MANFOUR].walking  == 0)  &&
      (character[MANFOUR].animating == 0)  &&
      (PauseCounter                <= 0)) {
        if      (ActionNumber == 1) { //move character MANFOUR
     MoveCharacterDirect(MANFOUR, 276, 174);
     ActionNumber = 2; //goto action 2 after comleting this one.
    }
    else if (ActionNumber == 2) { //set pause (1000 loops)
     PauseCounter = 1000;
     ActionNumber = 3; //goto action 3 after comleting this one.
    }
    else if (ActionNumber == 3) { //proceed some animation
     SetCharacterView(MANFOUR, int view);
     AnimateCharacter(MANFOUR, int loop, int speed, 0);
     ActionNumber = 4; //goto action 4 after comleting this one.
    }
    else if (ActionNumber == 4) { //last action...
     NeedChecking = 0; //disables checking; use StartActions() to start again.
     //...or ActionNumber = 1; (good for looping actions)
    }
  }

 
 } //end of needchecking block

 
}

This way you may have as many actions as you need. (don't forget about looping[see action 4] as well as about making random selection: ActionNumber = 1 + Random(3) ).
Pay attention on 'if ((character[MANFOUR].walking  == 0) && (..........)' statement. It guarantees that the next action (among: MoveCharacter/AnimateCharacter/Pause[added]) will proceed only after completing of a current one.

- Scorpiorus

Quote
The problem is that I can still click on him, which runs the interaction script again. Does the CCS commands enable clicking when called ?

I do not think CCS interferes with interaction at all. I would take SSH's recommendation and set up a global int in your interaction script for that NPC.

Here is a sample script that would go under your character/interaction/talk to or whatever

Quote
if (GetGlobalInt(Interact_with) == 1) {
ccPauseExecution(MAN);
DisplaySpeech(MAN,"No! Let me alone!");
SetGlobalInt(Interact_with, 0);
ccResumeExecution(MAN);
}
if (GetGlobalInt(Interact_with) == 0) {
// Do Nothing
}

EDIT: One other thing, it appears that you are not using CCS "by-the-book". I'm not sure how much is required by CCS but all of your commands are supposed to go under the game_start() function, not in a interaction script. Perhaps CCS is not what you need for what you are doing. I'm just a little confused. If it is not what you need then the above script from Scorpiorus should work as a good replacement.

EDIT 2: SSH, as far as I know nearly every checkable option in the AGS editor is modifiable via scripting. Especially under general settings and the character editor. This is of course because: Chris is a genious.  ;D

good luck,
-junc

Scorpiorus

#3
QuoteThe problem is that I can still click on him, which runs the interaction script again. Does the CCS commands enable clicking when called ?
Ah, yes that is it. It's due to the way the MOVE command works and it's kind of a bug actually. Thanks for spotting that; I'll fix it for the next version. ;) As SSH suggested, a workaround would be to set a global int and check it inside the interaction event function. See the sample script that junc provided.

QuoteOne other thing, it appears that you are not using CCS "by-the-book". I'm not sure how much is required by CCS but all of your commands are supposed to go under the game_start() function, not in a interaction script.
Although it doesn't matter where to place it, having all the definitions at one place helps organize the script code.

I also agree with junc - if you just want a move-then-gotoroom sequence using the script may be simplier, example:

room's script:

//at the top of room script
int player_clicked = 0; //whether character was clicked on (1 true, 0 false)


character interact interaction:

player_clicked = 1; //just clicked on
MoveCharacter(MAN, 119, 163); //move him




room's repeatedly:

// if the character stopped...
if (character[MAN].walking == 0 && player_clicked == 1) {
   StopMoving(MAN); //just in case
   character[MAN].room = 2;
   character[MAN].x = 158;
   character[MAN].y = 128;
   player_clicked = 0;
}


~Cheers

Silbad

#4
QuoteI'm not sure how much is required by CCS but all of your commands are supposed to go under the game_start() function, not in a interaction script.
Actually, I'm just trying the CCS plugin to understand how it works. I don't need it for a particular use. ;)

QuoteI also agree with junc - if you just want a move-then-gotoroom sequence using the script may be simplier.
Yeah, that's what I did, but I don't like much to use the « repeatedly_execute function » . Can it slow down the game to put too many instructions inside it? I mean, as this function runs x times per second, that means all the instructions will be executed x times too...

Anyway, thanx for your accurate answers ! 8)

Scorpiorus

QuoteYeah, it's the way I did, but I don't like much to use the « repeatedly_execute function » . Can it slow down the game to put too many instructions inside it?
No, don't be afraid of that. The instructions are executed quite fast. In fact there are certain commands that cause a noticeable slowdown, for example RawRestoreScreen(). As you can see it just a one line of code but it a lot heavier than a bundle of if statements.

To slow it down you have to have a long repeatative while loop inside the repeatedly execute :)

repeated_execute:
int i=0;
while (i<40000) {
i++;
}


Silbad

OK, I'm relieved! 8)

By the way, congratulations to Scorpiorus for your Snow-Rain Plugin. Very Impressive! Did you create it using the RawDrawImage function?

Scorpiorus

Thanks. :)

No, I used the plugin API functions and Allegro library.

~Cheers

Pumaman

That reminds me - with the latest v2.6 plugin API, do you still need the Allegro DLL? and if so, what functions are you using if I may ask?

It'd be neater if I could export enough functions from the engine that you didn't need to include Allegro.

Scorpiorus

Indeed, the last AGS version includes many useful API functions. As for the snow/rain plugin, for example, most of the Allegro functions are related to bitmap drawing: draw bitmap transparent (with opacity), draw bitmap rotated (don't remember actual names). Having a couple of them exported would be very nice. In fact the plugin in question uses only those I mentioned.

thanks,
cheers

Pumaman

If you'd like to dig out the actual function names at some point (so that I do add the correct ones ;) ) I'd be happy to export them.

Scorpiorus

#11
Thanks, Chris. I just took a look, the functions are:

void set_trans_blender(int r, int g, int b, int a);

void draw_trans_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y);

void rotate_sprite(BITMAP *bmp, BITMAP *sprite, int x, int y, fixed angle);

Pumaman

okey doke, I'll add those to my to-do list.

SMF spam blocked by CleanTalk