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:
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.
Quick question: is the currenty used for later, or was it supposed to be passed in the StrFormat line?
Er, it was supposed to be currentx in that example ^_^ whoops. Fixed now.
Say, Kinoko, did you ever get this problem fixed, or did you still need help with it?
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.
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*
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.
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:
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);
}
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:
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!!
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.
My favourite thing about CCS is being able to define a path/set of actions then pause it and resume, rather than constantly restarting.