Aller au contenu

Photo

Help with script


51 réponses à ce sujet

#1
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
I'm trying to write a script that will add a NPC to the party after a certain conversation option has been met.
And I'm habinga bit of a difficulty.

I have a plot (aquae_plot) that has a flag (AQUAE_JOIN) that is set to 1after a certain conversation choice is picked.
I'm trying to write a script that will add that NPC (tag  "aquae") to the party.

Since I plan to palce it in the Mage Tower, I'm not certain a area script is a good idea (methinks the mage tower has its' own area script active). So I'm sure how to proceed. Should I make it a conversation script?




#include "log_h"
#include "utility_h"
#include "wrappers_h"
#include "plot_h"
#include "plt_aquae_plot"

void main()
{
    event eParms = GetCurrentEvent();                // Contains all input parameters
    int nType = GetEventType(eParms);               // GET or SET call
    string strPlot = GetEventString(eParms, 0);         // Plot GUID
    int nFlag = GetEventInteger(eParms, 1);          // The bit flag # being affected
    object oPC = GetHero();

    plot_GlobalPlotHandler(eParms);

    if(nType == EVENT_TYPE_SET_PLOT) // actions -> normal flags only
    {
      if(strPlot = AQUAE_JOIN)
        {
            int p = GetPlotActionStatus;
            if(p == TRUE)
          {
            object oAquae = UT_GetNearestCreatureByTag(oPC,aquae);
            UT_HireFollower(oAquae);
          }
          else{};
        }
    }
}



I'm cofused ATM as to how exactly check the current status of a plot flag!

#2
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Hm..wait...will this work?

int StartingConditional()
{
event eParms = GetCurrentEvent(); // Contains all input parameters
int nType = GetEventType(eParms); // GET or SET call
string strPlot = GetEventString(eParms, 0); // Plot GUID
int nFlag = GetEventInteger(eParms, 1); // The bit flag # being affected
int nResult = FALSE; // used to return value for DEFINED GET events
object oPC = GetHero();

plot_GlobalPlotHandler(eParms); // any global plot operations

if(nType == EVENT_TYPE_GET_PLOT) // actions -> normal flags only
{
switch(nFlag)
{
case QUST_ACCEPTED:
{
object oSabina = UT_GetNearestCreatureByTag(oPC, aquae);

UT_HireFollower(oaquae);
break;
}
break;
}
}

plot_OutputDefinedFlag(eParms, nResult);

return nResult;
}

#3
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Grrr....can't get her to join the party no matter what I try....

#4
Mengtzu

Mengtzu
  • Members
  • 258 messages
You just want to check the plot?



#include "wrappers_h"

#include "plt_whateveryoucalledyourplot"



WR_GetPlotFlag(PLT_WHATEVERYOUCALLEDYOURPLOT, FLAGNAME)

#5
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
No, the plot is checked in a conversation.



I want to add the NPC to the party.

#6
Mengtzu

Mengtzu
  • Members
  • 258 messages
 object oSabina = UT_GetNearestCreatureByTag(oPC, aquae);

UT_HireFollower(oaquae);


I'm guessing that's the issue :)

Post back if you have any troubles with followers, they're actually quite tricky but I think I've got a handle on it.  The first issue you'll have there is that your follower won't gain XP.   You can solve that by either using a fixed version of UT_HireFollower or by adding SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0); to a later script that you know will fire.

#7
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
That wasn't actualyl the scrip I was unsing..damn copy-paste...happens when you have several open windows.







#include "log_h"

#include "utility_h"

#include "wrappers_h"

#include "events_h"

#include "2da_constants_h"

#include "plt_aquae_plot"



void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);

string sDebug;

object oPC = GetHero();

object oParty = GetParty(oPC);

int nEventHandled = FALSE;

string strPlot = GetEventString(eParms, 0); // Plot GUID

int nFlag = GetEventInteger(eParms, 1); // The bit flag # being affected



switch(nEventType)

{



case EVENT_TYPE_SET_PLOT:

{

if(nType == EVENT_TYPE_SET_PLOT) /

{

// int nValue = GetEventInteger(eParms, 2);

//int nOldValue = GetEventInteger(eParms, 3);



switch(nFlag)

{

case AQUAE_JOIN:

{

object oAquae = UT_GetNearestCreatureByTag(oPC,aquae);

UT_HireFollower(oAquae);

}

break;

}

}

}



if (!nEventHandled)

{

HandleEvent(ev, RESOURCE_SCRIPT_AREA_CORE);

}

}

#8
DavidSims

DavidSims
  • BioWare Employees
  • 196 messages
Does that compile? aquae is being used as a tag and it's not in quotes. unless you defined it as a constant somewhere.

#9
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
You're right..I am missing quotes....



Hmmmm.... She still doesn't join the party. *pouts* I'm gonna try with a different script.

#10
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
DAngnammit!

I even followed this tutorial:
social.bioware.com/wiki/datoolset/index.php/Follower_tutorial
to the letter.


She still isn't joining!

This is party_join script that is triggered by the conversation:
----------------
#include "utility_h"
#include "plt_aquae_plot"                              // my plot
#include "add_custom_party_member_h"        // exactly the same as in the tutorial. just a different name

void main() {

                    object oHero = GetHero();
                    object oAquae = GetObjectByTag("aquae");


                    //Add to the party and set joining plot flags

                    hireCustomFollower(oAquae, class_WIZZARD, PLT_AQUAE_PLOT, AQUAE_JOIN);



        SetPartyPickerGUIStatus(2);
        ShowPartyPickerGUI();  //Shows the Party Picker; necessary for the follower to gain XP

}

--------------------------------
the tm_event module script:
---------------------------------

#include "utility_h"
#include "wrappers_h"
#include "plt_aquae_plot"   //make sure you include your own plot, not mine

void main()
{
    event ev = GetCurrentEvent();
    int nEventType = GetEventType(ev);
    switch(nEventType)
    {
        case EVENT_TYPE_PARTYMEMBER_ADDED:
        {
            object oFollower = GetEventObject(ev, 0);
            SetLocalInt(oFollower, CREATURE_REWARD_FLAGS, 0);
            SetFollowerState(oFollower, FOLLOWER_STATE_ACTIVE);

            if (GetTag(oFollower) == "aquae") {               //You must explicitly test for your follower's tag.
                WR_SetPlotFlag(PLT_AQUAE_PLOT, AQUAE_IN_PARTY, TRUE);     //Make sure you use your own flags!
            }

            break;
        }

        case EVENT_TYPE_PARTYMEMBER_DROPPED:
        {
              object oFollower = GetEventObject(ev, 0);

              if (GetTag(oFollower) == "aquae") {
                WR_SetPlotFlag(PLT_AQUAE_PLOT, AQUAE_IN_PARTY, FALSE);     //As above, but set false.
              }

        }

    }
}





I'm missing something, but I'm not sure what.
Maybe I should go for triggering the joining vie a script that checks a plot flag set in a convo, instead of this...

Modifié par Lotion Soronnar, 06 janvier 2010 - 05:12 .


#11
Mengtzu

Mengtzu
  • Members
  • 258 messages
I would skip the plot flag and just directly invoke the hire script from conversation - even just as a test.

#12
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Got everything working (more or else)

Another question - now I'm trying to add a NPC to the redcliffe at night, and that NPC sjould join the player (as a non-party member) and leave the party once the battle is done.

Will this work? (I'm thinking of using this bit i nthe module script. Is there a better way? The PRCSRC is pre-load only IIRC)

************

#include "utility_h"
#include "events_h"
#include "arl_constants_h"
#include "plt_aquae_plot"

void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);



switch(nEventType)
{
case ARL_SIEGE_FIGHT_STARTS
{
object oRcN = GetObjectByTag("arl100ar_redcliffe_night");
vector vAqWind = Vector(355.699f, 344.979f, 36.097f);
object oAqDef = CreateObject(OBJECT_TYPE_CREATURE, R"aquae_night.utc", Location(oRcN, vAqWind, 180.0f));

SetGroupId(oAqDef,GROUP_FRIENDLY);
AddNonPartyFollower(oAqDef);
}
break;


case ARL_SIEGE_OVER
{
RemoveNonPartyFollower("aquae_night");
WR_SetPlotFlag(PLT_AUAE_PLOT, REDCLIFFE_DEFENDED, TRUE);
}
break;
}

Modifié par Lotion Soronnar, 09 janvier 2010 - 02:24 .


#13
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
What happened when you tried it?

#14
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Haven't tried it yet..I still got some preparations and tweaks to do..and it's darn late here.

Just wanted to know if my coding is sound, and what's hte best way to trigger it.

#15
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
OK, this has me left staring at hte screen.....



If I just want to add a NPC somewhere, using PRCSCR and a simple scrip is all I need.



But what if I want to add a NPC and monitor some events? PRCSCR is not enough, since it runs when entering the area and doesn't check for stuff happening all the time.



The Redcliffe at night scenario above. I want to add a NPC to the fight (as NoPartyFollower)and remove it after the fight ends. I'm no sure how to go about this...

#16
thebigMuh

thebigMuh
  • Members
  • 98 messages
Hm...



Just off the top of my head: Could you use the PRCSCR script to replace the standard redcliffe-at-night area script with your own script, which then handles the events you need and passes down all the unhandled events to the old redcliffe-at-night script?



That should work with the standard game and any possible updates to it, but will collide with other addons that do the same thing to Redcliffe...



Ciao, muh!

#17
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Yes, and that'0s exactly my problem. If I want to do it that way, I don't even have to bother with PRCSCR - I can just edit a local copy of the script and add my changes and export - same effect in the end.

That's why I am asking - is there a way to do this "right"

#18
Craig Graff

Craig Graff
  • Members
  • 608 messages
You can fire code from the EVENT_TYPE_PERCEPTION_APPEAR of your creature and test when a party member is first coming into sight. Alternately, you could set down an AoE (Area of Effect) where you want the event to trigger and despawn it once the party triggers it.

Theoretically your could tie into the events you want with RegisterEventListener, but that isn't entirely intuitive and may just be broken.

The method suggested by thebigMuh will be more sustainable if we are able to add a GetEventScript function.

#19
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
HMmm....Would I even need the code to remove the NPC?

The spawning and adding to party(as NonFollower) is easy enough, but once the player finishes the Redcliffe siege, he is moved to another level. That removes the NonPartyFollower too, no?


***
I'm still not sure if I got all the scripts precedence right.
AFIAK, you got:

PRCSCR - scripts triggered at area load, can be used to set up things at the begining (but not to monitor and alter things during play)

Module - script runs as long as the module is running

Area - script runs as long as the player is in the area

conversation - triggered from a conversation, used to affect or change something at a singel point in time.


Normally an area script would be the best suited for monitoring different plot events and player progress, but since this IS a singleplayer area, I might have to go with the module script. F'course, I wanna avoid dumping too much into that script.

Modifié par Lotion Soronnar, 18 janvier 2010 - 07:16 .


#20
Craig Graff

Craig Graff
  • Members
  • 608 messages
Unfortunately AddNonPartyFollowers must explicitly be paired with RemoveNonPartyFollower, since there is a limit to the number of non-party followers and this tally isn't updated when a non-party follower is left behind, but only when explicitly removed.

#21
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Hm...and I can't really remove her from another area then.

The knights and redcliffe and the milita - they don't count and nonParty followers, they are just friendly combatants, right?
In that case, I may simply make her one. She wouldn't follow the player around, but she would still fight the undead.

Well, that or I use the module script to catch some redcliffe specific events and work with that. Or edit the area script.
Thanks for you help Craig.

Modifié par Lotion Soronnar, 18 janvier 2010 - 12:06 .


#22
Craig Graff

Craig Graff
  • Members
  • 608 messages
Creatures can be moved between areas if you move them to and from the stage area or if the areas share an area list. Editing the area script is probably easiest in this case, though. If it's all in the Redcliffe areas, you could try editing arl000ar_generic_core.

If you are working with a custom creature, you could possibly work with EVENT_TYPE_EQUIP, as crazy as that sounds. It seems to fire just before a creature is unloaded. You'd need to figure out the order of events, as well as screen for multiple events if your creature has several things equipped, but it should allow you to either call RemoveNonPartyFollower or SetLocation to the stage area.

#23
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
Two questions:

1. I searched EVERYWHERE and for the life of me I can't find any xls, 2da, gda or script that controls how many attribute points per level a character gets. Is it hardcoded?

2. I edited bhn000ip_door_pantry, and added a single plot flag check just before hte final cutscene in hte human noble origin triggers:
if (WR_GetPlotFlag(PLT_IONA_PLOT, IONA_FALLS) == TRUE)
{
WR_SetPlotFlag(PLT_IONA_PLOT, IONA_KILLED, TRUE);
}


I get this error:
E: 11:04:19 - sys_traps_h.nss - sys_traps_h.nss(1521): No right bracket on expression (while compiling bhn000ip_door_pantry.nss)

I haven't touched sys_trap_h.nss and the line it poitns to seem to have all it's brackets in order..

That would be the IF line:

// Don't trigger if player is attempting to disarm this trap
command cCurrent = GetCurrentCommand(oTarget);
if (GetCommandType(cCurrent) == COMMAND_TYPE_USE_OBJECT && GetCommandObject(cCurrent) == oTrap)
{
Log_Trace(LOG_CHANNEL_SYSTEMS_TRAPS, "sys_traps_h.Trap_HandleEventEnter", "Discarding OnEnter event - player attempting to disarm trap: " + GetTag(oTrap));
return;
}


What gives?

Modifié par Lotion Soronnar, 23 janvier 2010 - 10:05 .


#24
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
And yet ANOTHER question.





I want a NPC to move (walk, visibly) after a conversation to a new location.

Now, since this is a npc I added to a singleplayer area with a script, I can't use ambient behavior to move it.

Is there any way to make it happen or should I drop the idea?

#25
Lotion Soronarr

Lotion Soronarr
  • Members
  • 14 481 messages
*bumpsky*