Most likely stupid questions, but...
Question #1
How do this in object based way:
character[GetCharacterAt(mouse.x, mouse.y)].StopMoving();
That works.
Then I tried something like...
character[Character.GetAtScreenXY(mouse.x, mouse.y)].StopMoving();
and
Character.GetAtScreenXY(mouse.x,mouse.y).StopMoving();
... and so on, but them don't work, and I have no idea what i'm doing.
Question #2
cGuy begins to walk towards another character, when I click that another character.Ã, cGuy starts where player character is standing.
How can I make it so that cGuy doesn'tÃ, stop when it reaches its destination (if it doesn't overlap), but continues to same direction (eAnywhere).
Also, how can I use Character.GetAtScreenXY(mouse.x, mouse.y) with AreThingsOverlapping.Ã, Again I have no idea what i'm doing.
piece of script:
function repeatedly_execute()
Ã, {
timer--;
if (timer ==0){
character[player.ID].ChangeView(1);
}
if ((AreThingsOverlapping(somethinghere, cGuy)) || (cGuy.Moving==false)) {
cGuy.StopMoving();
cGuy.ChangeRoom(-1);
}
Ã, }
function on_mouse_click(MouseButton button)
Ã, {
Ã, Ã,Â
if ((button ==eMouseLeft)&&(mouse.Mode==eModeUseinv)&&(player.ActiveInventory==ithingy)&&
(GetLocationType(mouse.x,mouse.y)==eLocationCharacter)&&
(cGuy.Room!=character[player.ID].Room)){
if (counter>=0){
Ã, character[player.ID].StopMoving();
Ã, character[GetCharacterAt(mouse.x, mouse.y)].StopMoving();
Ã, character[player.ID].FaceCharacter(Character.GetAtScreenXY(mouse.x,mouse.y),eBlock);
Ã, character[player.ID].ChangeView(17);
cGuy.ChangeRoom(character[player.ID].Room,character[player.ID].x,character[player.ID].y-40);
cGuy.Walk(mouse.x, mouse.y, eNoBlock, eAnywhere);
timer=20;
counter--;
}
else
character[player.ID].Say("No.");
}
}
QuoteCharacter.GetAtScreenXY(mouse.x,mouse.y).StopMoving();
Basically correct. But the so-called pathing isn't allowed in this case since there could be no character at this position and you can't use StopMoving on null.
Do this:
Character *thechar = Character.GetAtScreenXY(mouse.x,mouse.y);
// declare a pointer named "thechar" of type Character and fill it with the character at the mouse position
if (thechar != null) thechar.StopMoving(); // if there's a character there, stop it moving
It's basically the same in the old-style scripting:
int thechar = GetCharacterAt(mouse.x, mouse.y);
if (thechar != -1) StopMoving(thechar);
I don't know, but does "thechar.StopMoving();" work where "thechar" is a "pointer to char" type? Just asking because I know in C++ you would have to do "(*thechar).StopMoving();" or "thechar->StopMoving();"...
Yes, that does work. AGS is designed to be simpler than C++, thus there is none of the (*thechar) or -> business.
Quotecharacter[player.ID].ChangeView(1);
That will work but is the long way round -- much easier to just do this:
player.ChangeView(1);