Good morning
I ask for your help to understand if it is a bug or I make mistakes.
function cLupo_AnyClick() {
if (Verbs.MovePlayer(340, 140)) {
player.FaceDirection(eDirectionRight);
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// GIVE TO (characters only)
else if (Verbs.UsedAction(eGA_GiveTo)) {
if (player.ActiveInventory == iObject) {
player.LoseInventory(iObject);
player.Say("do you want this?");
cLupo.Say("WOW! YES. I want it");
} else if (player.ActiveInventory != iObject) {
player.Say("do you want this?");
cLupo.Say("No");
}
}
}
}
When I give an object to an NPC for the first time nothing happens, psi approaches and nothing happens. If I repeat the action everything is normal
Try adding Display() commands to see exactly what is happening.
You can also try removing the eGA_WalkTo branch since your moving the player to the character manually anyway.
Quote from: Khris on Mon 24/06/2024 15:31:11Try adding Display() commands to see exactly what is happening.
You can also try removing the eGA_WalkTo branch since your moving the player to the character manually anyway.
The anomaly persists. Display() exactly how I set it?
Like this:
function cLupo_AnyClick() {
if (Verbs.MovePlayer(340, 140)) {
Display("Move player finished");
player.FaceDirection(eDirectionRight);
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Display("action is walk");
Verbs.GoTo();
}
// GIVE TO (characters only)
else if (Verbs.UsedAction(eGA_GiveTo)) {
Display("action is give");
if (player.ActiveInventory == iObject) {
player.LoseInventory(iObject);
player.Say("do you want this?");
cLupo.Say("WOW! YES. I want it");
} else if (player.ActiveInventory != iObject) {
player.Say("do you want this?");
cLupo.Say("No");
}
}
}
}
Nothing... it doesn't work, I've made multiple attempts but I can't resolve anything. Do you know if anyone has the same problem as me?
I noticed that if the action happens from left to right nothing happens, if it happens from right to left everything happens fine.
I thought it was the alpha channel of the sprite or the character animation. I can not understand ..
Well, the entire thing depends on
if (Verbs.MovePlayer(340, 140)) {
so if that fails, (edited for clarity:) the player walks towards these coordinates but then can't reach them and they stop and nothing happens.
The question is, why does it fail from one side and not the other? And does the function itself have a bug?
Make sure that 340, 140 is part of the walkable area and also not blocked by the NPC's solidity rectangle.
I tried them all.. I think it's a bug
Show a printscreen of the walkable area with the characters in the room editor and mark where is the 340x140 coordinate and from where the movement is failing.
1) From left to right: It doesn't work
2) From right to left: it works
3) From left to right: Not working again
4) From left to right in that position: it works
Look at 0:07 and compare that to 0:23.
It's very visibly a different position.
I assume 340, 140 is where the player is at 0:23, so the question is why they don't reach that coordinate the first time around.
Quote from: Khris on Wed 26/06/2024 20:12:43Look at 0:07 and compare that to 0:23.
It's very visibly a different position.
I assume 340, 140 is where the player is at 0:23, so the question is why they don't reach that coordinate the first time around.
I can't understand why
I tried to write everything down again
function cLupo_AnyClick() {
if (Verbs.MovePlayer(340, 140)) {
player.FaceDirection(eDirectionRight);
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// GIVE TO (characters only)
else if (Verbs.UsedAction(eGA_GiveTo)) {
player.FaceDirection(eDirectionRight);
if (player.ActiveInventory == iCalcio) {
player.LoseInventory(iCalcio);
player.Say("Vuoi questo poster?");
cLupo.LockView(175);
cLupo.Animate(0, 2, eOnce, eBlock, eForwards);
cLupo.UnlockView();
cLupo.LockView(103);
cLupo.Animate(1, 5, eOnce, eBlock, eForwards);
cLupo.Say("WOW! Il poster di Bruno Conti");
cLupo.Say("Ti do la moneta");
player.AddInventory(iCoin);
moneta = true;
cLupo.UnlockView();
} else if (player.ActiveInventory != iCalcio) {
player.Say("Vuoi questo?");
cLupo.Say("No. Non lo voglio");
}
}
}
}
I inserted a second PNG and placed it on the left.. it works in reverse
Update:
Hi everyone
I am finding this anomaly in every room.
When I give an object to a player, the first time nothing happens, I have to repeat the operation.
Do you happen to you?
(Turseweed Action Functions)
@KhrisSorry but I tried all the possible solutions but I have a problem with Giveto.
The first time I launch the command, the player approaches the PNG but nothing happens, everything he is later
If (Verbs.usedation (Ega_giveto)) {
it is ignored
When I repeat the command, it works
I don't understand what blocks it, is there a link for assistance?
I also tried with
Player.walk (CNET.X - 20, Cnet.y, Eblock, Ewalkableareas);
To get him closer but nothing
My understanding is that the transparent parts of images still count in the collision detection. I had an issue with that in a game a few years ago. In the video it looks like the character might be getting blocked by part of the fishing hole image.
If you have extra space around the image, you may try trimming it down to only surround the visible parts. If the girl and the fishing hole are all part of one image, you might break them into separate images so that the rectangle surrounding the different parts can fit more closely.
You could also try having the character first walk to a spot from where you know he can always reach the correct spot to trigger the dialog.
The problem is that everything I write after
If (Verbs.usedation (Ega_giveto)) {
The first time is ignored
example
If (Verbs.usedation (Ega_giveto)) {
Player.say ("Hello");
It does nothing, it goes directly close to the PNG
only when I repeat the action everything works
All actions work at the first call but Giveto only works at the second.
I'm going crazy I tried them all.
What can be the reason .. AGS?
Once again, you need to put Display commands in your code to try and debug this.
Does the function trigger at all? Where exactly does AGS exit the function?
Edit:
I just checked my AGS 3.6 Tumbleweed example game and the "give to" action works without issue, same as the other verbs.
To debug this, we need to determine which of the two if conditions fails. I suspect it's the move part again, but if the other verbs do work, then it must be something else.
If you upload your source code and send me a link I will take a look.
Quote from: Khris on Mon 07/10/2024 09:16:18Once again, you need to put Display commands in your code to try and debug this.
Does the function trigger at all?
Sorry if I insist with this thing ..
I also tried this but as I said, after the first call "give" does not perform any action, it approaches the PNG and nothing happens.
Any code I write after
If (Verbs.usedation (Ega_giveto)) {
is ignored
function room_AfterFadeIn() {
Display ("Start of the test");
if (Verbs.UsedAction(eGA_GiveTo)) {
Display ("Give_to recognized action!");
// Here the code to be performed
} else {
Display ("Give_to unrecognized action!");
}
Display ("Completed test");
}
Give_to unrecognized action!
This will never trigger. That function runs once after the room has faded in, but at that point Verbs.UsedAction(eGA_GiveTo) will never be true.
You need to actually click the give button, an inventory item and a character to properly test this (or simulate the action some other way, provided the template supports that).
(Also, this is why it is so important to always post your actual code. Testing it this way won't work, so getting stuck on this not working is a complete waste of time.)
function cNet_AnyClick(Character *theCharacter, CursorMode mode)
{
// WALK TO
if (Verbs.UsedAction(eGA_WalkTo)) {
Verbs.GoTo();
}
// Check if the action used is GIVE TO
else if (Verbs.UsedAction(eGA_GiveTo)) {
// Move the player towards cNet's position and wait for the movement to finish
player.Walk(cNet.x - 20, cNet.y, eBlock, eWalkableAreas); // Walk close to cNet, 20 pixels away
player.FaceCharacter(cNet); // The player looks at cNet
player.Say("Hey, do you want this?");
// If I give him the soap
if (Verbs.GetItemGiven() == iSoap) {
player.LoseInventory(iSoap);
player.Say("Will this do?");
// cNet's dialogue
cNet.Say("For all surfaces, for stubborn dirt");
cNet.Say("Muriatic acid");
cNet.Say("Pure bleach");
cNet.Say("Depleted uranium");
cNet.Say("Emotoxin rattlesnake venom");
cNet.Say("Strychnine");
cNet.Say("Formaldehyde");
cNet.Say("Palm oil");
cNet.Say("WOW!");
cNet.Say("PERFECT!");
// Mark that you have given the soap
hodatosapone = true;
}
// If I have already given him the soap
else if (hodatosapone == true) {
player.Say("I've already given him the soap.");
}
// If I give him something else
if (Verbs.GetItemGiven() != iSoap) {
player.Say("I don't think he's interested.");
}
} else {
Verbs.Unhandled();
}
}
Try this:
function cNet_AnyClick(Character *theCharacter, CursorMode mode) {
// approach character non-blocking
if (Verbs.MovePlayer(cNet.x - 20, cNet.y)) {
player.FaceCharacter(cNet, eBlock);
// Check if the action used is GIVE TO
if (Verbs.UsedAction(eGA_GiveTo)) {
player.Say("Hey, do you want this?");
// If I give him the soap
if (Verbs.GetItemGiven() == iSoap) {
// if NPC didn't receive soap yet
if (!hodatosapone) {
player.LoseInventory(iSoap);
player.Say("Will this do?");
// cNet's dialogue
cNet.Say("For all surfaces, for stubborn dirt");
cNet.Say("Muriatic acid");
cNet.Say("Pure bleach");
cNet.Say("Depleted uranium");
cNet.Say("Emotoxin rattlesnake venom");
cNet.Say("Strychnine");
cNet.Say("Formaldehyde");
cNet.Say("Palm oil");
cNet.Say("WOW!");
cNet.Say("PERFECT!");
// Mark that you have given the soap
hodatosapone = true;
}
// If I have already given him the soap
else {
player.Say("I've already given him the soap.");
}
}
// If I give him something else
else {
player.Say("I don't think he's interested.");
}
} else {
Verbs.Unhandled();
}
}
}
It's a design choice whether the player character always approaches first or not, but this is the way all the LucasArts 9-Verb games did if, IIRC.
Anyway, you said only "give" didn't work, but this code has a blocking walk inside the handling of "give" (which is not really how the template is supposed to work) and I have no idea if that code is the one that caused the original trouble.
I fixed it in the way that I think works best with the template, and I also fixed the soap logic (you didn't check the hodatosapone variable first, so if the player can pick up more soap, they can keep giving it to cNet).
1. is this your code or my code?
2. he makes an additional step when you click a second time, meaning that the character doesn't reach the target the first time around, which is most likely the reason the code doesn't trigger
Assuming this is my code, what happened when you ran your code with the blocking walk?
Also, feel free to PM me a link to the game so I can take a look. I have a sneaking suspicion that I can easily fix this if I have the source code.
Found it, and I remember having found this before.
Open TemplateSettings.asc and find line 66:
// walk to character before starting interaction
Verbs.VerbGuiOptions[eVerbGuiApproachCharInteract] = false;
This option needs to be set to false, otherwise the template takes over the Give click and does not run the interaction function if the character fails to reach an automatically calculated target.
Edit: found the other topic; the error was just as frustrating; maybe the template should default to this being turned off
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/character-walks-into-npc-when-talking/msg636513014/#msg636513014
Quote from: Khris on Wed 09/10/2024 18:06:21Edit: found the other topic; the error was just as frustrating; maybe the template should default to this being turned off
Note you may add your suggestion in the template's issue tracker here:
https://github.com/dkrey/ags_tumbleweed/issues
@Khris Thank you, you solved a huge problem for me... now I can move forward. Thank you!