Hello everybody! Just wondering if anyone out here can help me out with this line of code I am having trouble with. Basically what I want it to do is have a AreCharactersColliding command set so when my NPC crashes into my player character he will say something random each time
here is what I have got
function room_b() {
// script for room: Player enters screen (after fadein)
SetGlobalInt(6,0);
RemoveWalkableArea(3);
DisableHotspot(17);
DisableHotspot(16);
ccCreateCommand(1, "WAIT:50;VIEW:69;MOVE:190,194;VIEW:67;WAIT:80;VIEW:69;MOVE:121,181;
VIEW:67;WAIT:80;VIEW:69;MOVE:447,181;VIEW:67;WAIT:80;VIEW:69;MOVE:190,194;VIEW:67;GOTO:1;");
ccExecuteCommand(HOME, 1);
if (AreCharactersColliding(EGO,HOME)==1){
random = Random(5);
if (random==0) DisplaySpeech(HOME, "ARRRRRRRRRRR! Youd best be getting out of way! You little scrub!");
else if (random==1) DisplaySpeech (HOME, "Why I outta mop the floor with ya!");
else if (random==2) DisplaySpeech (HOME, "Move out of the way lad!");
else if (random==3) DisplaySpeech (HOME, "You'd best consider moving boy! Otherwise me and you are going to have trouble");
else if (random==4) DisplaySpeech (HOME, "MOVE! lad!");
else if (random==5) DisplaySpeech (HOME, "I am warning you! GET OUT OF MY WAY!");
}
}
Please let me know if anyone can let me know what I am forgetting to do because for some reason it runs but nothing happens when the characters collide! Thanks
Daniel
Winebarger
[edit: fix line wrap]
i think it should read more like this
if (AreCharactersColliding(EGO,HOME)==1){
int ran=Random(5);
if (ran==0) DisplaySpeech(HOME, "ARRRRRRRRRRR! Youd best be getting out of way! You little scrub!");
else if (ran==1) DisplaySpeech (HOME, "Why I outta mop the floor with ya!");
else if (ran==2) DisplaySpeech (HOME, "Move out of the way lad!");
else if (ran==3) DisplaySpeech (HOME, "You'd best consider moving boy!");
else if (ran==4) DisplaySpeech (HOME, "MOVE! lad!");
else DisplaySpeech (HOME, "I am warning you! GET OUT OF MY WAY!");
}
not tested it tho
Maybe you should put all code which you have after
ccExecuteCommand(HOME, 1);
into the repeatedly_execute.
Yeah that was itotally it! thanks alot it now it works that little problem is solved! Now I am having a new problem now which is I need to pause the ccControl command so HOME will pause stop running the character control command that I have set and say his speech that I want. THen when the EGO moves out of the way he goes back to what he was doing originally! I think I need to change to his talking view instead or something because he is still moves gliding across the screen still running the command I had set for him. If any one out there knows how to place some kind of if statement in there I really would appreciate the help thanks again!
Try that one....
repeatedly:
if (AreCharactersColliding(EGO,HOME)==1) {
StopMoving(EGO);
ccPauseExecution(HOME);
int random = Random(5);
if (random==0) DisplaySpeech (HOME, "ARRRRRRRRRRR! Youd best be getting out of way! You little scrub!");
else if (random==1) DisplaySpeech (HOME, "Why I outta mop the floor with ya!");
else if (random==2) DisplaySpeech (HOME, "Move out of the way lad!");
else if (random==3) DisplaySpeech (HOME, "You'd best consider moving boy! Otherwise me and you are going to have trouble");
else if (random==4) DisplaySpeech (HOME, "MOVE! lad!");
else if (random==5) DisplaySpeech (HOME, "I am warning you! GET OUT OF MY WAY!");
RefreshMouse();
if (IsButtonDown(LEFT)) MoveCharacterBlocking(EGO, GetViewportX()+mouse.x, GetViewportY()+mouse.y, 0);
ccResumeExecution(HOME);
}
This way you also be able to move the character away with a left click.
How does it go?
~Cheers
Hey Scorpiorus It's Dan. Hey thanks alot I tried that and It worked! It's cool because I can reuse that same block of code in all over game where I have problems with the player character colliding with my NPC's. Thanks again I really appreciate it
Daniel
Winebarger