CCS plugin problem (SOLVED)

Started by Kinoko, Sun 10/07/2005 16:07:06

Previous topic - Next topic

Kinoko

This is really for Scorporius but if anyone else can answer me, please do so ^_^

I'm using the Character Control System plugin (v1.02) and trying to write some code so that a character moves either only on the x axis or only on the y axis.

This is the code for the Y axis movement inside a function I've made:

Code: ags

int currentx = character[charname].x;
StrFormat(randompathy,"MOVE:%d,%d;WAIT:%d;GOTO:1;",currentx, y1, weight);
ccCreateCommand(numb+1, randompathy);


This will work for the first run through but to do it this way I need the command to update the character's y position after every MOVE. Is there some way to make this possible? I've thought of setting a GlobalInt to the currenty variable but I don't think I can get MOVE to use that.

Jet Kobayashi Zala

Quick question: is the currenty used for later, or was it supposed to be passed in the StrFormat line?

Kinoko

Er, it was supposed to be currentx in that example ^_^ whoops. Fixed now.

Jet Kobayashi Zala

Say, Kinoko, did you ever get this problem fixed, or did you still need help with it?

Kinoko

No, I didnt... partly because I stopped working on the game to get ready for the move to Japan and Im only now starting to re-tackle some of these problems. I thought of this one last night so I decided to dredge the thread up again and see if anyone could help.

Jet Kobayashi Zala

lol I totally didn't expect an answer. Wow, I feel special. :P How is life in Japan? *furiously looks up the CCS plugin stuff to solve your problem since he's forgotten already*

Kinoko

Well, to save litering the technical forum with off-topic stuff, heres my blog if you wanna read my whinging: http://kinoko.blogspot.com

But yeah, its good.

Scorpiorus

Quote from: Kinoko on Sun 10/07/2005 16:07:06I'm using the Character Control System plugin (v1.02) and trying to write some code so that a character moves either only on the x axis or only on the y axis.

Let us know if the following code would do the trick:

repeatedly execute:
Code: ags

int CharID = .......; // char to move
int CommandID = .......; // command id to use 

if (ccIsExecuting(CharID) == 0)
{
	string randomDirection;

	// random determines move either along x or along y
	if (Random(1) == 0)
		StrFormat(randomDirection, "MOVE:%d,%d;", Random(game.room_width-1), character[CharID].y);
	else
		StrFormat(randomDirection, "MOVE:%d,%d;", character[CharID].x, Random(game.room_height-1));

	ccCreateCommand(CommandID, randomDirection);
	ccExecuteCommand(CharID, CommandID);
}

Kinoko

That DID help! Thanks!

I went home and ended up with a hybrid of your code and my original to get it working the way I want, so I finished up with this:

Code: ags

function RandomCommand(int CharID, int numb, int weight, int xa, int ya, int xb, int yb) {
Ã,  int x1 = RandomEx(xa, xb);
Ã,  int y1 = RandomEx(ya, yb);
Ã,  string randompath;
Ã,  if (Random(1) == 0) StrFormat(randompath,"MOVE:%d,%d;WAIT:%d;",x1, character[CharID].y, weight);
Ã,  else StrFormat(randompath,"MOVE:%d,%d;WAIT:%d;",character[CharID].x, y1, weight);
Ã,  ccCreateCommand(numb, randompath);
Ã,  ccExecuteCommand(CharID, numb);
}

//in repeatedly_execute
if (ccIsExecuting(BILLA) == 0) RandomCommand(BILLA, 6, 250, 550, 370, 785, 440); //for each character


It works beautifully so far with no problems, so thanks heaps!!

Scorpiorus

You're welcome I'm glad you got it working :)

Funny thing, such instantly random CCS actions force you to use if (ccIsExecuting(...) == 0) within repeatedly_execute when the CCS main goal is to free one from such routine. :P

Oh well, at least moving should work room independently.

Kinoko

My favourite thing about CCS is being able to define a path/set of actions then pause it and resume, rather than constantly restarting.

SMF spam blocked by CleanTalk