Aller au contenu

Photo

[Conversation/Script Help] Having troubles, please help. [SEMI - SOLVED]


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

#1
invaderzem

invaderzem
  • Members
  • 19 messages
To start with I will say that I am not a programmer and nor do I understand c++ but I am giving it a damn good try.

I have set plot flags in a conversation that I have created and want to access them via a script to change player details but I am lost on what the code should look like. I'm assuming I should be using the EVENT_TYPE_AMBIENT_CONTINUE as this is when the conversation ends (am I right)? but then what would be the code for "if plot flag 1 is set - then - object oHero = GetHero(); Chargen_SelectCoreclass(oHero,class_ROGUE);"

I'm trying to make an object that when you talk to it you can change your class, amongst over things. Please help I'm stuck bad :(

Modifié par invaderzem, 25 novembre 2009 - 11:59 .


#2
invaderzem

invaderzem
  • Members
  • 19 messages
Okay this is what I have in the script. It compiles and everything but when I choose the appropriate option in the conversation, the conversation ends like expected but the characters class does not change.


==========================================================
#include "events_h"
#include "utility_h"
#include "global_objects_h"
#include "sys_chargen_h"
#include "sys_rewards_h"
#include "plt_pl_identity"

void main()
              {
                    event ev = GetCurrentEvent();
                    int nEventType = GetEventType(ev); //extract event type from current event
                    int nEventHandled = FALSE; //keep track of whether the event has been handled
                    switch(nEventType)
                                    {
                                      case EVENT_TYPE_AMBIENT_CONTINUE:
                                                  {
                                                  if (WR_GetPlotFlag(PLT_PL_IDENTITY, IS_ROGUE))
                                                               {
                                                                object oHero = GetHero();
                                                                Chargen_SelectCoreclass(oHero,class_ROGUE);
                                                                 }
                                                                 break;
                                                    }
                                     }
                                     if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
                       {
                       HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
            }
}
====================================================

Modifié par invaderzem, 23 novembre 2009 - 01:38 .


#3
stuntpope

stuntpope
  • Members
  • 112 messages
Well the short answer is:

if (WR_GetPlotFlag(PLT_plotnamehere, 1)){
object oHero = GetHero();
Chargen_SelectCoreclass(oHero, class_ROGUE);
}

but I think you should be careful with that. Have you thought through the consequences of changing someone's class without changing their background? What will hapen if you haven't cleared the skills that they already have? I suggest you have a look at the sys_chargren script in the systems folder to see how this is used during character creation. It might give you some ideas. Looking at the bioware scripts is also a great way to learn. Also have a look at the actual definition of the function so you are clear about what it does.

EDIT - ok you posted again while I was constructing an answer. Looks like you were onto the right track.

Modifié par stuntpope, 23 novembre 2009 - 01:56 .


#4
stuntpope

stuntpope
  • Members
  • 112 messages
I am wondering where you have that script hooked up - it looks like you are using a module script but that event is not a module event. You want your script to fire when the conversation ends so you need to hook it up to fire at that point.

Even if you do get that event you don't want to pass it on to module core because it won't know what to do with it and it will just log it as an unhandled event.

Modifié par stuntpope, 23 novembre 2009 - 02:04 .


#5
weriKK

weriKK
  • Members
  • 106 messages

invaderzem wrote...
...
void main()
              {
                    event ev = GetCurrentEvent();
                    int nEventType = GetEventType(ev); //extract event type from current event
                    int nEventHandled = FALSE; //keep track of whether the event has been handled
                    switch(nEventType)
                                    {
                                     }
                                     if (!nEventHandled) //If this event wasn't handled by this script, let the core script try
                       {
                       HandleEvent(ev, RESOURCE_SCRIPT_MODULE_CORE);
            }
}
...


If you are not using event override in your script then this can potentionally bring the game to it's knees including every other mod other people have written.

What you do here is catching an event with your event handling script of your module, an event that is sent out to every single module in the game (events are not sent to specific modules) and then you delegate it back to the core module's event handler at the end. This way in some cases that core module will process the exact same event TWICE which can cause many issues including the infamous double attribute point issue.

The only time you want to pass an event back to the respective core event handler is when you are overriding that script and no event messages would reach it otherwise.

#6
invaderzem

invaderzem
  • Members
  • 19 messages
Thanks for your replies people. I won't have time to work on it until tomorrow but you've definitely given me some things to look into. @Stuntpope: I wasn't too worried about the background of the characters as this was for a single level stand alone campaign and they would not be interacting with any main campaign.

@weriKK: This override business is something I had not even thought about. Thanks for bringing it to my attention, it seems vital. Looks like thats my next hurdle to sink my teeth into.

Modifié par invaderzem, 23 novembre 2009 - 08:37 .


#7
invaderzem

invaderzem
  • Members
  • 19 messages
So I've finally fixed it.... I made the ROOT script for the conversation the below script (apparently this was a vital step I was missing, leading to me trying to use EVENTS and what not).

===========================================
#include "sys_chargen_h"
#include "plt_pl_identity"

void main()
{
    if (WR_GetPlotFlag(PLT_PL_IDENTITY, IS_ROGUE))
    {
        object oHero = GetHero();
        Chargen_SelectCoreclass(oHero,class_ROGUE);
        Chargen_SelectBackground(oHero,BACKGROUND_NOBLE);
    }
}
==========================================

So now it works, the only problem I have is that this only ADDS the class to your current class (eg. if your warrior and pick rogue in the conversation you become a warrior/rogue). I've now fixed this issue by doing:

    object oHero = GetHero();
    Chargen_InitializeCharacter(oHero);
    int nTargetLevel = 25;
    RewardXP(oHero, RW_GetXPNeededForLevel(nTargetLevel), FALSE, FALSE);
    SetCanLevelUp(oHero, FORCE_AUTOLEVEL);

But now I have the problem of losing all the skills in the skills panel when leveling except for coersion.

Modifié par invaderzem, 25 novembre 2009 - 11:59 .


#8
stuntpope

stuntpope
  • Members
  • 112 messages
yes you will have to clear their current class. Have a look in the sys_chargen script in the _Systems folder to see how Bioware do it in character generation.

Modifié par stuntpope, 25 novembre 2009 - 12:03 .