[SOLVED]Problem with eGA_GiveTo

Started by zeta_san, Mon 24/06/2024 08:54:01

Previous topic - Next topic

zeta_san

Good morning
I ask for your help to understand if it is a bug or I make mistakes.

Code: ags

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

Khris

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.

zeta_san

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?

Khris

Like this:

Code: ags
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");
            }
        }
    }
}

zeta_san

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?

zeta_san

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 ..

Khris

#6
Well, the entire thing depends on
Code: ags
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.

zeta_san

I tried them all.. I think it's a bug

eri0o

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.

zeta_san

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



Khris

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.

zeta_san

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

Code: ags
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");
      }
    }
  }
}

zeta_san

I inserted a second PNG and placed it on the left.. it works in reverse

zeta_san

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)

zeta_san

@Khris

Sorry 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

Code: ags
Player.walk (CNET.X - 20, Cnet.y, Eblock, Ewalkableareas); 

To get him closer but nothing

pell

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.

zeta_san

The problem is that everything I write after
If (Verbs.usedation (Ega_giveto)) {
The first time is ignored

example

Code: ags
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

zeta_san

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?

Khris

#18
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.

zeta_san

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

Code: ags
If (Verbs.usedation (Ega_giveto)) {

is ignored

SMF spam blocked by CleanTalk