Forum rules - please read before posting.

Show pending interaction whilst action/interaction is running during cutscene?

2

Comments

  • Thanks for the hooks! How should I tap in to when the player is looking at an inventory item and the dialog pauses gameplay? https://gfycat.com/SelfishEagerAsianelephant

    I assume it's not presently working because I'm rebuilding the sentence and freezing it with 'MyUse(Hotspot hotspot, AC.Button button)' ?

  • You can hook into the OnBeginActionList and OnEndActionList events and check if the ActionList is an Interaction.

  • Okay, so I can't use button in OnBeginActionList because it's not recognized? Since I'd probably need to use
    int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language);
    to rebuild the sentence to hold it in place for the duration of the "cutscene" dialog when the inventory item is looked at.

  • OnBeginActionList has nothing to do with buttons - its a generic event called whenever an ActionList is triggered, regardless of how or when. To access the Button involved, you can use OnHotspotInteract.

  • Thanks, that's how it's building the label already, but I assumed that since OnBeginActionList is a separate hook, OnHotspotInteract wouldn't be triggered unless a hotspot is chosen (in this case, I'm merely interacting with an inventory item). So in order to rebuild the sentence if an inventory item is interacted with so I can hold that sentence in place during the "cutscene", does the sentence need to be rebuilt using a different method that would work in OnBeginActionList?

  • I thought the line of thinking was that you'd continue to build it how you were already doing so, but use the new ActionList event hooks to choose when to show and hide it. You can use them to record the currently-running Interaction, and if they match, remove the dummy label.

  • edited February 2019

    Yeah, I'm creating the sentence here:
    private void MyUse(Hotspot hotspot, AC.Button button) { textOnEvent = true; if (button != null) { int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language); } }
    But I need to do this when an inventory item is interacted with, which doesn't trigger the OnHotspotInteract hook obviously, but I can't just hold the current text into dummy during an inventory interaction, as it will have cleared by the time the inventory interaction is triggered. Is there a hook for inventory interactions, or is everything going through OnBeginActionList?

    Using this:
    private void OnBeginActionList(ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping) { if (actionList is Interaction) { amInteraction = true; myInteraction = actionList as Interaction; print("test"); }

    doesn't actually debug for an inventory actionlist?

  • Is there a hook for inventory interactions

    You can use OnInventoryInteract for inventory interactions - see the Manual's "Inventory scripting" chapter.

    doesn't actually debug for an inventory actionlist?

    It won't - the Interaction class type is for Hotspot interactions only. Hooking into OnEnterGameState / OnExitGameState would also allow you to track when to hide/show the label.

  • edited February 2019

    Sure, but I need to build the label again, for instance if I right-click on an item, it will never build the sentence "Look at item" it just builds a "Use item" sentence when hovering, and upon right-clicking, it will just say "Use". So, in effect I need to do the same as I did with the hotspots and actually manually construct a sentence from the cursor interaction that is being run during the Inventory interaction.

    private void InventoryInteract(InvItem theItem, int cursorID) { }

    And I'd need to do something like:
    int language = Options.GetLanguage();
    newLabel = KickStarter.cursorManager.GetLabelFromID
    (button.iconID, language) + " " + item.GetName(language);
    For full disclosure, here's the script I'm using so far:

    http://pasteall.org/1477956

  • edited February 2019

    So far, I've gotten something that works okay, I just need to be able to build the sentence correctly inside OnInventoryInteraction by grabbing the cursor used: http://pasteall.org/1478639

    So far I've just substituted KickStarter.cursorManager.GetLabelFromID(button.iconID, language) with a basic "Look at", and using invItem.GetLabel(language) is great for the actual item being examined.

    Is there a way of grabbing the current cursor used for the inventory interaction to build the sentence with? That way, for items that have a "cutscene" interaction for combines or other cursors will be able to hold the sentence during the "cutscene" actionlist.

    and yes, I will be refactoring everything using the new hooks when I've gotten this working! :D

  • Is there a way of grabbing the current cursor used for the inventory interaction to build the sentence with?

    The OnInventoryInteract event's iconID parameter is just that:

    newLabel = KickStarter.cursorManager.GetLabelFromID (iconID, language) + " " + invItem.GetLabel(language);
    
  • Bringing this back from the dead again, but I've noticed it isn't working when I used inventory items with hotspots, in the case of using the "newspaper" with the "door" hotspot, it just holds the sentence as 'door', as if it isn't getting the rest of the sentence properly. Will this script grab the inventory interactions with hotspots, or does it need a different method for that?

    `using UnityEngine;
    using System.Collections;
    using UnityEngine.UI;
    using AC;

    public class Verb1txtVerb2 : MonoBehaviour
    {

    public Text textBox1;
    public Text textBox2;
    public GameObject bg;
    private bool textOnce;
    private bool textOnEvent;
    private string newLabel;
    private bool amInteraction;
    private bool amCutscene = true;
    Interaction myInteraction;
    private bool invInteraction;
    
    private Animator _animator;
    public float heightofclick;
    
    private void Start()
    {
        _animator = GetComponent<Animator>();
    }
    
    private void OnEnable()
    {
        EventManager.OnHotspotInteract += MyUse;
        EventManager.OnExitGameState += ExitGameState;
        EventManager.OnEnterGameState += EnterGameState;
        EventManager.OnBeginActionList += OnBeginActionList;
        EventManager.OnEndActionList += OnEndActionList;
        EventManager.OnInventoryInteract += OnInventoryInteract;
    }
    
    private void OnDisable()
    {
        EventManager.OnHotspotInteract -= MyUse;
        EventManager.OnExitGameState -= ExitGameState;
        EventManager.OnEnterGameState -= EnterGameState;
        EventManager.OnBeginActionList -= OnBeginActionList;
        EventManager.OnEndActionList -= OnEndActionList;
        EventManager.OnInventoryInteract -= OnInventoryInteract;
    
    }
    
    private void OnInventoryInteract(InvItem invItem, int iconID)
    {
        invInteraction = true;
        print("is inventory");
        int language = Options.GetLanguage();
        newLabel = KickStarter.cursorManager.GetLabelFromID(iconID, language) + " " + invItem.GetLabel(language);
    }
    
    private void OnEndActionList(ActionList actionList, ActionListAsset actionListAsset, bool isSkipping)
    {
        if (invInteraction == true)
        {
            invInteraction = false;
            print("inventory actionlist cancel");
    
        }
    }
    
    private void EnterGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            amCutscene = true;
        }
    }
    private void ExitGameState(GameState gamestate)
    {
        if (gamestate == GameState.Cutscene)
        {
            textOnEvent = false;
            amInteraction = false;
            amCutscene = false;
        }
    }
    private void OnBeginActionList(ActionList actionList, ActionListAsset actionListAsset, int startingIndex, bool isSkipping)
    {
        if (actionList is Interaction)
        {
            amInteraction = true;
            myInteraction = actionList as Interaction;
        }
    
    }
    private void MyUse(Hotspot hotspot, AC.Button button)
    {
        textOnEvent = true;
        if (button != null)
        {
            int language = Options.GetLanguage();
            newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language);
        }
    }
    
    private void Update()
    {
        bool doHold = false;
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            )
        {
            if (textOnce == false)
            {
                textBox2.text = textBox1.text;
                textBox2.enabled = true;
                bg.SetActive(true);
                textOnce = true;
            }
    
        }
        else
        {
            textBox2.text = textBox1.text;
            textBox2.enabled = false;
            bg.SetActive(false);
            textOnce = false;
        }
        if (textOnEvent == true || invInteraction == true)
        {
            textBox1.text = newLabel;
        }
        if (KickStarter.playerInteraction.GetHotspotMovingTo() == null
            && amInteraction == false
            )
        {
            textOnEvent = false;
        }
    
        if (myInteraction != null)
        {
            if (!myInteraction.AreActionsRunning())
            {
                //textOnEvent = false;
                amInteraction = false;
                // Interaction is set, but no Actions are running
            }
        }
    
        //Highlight Script
    
        if (KickStarter.playerInteraction.GetHotspotMovingTo() != null
            || amInteraction == true
            //||  textOnEvent == true
                )
        {
            doHold = true;
        }
        _animator.SetBool("Hold", doHold);
    
        if (Input.GetMouseButtonDown(0) &&
            KickStarter.playerInteraction.GetActiveHotspot() == null &&
            Camera.main.ScreenToViewportPoint(Input.mousePosition).y >= heightofclick
            && amInteraction == false
            && amCutscene == false
            )
        {
            _animator.SetTrigger("Flash");
        }
    
    }
    

    }`

  • OnHotspotInteract will be called for inventory and non-inventory interactions alike. You can use the Hotspot's IsInventoryButton method to determine if the interaction is for inventory inside your MyUse event:

    if (hotspot.IsInventoryButton (button))
    {
        // 
    }
    
  • I tried this, but it's still saying just "door" since I guess it needs something else to use for the inventory label:
    private void MyUse(Hotspot hotspot, AC.Button button) { textOnEvent = true; if (button != null || (hotspot.IsInventoryButton(button))) { int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language); } }

  • You can call the PlayerInteraction script's GetLabelPrefx to get the text before "door" for a given Hotspot / item combination:

    string prefix = KickStarter.playerInteraction.GetLabelPrefix (hotspot, KickStarter.runtimeInventory.SelectedItem);
    
  • Thanks, this works for inventory interactions:
    private void MyUse(Hotspot hotspot, AC.Button button) { textOnEvent = true; if (button != null) { int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language); } if (hotspot.IsInventoryButton(button)) { int language = Options.GetLanguage(); newLabel = KickStarter.playerInteraction.GetLabelPrefix(hotspot, KickStarter.runtimeInventory.SelectedItem, language) + " " + hotspot.GetName(language); } }

    However, I'm not getting sentences held if it's an unhandled interaction (anything that hasn't been explicitly defined), is this because button is null if an interaction is unhandled or because it's not an actionlist so it isn't enabling MyUse?

  • If the interaction is unhandled, OnHotspotInteract will still be called - but the button parameter will be null.

  • For an unhandled interaction, I'd need to a) test if it's unhandled and b) create the sentence based on the the unhandled sentence, or do I just need to substitute button for something else?

  • You're calling CursorManager's GetLabelFromID function to form the sentence, which takes a cursor ID value.

    If button is null, you can instead get the selected cursor ID value with:

    KickStarter.playerCursor.GetSelectedCursorID ()
    
  • I'm not sure if I'm calling this correctly, but I can't get the text to change if the interaction is unhandled:
    private void MyUse(Hotspot hotspot, AC.Button button) { textOnEvent = true; if (button != null) { int language = Options.GetLanguage(); newLabel = KickStarter.cursorManager.GetLabelFromID(button.iconID, language) + " " + hotspot.GetName(language); } else if (button == null) { int language = Options.GetLanguage(); newLabel = KickStarter.playerCursor.GetSelectedCursorID() + " " + hotspot.GetName(language); } if (hotspot.IsInventoryButton(button)) { int language = Options.GetLanguage(); newLabel = KickStarter.playerInteraction.GetLabelPrefix(hotspot, KickStarter.runtimeInventory.SelectedItem, language) + " " + hotspot.GetName(language); } }

    It could be because this isn't being called at all, since:
    if (KickStarter.playerInteraction.GetHotspotMovingTo() != null is null? I basically want the unhandled interactions to hold the sentence exactly the same way as handled and inventory interactions do.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.
Do NOT follow this link or you will be banned from the site!