Aller au contenu

Photo

Soundset scripting question


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

#1
Malcroix

Malcroix
  • Members
  • 360 messages
Within the custom soundset project, I'm trying to make soundsets behave more like they did in the Infinity/Aurora games. There are 2 issues I've encountered which seem to be caused by scripts:

1. The Player character does not respond when hir portrait is clicked while in Explore mode;

2. None of the party members respond when ordered to move while in Explore mode.

In Combat mode everyone responds as they should, so it is not an issue of the soundset files or of the soundset 2DAs.

After looking through sys_soundset_h, here's what I found:

1. Player character respond problem:

  case SOUND_SITUATION_SELECTED:
        {
            nSound = SS_EXPLORE_SELECT_NEUTRAL;
            if (IsFollower(oCreature))
            {
                nSound = SS_EXPLORE_SELECT_HATE;
                int nApproval = GetFollowerApproval(oCreature);

                if (nApproval >= GetLocalInt(GetModule(), APP_RANGE_VALUE_NEUTRAL))
                    nSound = SS_EXPLORE_SELECT_NEUTRAL;
                if (nApproval >= GetLocalInt(GetModule(), APP_RANGE_VALUE_WARM))
                    nSound = SS_EXPLORE_SELECT_FRIENDLY;
                if (nApproval >= GetLocalInt(GetModule(), APP_RANGE_VALUE_FRIENDLY))
                    nSound = SS_EXPLORE_SELECT_LOVE;
            }
            break;

Is the player character considered a follower? Because the toolset keeps referencing the follower as "member of the same party as player". But isn't the player also a member of the same party, i.e. "party member"?

If that is indeed so, then:
 
1. Instead of playing the default Neutral sound
2. the script would be checking for the Player character's Approval rating;
3. since the PC doesn't have an Approval rating, the script would attempt to play the default Hate sound;
4. but since player soundsets don't have hate replies (only neutral), no sound would be played at all.

I understand it's a rather thin premise, but that's the only remotely possible reason I've found so far for Player characters not responding on click when in Explore mode.

What I did:

Replaced

nSound = SS_EXPLORE_SELECT_HATE;

with

nSound = SS_EXPLORE_SELECT_NEUTRAL.

Would that be a solution?


2. Move order problem:

Here's what I found in sys_soundset_h:

if (nSituation == SOUND_SITUATION_ORDER_RECEIVED)
                {
                    if (!IsStealthy(oCreature))
                    {
                        float fProb = GetM2DAFloat(TABLE_COMMANDS, "SoundsetProbability", nCommandType);
                        // No voice chat when moving in explore mode.
                        switch (nCommandType)
                        {
                            case COMMAND_TYPE_DRIVE:
                            case COMMAND_TYPE_MOVE_TO_LOCATION:
                            case COMMAND_TYPE_MOVE_TO_OBJECT:
                                if (nMode == GM_EXPLORE)
                                    fProb = 0.0f;

                        }
                        if (fProb > 0.0f)
                        {
                            #ifdef DEBUG
                            Log_Trace(LOG_CHANNEL_SOUNDSETS, "sys_soundsets.play", "SOUND_SITUATION_ORDER_RECEIVED: Command = " + Log_GetCommandNameById(nCommandType) + ", Probability = " + ToString(fProb));
                            #endif
                            PlaySoundSet(oCreature, nSound, fProb);
                        }
                    }
                }
                else
                {
                    #ifdef DEBUG
                    Log_Trace(LOG_CHANNEL_SOUNDSETS, "sys_soundsets.play", "oCreature: " + ToString(oCreature) + ", nSituation: " + ToString(nSituation) + ", Sound: " + ToString(nSound));
                    #endif
                    PlaySoundSet(oCreature, nSound);

What I did:

1. Removed the line

case COMMAND_TYPE_MOVE_TO_LOCATION:

2. Changed fProb = 0.0f to fProb = 1.0f;

Would that be a solution?

3. Implementation

Before you ask, yes, I tried implementing these changes. It's a tricky process, because sys_soundset_h is an "include", and can't be compiled on its own. After reading this thread, I did the following:

1. Changed sys_soundset_h, saved, exported as nss, put the nss into override;

2. Compiled the scripts which include sys_soundset_h (so far I found three: rules_core, player_core, creature_core). This put a whole bunch of files into my override/toolsetexport, among them another nss of sys_soundset_h;

3. Launched game.

Nothing happened.

So, there's a mistake, or several, in the above process.

Help would be appreciated.

P.S. If you're interested, my custom soundsets, which are fully workable, can be found here.

P.P.S. Sorry for the bland formatting, I tried to make it color-coded, but this forum engine reverted all my colors to white.

Modifié par Malcroix, 21 mars 2010 - 01:10 .


#2
Lord Thing

Lord Thing
  • Members
  • 257 messages
 1. As far as I can tell, the Player is not considered a follower, so 'nSound' should simply default to 'SS_EXPLORE_SELECT_NEUTRAL'

In fact, if the Player was considered a follower, the check wouldn't be necessary, as the only to trigger this case is to click on the portrait of the player or their followers, as no-one else has portraits that you can click on.

However, I'm not sure why the Player doesn't respond when moving outside of combat, it's probably somewhere else in the code.


2. The majority of the code here deals with sounds whilst the creature is stealthed, giving it a probability ('fProb') of the creature saying something whilst stealthed.  The 'No voice chat when moving in explore mode.' switch statement you have highlighted their simply stops the creature from speaking during explore mode while they are stealthed.

Removing the line 'case COMMAND_TYPE_MOVE_TO_LOCATION:' would simply stop the code from silencing the creature if the creature was ordered to move to a location, whilst in stealth.

Changing the 'fProb = 0.0f' to 'fProb = 1.0f;' would simply force the creature to speak whilst ordered to Drive or Move to Object whilst stealthed in explore mode (it would also include Move to Location, but you removed that)

According to this section of code, if the creature is not stealthed, it simply plays the given 'nSound' no matter what.  What you'll likely want to do is find where this 'nSound' is set, and make sure it actually has a sound in it.

3.  The way you're doing things, this should be the way to export your changes.  Make sure, however that you place the files in '{module name}/core/override/toolsetexport' and not '{module name}/module/override/toolsetexport'

As I said in the other thread here, this isn't the best way of doing things compatibility-wise, but if you don't have the experience to do the work-arounds just yet, it will still work.

Modifié par Lord Thing, 22 mars 2010 - 09:22 .


#3
Malcroix

Malcroix
  • Members
  • 360 messages

Lord Thing wrote...

 1. As far as I can tell, the Player is not considered a follower, so 'nSound' should simply default to 'SS_EXPLORE_SELECT_NEUTRAL'


Then why isn't the sound played? It plays OK in the combat selection (SS_COMBAT_SELECT_NEUTRAL), but not in Explore. Only Explore has this check for approval of followers, so Occam's razor...




In fact, if the Player was considered a follower, the check wouldn't be necessary, as the only to trigger this case is to click on the portrait of the player or their followers, as no-one else has portraits that you can click on.


Well maybe the script designer forgot that 8-P It may well be a scripting error.


However, I'm not sure why the Player doesn't respond when moving outside of combat, it's probably somewhere else in the code.


So far I've looked through nearly all core scripts, and soundset_h is the only one to directly regulate the selection sound.


2. The majority of the code here deals with sounds whilst the creature is stealthed, giving it a probability ('fProb') of the creature saying something whilst stealthed.  The 'No voice chat when moving in explore mode.' switch statement you have highlighted their simply stops the creature from speaking during explore mode while they are stealthed.


Wait a sec. Doesn't

if (!IsStealthy(oCreature))

mean that it applies when the creature is NOT stealthed? The exclamation point means NOT, right?

If I'm wrong on this, then the problem is probably indeed elsewhere 8-(


 What you'll likely want to do is find where this 'nSound' is set, and make sure it actually has a sound in it.


I'll double check that when I get back from work, but:

the movement sounds work perfectly when in Combat mode, so there's nothing wrong with the sounds themselves.


3.  The way you're doing things, this should be the way to export your changes.  Make sure, however that you place the files in '{module name}/core/override/toolsetexport' and not '{module name}/module/override/toolsetexport'


The toolset itself actually puts them into the main override/toolsetexport. I put the actual core NCS files into the root override, and leave all the extra exported fluff in the toolsetexport.


As I said in the other thread here, this isn't the best way of doing things compatibility-wise, but if you don't have the experience to do the work-arounds just yet, it will still work.


Yeah, I want to make it work first, and then will think about making it more compatible etc.

Thanks for the help!

Modifié par Malcroix, 22 mars 2010 - 10:47 .


#4
Lord Thing

Lord Thing
  • Members
  • 257 messages
Ah, yes, '!' does mean not, my bad, somehow I didn't notice it >.>

Still, I'd suggest you put the 'case COMMAND_TYPE_MOVE_TO_LOCATION' back, as you're setting 'fProb' to 1.0f anyway, as there may be something in the m2da that says that the players fProb is always 0 whilst exploring or something.

Malcroix wrote...

Then why isn't the sound played? It plays OK in the combat selection (SS_COMBAT_SELECT_NEUTRAL), but not in Explore. Only Explore has this check for approval of followers, so Occam's razor...


You can also try putting an:

if (IsPlayer(oCreature))
{
     nSound = SS_EXPLORE_SELECT_NEUTRAL;
}



after the end of the 'if (IsFollower(oCreature))' block just to double-check.

Modifié par Lord Thing, 22 mars 2010 - 11:07 .


#5
Craig Graff

Craig Graff
  • Members
  • 608 messages
IsFollower is true for the player.

#6
Malcroix

Malcroix
  • Members
  • 360 messages

Craig Graff wrote...

IsFollower is true for the player.


Then this is a mistake in the original script, which is in all probability causing the bug.

Will try to correct this.

#7
Malcroix

Malcroix
  • Members
  • 360 messages

Lord Thing wrote...

You can also try putting an:

if (IsPlayer(oCreature))
{
     nSound = SS_EXPLORE_SELECT_NEUTRAL;
}



after the end of the 'if (IsFollower(oCreature))' block just to double-check.


I'd rather just replace IsFollower with !IsPlayer (none but party members can be selected, right?)

or add:
 
if (IsFollower(oCreature) && !IsPlayer(oCreature))

Problem is, soundset_h does not HAVE an IsPlayer function.

After doing this, I'm now getting a "no right bracket on expression" error in line 233 of soundset_h when compiling rules_core. I don't see any missing brackets, so the trouble is probably with the undefined function.

Modifié par Malcroix, 22 mars 2010 - 07:58 .


#8
Craig Graff

Craig Graff
  • Members
  • 608 messages
I think you want IsHero, not IsPlayer.