Skip to content

oTarget Mystery

I cant get oTarget to set to destroy?

Comments

  • ZephiriusZephirius Member Posts: 411
    Zephirius wrote: »
    I cant get oTarget to set to destroy?
    void main()
    {
    
    object oPC = GetEnteringObject();
    
    if (!GetIsPC(oPC)) return;
    
    int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
    
    if (DoOnce==TRUE) return;
    
    SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
    
    object oTarget;
    oTarget = GetObjectByTag("RUMOR_01");
    
    effect eEffect;
    eEffect = GetFirstEffect(oTarget);
    while (GetIsEffectValid(eEffect))
       {
       if (GetEffectType(eEffect)==EFFECT_TYPE_SLEEP) RemoveEffect(oTarget, eEffect);
       eEffect = GetNextEffect(oTarget);
       }
    
    object oSpawn;
    location lTarget;
    oTarget = oPC;
    
    lTarget = GetLocation(oTarget);
    
    oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "rumor", lTarget);
    
    oTarget = oSpawn;
    
    AssignCommand(oTarget, ActionStartConversation(oPC, ""));
    
    //Visual effects can't be applied to waypoints, so if it is a WP
    //the VFX will be applied to the WP's location instead
    
    int nInt;
    nInt = GetObjectType(oTarget);
    
    if (nInt != OBJECT_TYPE_WAYPOINT) DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), oTarget));
    else DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), GetLocation(oTarget)));
    
    oTarget = GetObjectByTag("RUMOR_01");
    
    DestroyObject(oTarget, 0.0);
    
    }
    
  • ForSeriousForSerious Member Posts: 446
    edited January 2021
    This is kind of a shot in the dark. I turned on the floodlights, added brackets and indentations for clarity, and I removed some of the needless reassignments.
    It would help if I knew what type of object 'RUMOR_01' is in the game.
    void main()
    {
        object oPC = GetEnteringObject();
        SendMessageToPC(GetFirstPC(), "Found the entering object: " + GetName(oPC));
        if(!GetIsPC(oPC))
        {
            return;
        }
        int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
        if(DoOnce == TRUE)
        {
            return;
        }
        SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
        SendMessageToPC(GetFirstPC(), "Got past the do once stuff.");
        object oTarget;
        oTarget = GetObjectByTag("RUMOR_01");
        SendMessageToPC(GetFirstPC(), "Name of RUMOR_01: " + GetName(oTarget));
        effect eEffect;
        eEffect = GetFirstEffect(oTarget);
        while(GetIsEffectValid(eEffect))
        {
            if(GetEffectType(eEffect) == EFFECT_TYPE_SLEEP)
            {
                RemoveEffect(oTarget, eEffect);
            }
            eEffect = GetNextEffect(oTarget);
        }
        object oSpawn;
        location lTarget;
        lTarget = GetLocation(oPC);
        oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "rumor", lTarget);
        AssignCommand(oSpawn, ActionStartConversation(oPC, ""));
        //Visual effects can't be applied to waypoints, so if it is a WP
        //the VFX will be applied to the WP's location instead
        int nInt;
        nInt = GetObjectType(oTarget);
        if(nInt != OBJECT_TYPE_WAYPOINT)
        {
            DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), oTarget));
        }
        else
        {
            DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), GetLocation(oTarget)));
        }
        oTarget = GetObjectByTag("RUMOR_01");
        SendMessageToPC(GetFirstPC(), "Name of RUMOR_01 round 2: " + GetName(oTarget));
        // Not sure if this will do the stunt. You may need to make a script that has SetIsDestroyable(TRUE) in it
        // then call ExecuteScript("(whatever you name it)", oTarget);
        AssignCommand(oTarget, SetIsDestroyable(TRUE));
        DestroyObject(oTarget, 0.0);
    }
    

    Sorry I didn't try to compile this. The main thing that comes to mind is if 'RUMOR_01' is a creature, it might be set to be undestroyable.
  • ZephiriusZephirius Member Posts: 411
    ForSerious wrote: »
    This is kind of a shot in the dark. I turned on the floodlights, added brackets and indentations for clarity, and I removed some of the needless reassignments.
    It would help if I knew what type of object 'RUMOR_01' is in the game.
    void main()
    {
        object oPC = GetEnteringObject();
        SendMessageToPC(GetFirstPC(), "Found the entering object: " + GetName(oPC));
        if(!GetIsPC(oPC))
        {
            return;
        }
        int DoOnce = GetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF));
        if(DoOnce == TRUE)
        {
            return;
        }
        SetLocalInt(OBJECT_SELF, GetTag(OBJECT_SELF), TRUE);
        SendMessageToPC(GetFirstPC(), "Got past the do once stuff.");
        object oTarget;
        oTarget = GetObjectByTag("RUMOR_01");
        SendMessageToPC(GetFirstPC(), "Name of RUMOR_01: " + GetName(oTarget));
        effect eEffect;
        eEffect = GetFirstEffect(oTarget);
        while(GetIsEffectValid(eEffect))
        {
            if(GetEffectType(eEffect) == EFFECT_TYPE_SLEEP)
            {
                RemoveEffect(oTarget, eEffect);
            }
            eEffect = GetNextEffect(oTarget);
        }
        object oSpawn;
        location lTarget;
        lTarget = GetLocation(oPC);
        oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "rumor", lTarget);
        AssignCommand(oSpawn, ActionStartConversation(oPC, ""));
        //Visual effects can't be applied to waypoints, so if it is a WP
        //the VFX will be applied to the WP's location instead
        int nInt;
        nInt = GetObjectType(oTarget);
        if(nInt != OBJECT_TYPE_WAYPOINT)
        {
            DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), oTarget));
        }
        else
        {
            DelayCommand(0.5, ApplyEffectAtLocation(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_FNF_NATURES_BALANCE), GetLocation(oTarget)));
        }
        oTarget = GetObjectByTag("RUMOR_01");
        SendMessageToPC(GetFirstPC(), "Name of RUMOR_01 round 2: " + GetName(oTarget));
        // Not sure if this will do the stunt. You may need to make a script that has SetIsDestroyable(TRUE) in it
        // then call ExecuteScript("(whatever you name it)", oTarget);
        AssignCommand(oTarget, SetIsDestroyable(TRUE));
        DestroyObject(oTarget, 0.0);
    }
    

    Sorry I didn't try to compile this. The main thing that comes to mind is if 'RUMOR_01' is a creature, it might be set to be undestroyable.

    Yeah, that worked. Thanks.
    Are you up for another challenge?

    Let me preface this by saying that I struggle mightily with conceptual ideas such as local variables. It's not that I haven't tried, but I've been trying for the last five days unsuccessfully.
    I just want to know how to go about not playing the same conversation twice, especially when doing a "fetch" and "retrieve". The only thing I understand as of now is that I have to make 2 conversation files. As far as the Get and Set local variables - well, I get them confused. I guess what I'm asking is, HOW, WHEN and WHERE they should go?

    Once I understand this concept, I think it would break the dam wide open for me - so to speak.

    Any help would be awesome... :)
  • ForSeriousForSerious Member Posts: 446
    I would love to try.
    Scenario 1:
    The portion of the conversation should only ever happen once.
    In the conversation file, make two main branches from the root:
    1. "Hey there, stranger."
    2. "Hello again, hero."
    This has all the parts of the WHERE, WHEN and HOW, for looking at a local variables.
    In the 'Text appears when…' tab for option 1, make a script that checks to see if option 1 has been seen before.
    int StartingConditional()
    {
        return !GetLocalInt(OBJECT_SELF, "notMet");
    }
    
    By default, the variable 'notMet' will be FALSE. If you check any random undefined variable (of type int[eger]), it will come back as 0, witch the game recognizes as FALSE. So that is why we have the not symbol (!). Because not FALSE is TRUE. This way the default value will return TRUE, and conversation option 1 will be displayed to the player.
    Next, make sure that option 2 does not show at first.
    Put:
    int StartingConditional()
    {
        return GetLocalInt(OBJECT_SELF, "notMet");
    }
    
    in the 'Text appears when…' tab for option
    3. This script is the same but without the not symbol (!). So by default, this script will return FALSE, and the option will not be displayed to the player.

    Next we need to mark that option 1 has happened.
    In the 'Actions Taken' tab of option 1, make a script that includes this:
    void main()
    {
        SetLocalInt(OBJECT_SELF, "notMet", TRUE);
    }
    
    When this script is ran, it will find OBJECT_SELF, witch is the object the player is talking to, and assign the value 1 to the integer variable named 'notMet'. After the first time any player talks to the object, only option 2 will ever show.


    Scenario 2:
    The portion of the conversation should happen once per player.
    This scenario is the same, but the name of the variable needs to be unique.
    So this time, the script in option 1 under tab 'Text appears when…', will need to be more involved:
    int StartingConditional()
    {
        object oPC = GetPCSpeaker();
        return !GetLocalInt(OBJECT_SELF, GetName(oPC));
    }
    
    And the script in the 'Actions Taken' tab will look like:
    void main()
    {
        object oPC = GetPCSpeaker();
        SetLocalInt(OBJECT_SELF, GetName(oPC), TRUE);
    }
    
    This approach has flaws, but the concept works (Provided no one names their character the exact same thing).
    In this scenario, let's say my character's name is John, and the NPC he is talking to is Mike. The object Mike, has no local variable 'John'. By default it will return FALSE, but that first script is returning the opposite of whatever it finds for the variable named 'John'.
    After the conversation happens, the object Mike gains a local variable named John with a value of 1. Now when any player named John talks to Mike, the conversation option 1 will not show.

    If you still can't follow the logic in these, I can explain it a level down. There's just a lot more steps. The logic is easier though.
  • ZephiriusZephirius Member Posts: 411
    Wow! Thank you ForSerious. I've got a lot to chew on. Check back in a couple of days and I'll let you know how my module fares.
  • ZephiriusZephirius Member Posts: 411
    YEAH! It works!
    Now "Rumor" can finally get the medicine he needs. Rumor is a male leopard "henchcat" that you heal and befriend.
    I can't thank you enough. You truly are an awesome teacher. Gotta go. Building a few Chult maps - that's were you pick Rumor up at... :)
  • ForSeriousForSerious Member Posts: 446
    Anytime. Let me know if you need any more help.
Sign In or Register to comment.