Hello all!
In my game, I have an NPC (just a normal character) that I want my playable character to talk to. But whenever I choose "Talk to" and click on the NPC, my character will first walk to the NPC and literally stand on him before moving away to the side. I have the following code implemented:
function cNPC_AnyClick()
{
cPlayableCharacter.Walk(116, 262, eBlock, eWalkableAreas);
Game.TextReadingSpeed = 9;
// TALK TO
if (UsedAction(eGA_TalkTo)) {
cPlayableCharacter.Walk(116, 262, eBlock, eWalkableAreas);
cPlayableCharacter.FaceDirection(eDir_Left);
dNPC.Start();
}
else Unhandled();
}
With this code, my intent was to have the playable character move to a fixed position AND THEN talk to the NPC. But my character will instead move to the NPC first (almost standing right on top of him) AND THEN move to the co-ordinates and talk to the NPC. What should I do? I'm using the 9-Verb template. Thanks! :)
Should be enough to do what you want to do with your script:
function cNPC_AnyClick()
{
// TALK TO
if (UsedAction(eGA_TalkTo)) {
dNPC.Run();
}
I think the template you're using are set up so that if you use talk to the character will automatically move to the npc before running the dialoge script. What happens might be that the guiscript are first walking the character to the position close to the character you're talking to, and then running your scrip to move the character to a fixed position. You might have to look through the guiscript and adjusting the values connected to the talk to action there.
Quote from: Mathias on Fri 01/05/2015 14:04:30
Should be enough to do what you want to do with your script:
function cNPC_AnyClick()
{
// TALK TO
if (UsedAction(eGA_TalkTo)) {
dNPC.Run();
}
I think the template you're using are set up so that if you use talk to the character will automatically move to the npc before running the dialoge script. What happens might be that the guiscript are first walking the character to the position close to the character you're talking to, and then running your scrip to move the character to a fixed position. You might have to look through the guiscript and adjusting the values connected to the talk to action there.
Sorry, didn't work. My character will then only walk straight on top of the NPC :/
I looked around in the GUI script and found:
else if (GSagsusedmode==eModeTalkto && IsInteractionAvailable(x, y, GSagsusedmode) && GSloctype==eLocationCharacter) {
ActionLine.TextColor=ActionLabelColorHighlighted;
if (GoToCharacter(character[GSlocid], eDir_None, NPC_facing_player, 1)) character[GSlocid].RunInteraction(GSagsusedmode);
SetAction(eMA_Default);
Could the "GoToCharacter" value have anything to do with it? I'm not sure myself since I don't usually touch the script files much...
Sorry for the late reply.
This might be a lame suggestion, but if you don't want to tinker with the guiscript and remove the GoToCharacter sections of the Talk to action to make your own scripting of the movement easier, you could possibly cheat this by making a transparent area around your charactersprite, that way when you move your character the engine will think that the character has reached it's position when it collides with the transparent parts of your sprite.
It's weird because GoToCharacter uses offsets (x: 35 / y: 20) to approach the NPC. And this works fine in the demo, where talking to the character will make Roger approach them just fine, even though AnyClick/TALK_TO only starts the dialog.
On the other hand, this happens regardless of what the character's approach property is set to, so may there is a bug hidden in there somewhere.
Is the offset based off from the center of your character or from the edge of the sprite though?
If it's based from the center, and you change sprite to a different size then that might be the cause of problem. I'm just speculating so I might be far off in my thought.
Hello, I'm experiencing the same problem and this was the only post that I've found about it.
My problem is that I have this character behind a desk, and I don't want the player to go behind the desk and then going back to the front of it to talk to him. Is there a way of solving this or I'll have to just remove the walkable area so that he won't be able to go there?
Thanks for your time :)
If the character behind the desk is going to move and supposed to stick to walkable areas, you can use a different walkable area for the area behind the desk and turn it on/off as needed.
If you don't really need the area anyway, just remove it, this is the simplest solution.
I suspect the approach code from the template calculates coordinates that are outside the WA so the player, while trying to reach them, ends up on top of the NPC.
You can also fix this a different way:
Go to Scripts -> TemplateSettings -> Edit Script and find line 66. Set the eVerbGuiApproachCharInteract option to false.
Now wrap your code in the usual
if (Verbs.MovePlayer(123, 45)) { // coordinates in front of desk
player.FaceDirection(eDirectionUp, eBlock);
// look at, etc
}
QuoteQuote from: Khris on Wed 21/08/2024 10:02:02You can also fix this a different way:
Go to Scripts -> TemplateSettings -> Edit Script and find line 66. Set the eVerbGuiApproachCharInteract option to false.
Now wrap your code in the usual
if (Verbs.MovePlayer(123, 45)) { // coordinates in front of desk
player.FaceDirection(eDirectionUp, eBlock);
// look at, etc
}
You, sir, are a genius! That was it. The annoying extra walk is fixed!
One million thanks!! :-D