Author Topic: starting conditionals in scripts, Journal entries?  (Read 432 times)

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« on: July 16, 2012, 02:20:01 am »


                Is it possible to have a journal entry in an onenter script of a trigger, and if the player is at the specific entry of the journal, the script fires, otherwise it does nothing.

I have a script that works for what I want it to do. But I also want a starting conditional that states the player(party) must have a specific journal entry.
this is the beginning of my script. I am trying to start it off with the journal entry restriction, but I don't know if this is possible this way. Does the Journal restriction only apply in conversations?



void main(){    object oTarget;    object oSpawn;
    // Get the creature who triggered this event.    object oPC = GetEnteringObject();
    if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") == 2 )        return;    // Only fire for (real) PCs.    if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )        return;
    // Only fire once.    if ( GetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF)) )        return;    SetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);
]
               
               

               


                     Modifié par harjoblog, 16 juillet 2012 - 01:33 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #1 on: July 16, 2012, 02:41:19 am »


               Hmm. A little confused. A starting conditional script is used for conversations. So do you already have a conversation set up and you just want it so that a part of the conversation shows up if you don't have a specific journal entry? Or did you just want something added to the script you posted above to let the player know that they need to be at a specific point in the journal?
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #2 on: July 16, 2012, 02:55:50 am »


               I don't have a conversation set up, I have a trigger set up with an onenter script. I want to know if it's possible for me to set the script to fire if the player or party has a journal entry that's at a specific ID.

I can't get the [] to work to show the beginning of the script right in my first post.
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #3 on: July 16, 2012, 02:56:58 am »


               but this is what I am trying to use to check the pc entering the trigger, to check for the proper journal ID

if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") == 2 )
       return;
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #4 on: July 16, 2012, 02:58:01 am »


               Change:

if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") == 2 )return;

To:

if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") != 2 )return;
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #5 on: July 16, 2012, 03:03:46 am »


               Thanks, that worked lightfoot8, but I don't understand why. I thought == meant equal to and != meant not equal to. So it has me confused that not equal to journal ID 2 would work when equal to journal ID is what I wanted.
But thanks again.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #6 on: July 16, 2012, 03:04:32 am »


               This is just an example of different things you could do

void main()
{
    object oPC = GetEnteringObject();

    //if the journal entry = 2...
    if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") == 2 )
    {
        //...do stuff here
        //you are on the right part of the quest so this stuff will happen
    }

    //or


    //if the journal entry does NOT = 2...
    if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") != 2 )
    {
        //...do stuff here
        //SendMessageToPC(oPC, "I'm sorry but you don't have the right journal entry.");
        //return;
    }

}


Hopefully this is kinda what you are looking for?
               
               

               


                     Modifié par GhostOfGod, 16 juillet 2012 - 02:11 .
                     
                  


            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #7 on: July 16, 2012, 03:08:32 am »


               yeah thats the kind of stuff, but the little change from == to != worked without have to do the other stuff. But thanks
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #8 on: July 16, 2012, 03:17:57 am »


               

harjoblog wrote...

Thanks, that worked lightfoot8, but I don't understand why. I thought == meant equal to and != meant not equal to. So it has me confused that not equal to journal ID 2 would work when equal to journal ID is what I wanted.
But thanks again.


== does mean equal and
!= does mean not equal. 

So tell me what where you asking the script to do when NW_JOURNAL_ENTRYLH_beginning was equal to 2
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #9 on: July 16, 2012, 03:34:28 am »


               Here's the scenario.

PC gets journal updated to ID 2 in a journal entry. They enter a zone and then enter a trigger at the beginning of the zone, the script in the trigger checks for that specific entry ID, the script then creates creatures at waypoints.

The next trigger is near where the NPCs are created. When the player enters that trigger, it again checks to see if the journal entry is at ID 2, if it matches, the script then runs some floating text over a few NPCs plays some animations then destroys some creatures and objects. Everything is working after I changed the == to !=, i'm just not sure why since the journal was updated to ID 2 before the player ever enters the zone or trigger.
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #10 on: July 16, 2012, 03:35:28 am »


               if I knew how to post scripts here I would post the entire script, but I don't know exactly how and when I try, the script just runs together, like my first post.
               
               

               
            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #11 on: July 16, 2012, 03:36:50 am »


               essentially what I am doing is creating a scripted scene ( i only found the gest cutscene download today) based on whether or not the pc or party has a specific journal entry.
               
               

               


                     Modifié par harjoblog, 16 juillet 2012 - 02:37 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #12 on: July 16, 2012, 03:43:38 am »


               Basically what this line is saying:

if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") != 2 )return;

If the journal entry does not = 2 then just exit out of this script right now (return;). Otherwise everything else that is under this line will continue.
               
               

               


                     Modifié par GhostOfGod, 16 juillet 2012 - 02:54 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #13 on: July 16, 2012, 03:51:16 am »


               you are asking to understand why changing the == to != worked to make you script work correctly. To help you understand that I asked the Question:

In your original script what statement where you having the script execute when the local int NW_JOURNAL_ENTRYLH_beginning was equal to 2?

I will even add the question: What does that statement that is being executed when NW_JOURNAL_ENTRYLH_beginning is equal to 2 do?


I am not asking what you where trying to do. I am asking you to look at what your script was doing. You ca do that by answering the questions.

EDIT:  Oh well, ghost already answered them for you.
Now look back at the examples that ghost posted and see you you can understand them.  
               
               

               


                     Modifié par Lightfoot8, 16 juillet 2012 - 02:54 .
                     
                  


            

Legacy_harjoblog

  • Newbie
  • *
  • Posts: 38
  • Karma: +0/-0
starting conditionals in scripts, Journal entries?
« Reply #14 on: July 16, 2012, 04:06:15 am »


               Yes ghost, that's what is confusing me.

Lightfoot8
I have it right after the objects in the original script. I'll type out of the beginning of the script and show you what I'm talking and what I don't quite understand.

onenter script of a trigger

void main()
{
   object oTarget;
   object oSpawn;
   object oActor;
   object eVFX;
   object oPC = GetEnteringObject();

  if ( GetLocalInt(oPC, "NW_JOURNAL_ENTRYLH_beginning") != 2 )
     return;
  if ( !GetIsPC(oPC)  ||  GetIsDMPossessed(oPC) )
       return;
  if ( GetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF)) )
       return;
   SetLocalInt(GetModule(), "DO_ONCE__" + GetTag(OBJECT_SELF), TRUE);
       
        eVFX = EffectVisualEffect(471);
        oTarget = GetWaypointByTag("wp_mystwiz01");
        oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "mystwiz001", GetLocation(oTarget));
        DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, eVFX, oSpawn));


/* after the above, everything else in the rest of the script are AssignCommand, DelayCommand, Destroyobject */

}