Aller au contenu

Photo

[Solved] Adding a Specialization to a character


  • Veuillez vous connecter pour répondre
11 réponses à ce sujet

#1
Gralamin

Gralamin
  • Members
  • 45 messages
So, I've been trying to get Sten to start off with reaver for a while. Currently, I'm using the following Script:

#include "utility_h"
#include "plt_sten_is_reaver"

void addReaverToSten();

void main()
{
    event ev   = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events("", ev);
    switch (nEvent)
    {
        case EVENT_TYPE_MODULE_LOAD:
        {
            // Check if we've done this before
            if (WR_GetPlotFlag(PLT_STEN_IS_REAVER, REAVER_SET_ON_STEN) == 1)
                break;

            //If not, see if Sten is Valid.
            object oSten = GetObjectByTag(GEN_FL_STEN);

            if (IsObjectValid(oSten))
            {
                addReaverToSten();
                WR_SetPlotFlag(PLT_STEN_IS_REAVER, REAVER_SET_ON_STEN, 1);
            }
            break;
        }
    }
}

void addReaverToSten()
{
    object oSten = GetObjectByTag(GEN_FL_STEN);
    int nReaver = class_REAVER;
    int nActivated = 1;

    SetclassRank(oSten, nReaver, nActivated);
}

Which, doesn't seem to work. Anyone have any idea how to do this?

Modifié par Gralamin, 28 novembre 2009 - 09:59 .


#2
Talian Kross

Talian Kross
  • Members
  • 239 messages
You'll also need to add the ability.



ABI_base.xls, ID:4019, HIDDEN_REAVER



In your case / sample code:



AddAbility( oSten, 4019 );

#3
Gralamin

Gralamin
  • Members
  • 45 messages
I'll give that a go, thanks.

Edit: That worked. Now I just have to somehow call that function when you gain Sten in the first place.

Edit2: Hmm, Overriding "EVENT_TYPE_PARTY_MEMBER_HIRED" doesn't seem to work (File name events_gral_addreaver. And "EVENT_TYPE_PARTY_MEMBER_HIRED" Doesn't seem to work from core. Any other ideas?

Modifié par Gralamin, 27 novembre 2009 - 03:55 .


#4
Nodrak

Nodrak
  • Members
  • 144 messages
You could make a simple one time use item module that you turn on, load your game, use it to give sten the abilities, save, turn off/delete the mod, force load, save.

#5
Gralamin

Gralamin
  • Members
  • 45 messages

Nodrak wrote...

You could make a simple one time use item module that you turn on, load your game, use it to give sten the abilities, save, turn off/delete the mod, force load, save.


Yeah, but I don't want to resort to a hack like that. Ideally, I should be able to give the abilities to Sten either BEFORE you get him, or exactly when you get him.

#6
Gralamin

Gralamin
  • Members
  • 45 messages
http://pastebin.com/m22a1910b

Here is all my code. Just in case that helps

#7
Talian Kross

Talian Kross
  • Members
  • 239 messages

Gralamin wrote...

..., I should be able to give the abilities to Sten either BEFORE you get him, or exactly when you get him.

To do that, you'd have override Sten's dialogue script since that's what triggers him being hired.  Wouldn't that be part of the Campaign resources that haven't been released to us yet?  (I'm not sure.)

Otherwise, you'll just have to continuously monitor when or if Sten is a member of your party, like so:

void MakeStenAReaver()
{
    object oSten = Party_GetFollowerByTag( GEN_FL_STEN );
    if( IsObjectValid( oSten ) )
    {
        if( !HasAbility( oSten, 4019 ) )
        {
            AddAbility( oSten, 4019 );
        }
    }
}

And just throw a call to that function in your EVENT_TYPE_MODULE_LOAD block or something.

#8
Nodrak

Nodrak
  • Members
  • 144 messages
There are numerous logical issues with your code, like checking against things that your code has prevented from happening via rerouting the event (if you can reroute events from events.xls).  HandleEvent() needs a second paramater or else it passes the event to the object that called HandleEvent(), in this case your script might enter an infinite loop (Its more likey that it is passed to player_core).  You could hand the event to player_core before you check for Sten in the party, preventing many issues.  The event you are trying to override is defined in engineevents, rather then events, so your worksheet name would have to be prefixed with engineevents.

While looking at this, I became curious, and so I dug around untill I found a sollution everyone will like.  In the packages_base M2DA (packages.xls), you will find Sten on line 85.  The two black collums border a region that has been 'minimized' for lack of the correct excell term.  Click the + above the collum lables to find the class's for your companions.

Player_core limits followers to one spec, so only switch1_class is used.  Set the level you want Sten to learn it at (blank for starting with it), and set the ID for Reaver, 4019.  Ofcourse, do this in a seperate worksheet/workbook, prefixed with packages_base (there is a reference to a 2da called packages, but I cannot locate that worksheet).  Process that baby into a gda, and there is your Sten mod in one short file.  No need for scripts.

Modifié par Nodrak, 28 novembre 2009 - 08:45 .


#9
Gralamin

Gralamin
  • Members
  • 45 messages

Nodrak wrote...

There are numerous logical issues with your code, like checking against things that your code has prevented from happening via rerouting the event (if you can reroute events from events.xls).  HandleEvent() needs a second paramater or else it passes the event to the object that called HandleEvent(), in this case your script might enter an infinite loop.  You could hand the event to player_core before you check for Sten in the party, preventing many issues.

http://social.biowar.../Event_override <- I followed this for event override, it clearly uses HandleEvent(ev), so I doubt you are correct there, or the Wiki should be changed to represent that.

The event you are trying to override is defined in engineevents, rather then events, so your worksheet name would have to be prefixed with engineevents.

Definitely a possibility on that one. I'll have to check that.

I'll also point out that two (Possible errors - Not even confirmed these are both problems) is hardly numerous logical issues.


While looking at this, I became curious, and so I dug around untill I found a sollution everyone will like.  In the packages_base M2DA (packages.xls), you will find Sten on line 85.  The two black collums border a region that has been 'minimized' for lack of the correct excell term.  Click the + above the collum lables to find the class's for your companions.

Player_core limits followers to one spec, so only switch1_class is used.  Set the level you want Sten to learn it at, and set the ID for Reaver, 4019.  Ofcourse, do this in a seperate worksheet/workbook, prefixed with packages_base (there is a reference to a 2da called packages, but I cannot locate that worksheet).  Process that baby into a gda, and there is your Sten mod in one short file.  No need for scripts.

It would be, however, 100% In compatible with other mods that might try to replace characters (A rebalancing mod, for example). Given, though, that mine, as is, gives some compatibility issues, I'll probably release both versions, after looking around to ensure that actually does what I want.

Thanks for the help though.


Edit: engineevents worked, now checking for infinite loops.
Edit2: No infinite loops That I can tell - my Print statements aren't spamming thousands of statements.

Talian Kross wrote...

Gralamin wrote...

..., I should be able to give the abilities to Sten either BEFORE you get him, or exactly when you get him.

To do that, you'd have override Sten's dialogue script since that's what triggers him being hired.  Wouldn't that be part of the Campaign resources that haven't been released to us yet?  (I'm not sure.)

Otherwise, you'll just have to continuously monitor when or if Sten is a member of your party, like so:

void MakeStenAReaver()
{
    object oSten = Party_GetFollowerByTag( GEN_FL_STEN );
    if( IsObjectValid( oSten ) )
    {
        if( !HasAbility( oSten, 4019 ) )
        {
            AddAbility( oSten, 4019 );
        }
    }
}

And just throw a call to that function in your EVENT_TYPE_MODULE_LOAD block or something.

Or, I can use event override. EVENT_TYPE_MODULE_LOAD is a poor indication, as it isn't called on frequently enough. Saying "You have to do this" is usually an indication of needing to rethink your statement :P

Modifié par Gralamin, 28 novembre 2009 - 09:09 .


#10
Nodrak

Nodrak
  • Members
  • 144 messages
As per Script.ldf:

/** @brief Handles the event.
*
* Handles the specified event by passing it to the specified
* script for processing. You can access the event in the script
* by calling GetCurrentEvent() and doing all of your processing
* there. This function is executed inline.
*
* @param evEvent - The event to handle.
* @param rScriptName - The script that will handle the event (*.ncs). If no script is specified
* then the object's default script will be run
* @sa GetCurrentEvent()
* @author Brenon
*/
void HandleEvent( event evEvent, resource rScriptName=R"" )

The wiki entry is somehwhat correct in that the intended recipient of the event is the same as the creature's default script, player_core, this is not always the case however. I was unsure of the loop potential because the event gets called from a conversation, but the dev's took that into account and manually set the default script.

I wasn't meaning to be harsh if I came off that way, sorry. However, the differences between the methods is not so clear cut. The only thing in the 2da I reccomended is the level and class of your followers (we are only overriding one line, its an m2da remember), with a few basic routing labels. The only reason I see to edit this 2da is for class changes. Your override on the other hand, might interfere with a specific use of the event that a designer may need (complex scripting after hire, I dunno).

Modifié par Nodrak, 28 novembre 2009 - 09:43 .


#11
Talian Kross

Talian Kross
  • Members
  • 239 messages

Gralamin wrote...

Saying "You have to do this" is usually an indication of needing to rethink your statement :P

Please don't belittle those attempting to aid you.  If you must know, though, since I can now feel free to sink to your level, I personally have a heartbeat script going, but I thought that would be beyond your ability to understand at this point in your learning, so I just threw out "EVENT_TYPE_MODULE_LOAD or something"  (note the "or something") since all novice modders tend to like to use that event.

If you didn't want to implement a heartbeat event, you could've always monitored EVENT_TYPE_GUI_OPENED or EVENT_TYPE_GAMEMODE_CHANGE as those are sent fairly regularly, i.e., whenever hit ESC, for instance.

Regardless, good luck!

Modifié par Talian Kross, 28 novembre 2009 - 12:34 .


#12
Gralamin

Gralamin
  • Members
  • 45 messages

Nodrak wrote...

As per Script.ldf:

/** @brief Handles the event.
*
* Handles the specified event by passing it to the specified
* script for processing. You can access the event in the script
* by calling GetCurrentEvent() and doing all of your processing
* there. This function is executed inline.
*
* @param evEvent - The event to handle.
* @param rScriptName - The script that will handle the event (*.ncs). If no script is specified
* then the object's default script will be run
* @sa GetCurrentEvent()
* @author Brenon
*/
void HandleEvent( event evEvent, resource rScriptName=R"" )

The wiki entry is somehwhat correct in that the intended recipient of the event is the same as the creature's default script, player_core, this is not always the case however. I was unsure of the loop potential because the event gets called from a conversation, but the dev's took that into account and manually set the default script.

I wasn't meaning to be harsh if I came off that way, sorry. However, the differences between the methods is not so clear cut. The only thing in the 2da I reccomended is the level and class of your followers (we are only overriding one line, its an m2da remember), with a few basic routing labels. The only reason I see to edit this 2da is for class changes. Your override on the other hand, might interfere with a specific use of the event that a designer may need (complex scripting after hire, I dunno).


A good point. Thus the idea to release two versions. And you didn't come off as that harsh, its just some of your wording I disagree with (IE: Two != Numerous).

Talian Kross wrote...

Gralamin wrote...

Saying "You have to do this" is usually an indication of needing to rethink your statement :P

Please don't belittle those attempting to aid you.  If you must know, though, since I can now feel free to sink to your level, I personally have a heartbeat script going, but I thought that would be beyond your ability to understand at this point in your learning, so I just threw out "EVENT_TYPE_MODULE_LOAD or something"  (note the "or something") since all novice modders tend to like to use that event.

If you didn't want to implement a heartbeat event, you could've always monitored EVENT_TYPE_GUI_OPENED or EVENT_TYPE_GAMEMODE_CHANGE as those are sent fairly regularly, i.e., whenever hit ESC, for instance.

Regardless, good luck!

Sorry,
apparently that didn't come across right. Usually, when the :P smiley is used, it means it is likely a good indication of a joke, In my experience. But, at the same time it was pointed at your wording, saying you have to do something is implying anything else wouldn't work, which is usually not true.

I have actually considered the heartbeat approach before, but decided such a check, while quick, isn't worth the effort of the setup on its own. If I was doing this to multiple followers, then MAYBE a heartbeat would be worth using, but for this it is simply overkill.

Using one of the GUI events might be a good idea, and one I honestly hadn't thought of. In fact, the GUI one might be close to ideal. Heck, if the party Picker counts as the GUI_OPENED it would be ideal. (Without overriding)

Also, I used EVENT_TYPE_MODULE_LOAD here, because I specifically wanted it to be added immediately when you open the game if you have Sten. It's not used just because I'm a novice at Scripting - its used because It gets one of the results I intended.

Edit: Huh. I thought that the Heartbeat events didn't work. Oh well, now that I know they do, I have set it up to use Heartbeat, and thus works completely, without any overriding.

Modifié par Gralamin, 28 novembre 2009 - 09:34 .