Hey, I disabled the automatically move to hotspots "In look mode" in the general game settings but it still walks wherever i click, anyone know whats up with it?
What does your on_mouse_click function look like? That setting only relates to how ProcessClick(x, y, eModeLookat) is handled by the engine. We'd need to see your full code to be sure you're not just calling player.Walk yourself. :P
Ah, I see what your saying,
function on_mouse_click(MouseButton button){
if (button == eMouseLeft)
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));
SierraFunctions.mouse_click(button);
}
Hmm... (wtf)
Could you post the definitions of the CafeDo and SierraFunctions.mouse_click functions? I think the latter is from a module Dualnames wrote, but I can't be bothered right now to hunt it down and download it.
I also want to point out that:
if (button == eMouseLeft)
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));
SierraFunctions.mouse_click(button);
Is the same as:
if (button == eMouseLeft)
{
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));
}
SierraFunctions.mouse_click(button);
The way you have it written doesn't make that readily clear. Probably not the issue here, but I wanted to ensure that's what you meant to do (and if so, suggest you fix your formatting/indentation).
/*
General:
Sierra Style Control Method, means there's no hotspot label to indicate hotspots,
you right-click to go through modes and left-click to process a click. As for inventory
well, you open it using a pop-up bar, and you can either examine, or select an item.
*/
static function SierraFunctions::InvLook() {
mouse.Mode=eModeLookat;
}
static function SierraFunctions::InvSelect() {
mouse.Mode=eModeInteract;
mouse.UseModeGraphic(eModePointer);
}
static function SierraFunctions::InvClose(GUI*invenory) {
invenory.Visible=false;
mouse.UseDefaultGraphic();
}
static function SierraFunctions::mouse_click(MouseButton buton) {//handle//false
if (buton==eMouseLeft) {
if (mouse.Mode==eModeWalkto) {
player.Walk(mouse.x, mouse.y, eNoBlock, eWalkableAreas);
}
else {
ProcessClick(mouse.x, mouse.y, mouse.Mode);
}
}
if (buton==eMouseRight) {
mouse.SelectNextMode();
Wait(5);
}
That is the sierra control code, I doubt the CafeDo is the problem because its just speaking to the server, but let me know if this code doesn't explain the problem and i'll upload it anyway.
Thanks for the help!
It's right there in lines 22-24.
Actually no, let me take another look.
Edit: what's with the missing ts?
Construed, just to clarify: the character walks when you click a hotspot with the look cursor, right?
No, He walks anytime i click the look icon anywhere.
I commented out the server code and it seemed to work but lost the ability to switch modes with right click for some strange reason and the server code is quite necissary so I'm thinking perhaps i can add some code like
if (mouse.Mode == eModeWalkto)
{
// code here
}
To the server code:
void CafeDo(String action)
{
IRCAction(channel, action);
player.Act(action);
}
void Act(this Character *, String action)
{
if (action.Length < 1)
return;
String msg[] = action.IRCSplit();
if ((msg[0] == "walks") && (msg[1] == "to"))
{
if (this.Room == player.Room)
this.Walk(msg[2].AsInt, msg[3].AsInt, eNoBlock);
else
{
this.x = msg[2].AsInt;
this.y = msg[3].AsInt;
}
}
else if ((msg[0] == "is") && (msg[1] == "at"))
{
if (!this.Moving)
{
this.x = msg[2].AsInt;
this.y = msg[3].AsInt;
}
}
else if ((msg[0] == "looks") && (msg[1] == "like"))
{
this.ChangeView(msg[2].AsInt);
}
else if ((msg[0] == "speed") && (msg[1] == "is"))
{
this.StopMoving();
this.SetWalkSpeed(msg[2].AsInt, msg[3].AsInt);
}
else if ((msg[0] == "tele") && (msg[1] == "is"))
{
this.ChangeRoom(msg[2].AsInt, msg[3].AsInt,169);
}
}
I think i fixed it by editing the code as such:
function on_mouse_click(MouseButton button){
if ((button == eMouseLeft) && (mouse.Mode == eModeWalkto))
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y));
SierraFunctions.mouse_click(button);
}
Everything seems to be working fine now, thanks for leading me in the right direction guys!
Right, the problem was, in fact, the CafeDo method:
function on_mouse_click(MouseButton button)
{
if (button == eMouseLeft) // player clicked left mouse
{
CafeDo(String.Format("walks to %d %d", mouse.x, mouse.y)); // REGARDLESS OF MODE, call CafeDo("walks to X Y")
}
// ...
}
void CafeDo(String action) // called with action = "walks to X Y"
{
// ...
player.Act(action); // calls player.Act("walks to X Y")
}
void Act(this Character*, String action) // this = player, action = "walks to X Y"
{
String msg[] = action.IRCSplit(); // msg[0] = "walks", msg[1] = "to", msg[2] = "X", msg[3] = "Y"
if ((msg[0] == "walks") && (msg[1] == "to"))
{
if (this.Room == player.Room) // this == player
{
this.Walk(msg[2].AsInt, msg[3].AsInt, eNoBlock); // calls player.Walk(X, Y, eNoBlock)
}
// ...
}
// ...
}
If you can manage to follow the logical flow of the program, your on_mouse_click function was calling CafeDo with a "walks to" action regardless of the mouse/cursor mode. That was your problem. ;)
Well said, If only I had your commenting earlier I'd have avoided a long term bug i recently fixed where i was trying to use player. instead of this. to effect in-game code.
Well there doesn't seem to be a mismatch in this particular case. You should use player if you want to only refer to the player, and use this inside an extender method when you want to refer to the Character calling the method (e.g., cEgo for cEgo.Act and cDave for cDave.Act).
Ah, I see! Thank you for the clarity :D