Aller au contenu

Photo

Problem using NW_FLAG_SPECIAL_CONVERSATION


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

#1
rjshae

rjshae
  • Members
  • 4 506 messages
I'm trying to get an NPC to generate a float string when he perceives the PC, so I spawn the NPC with the NW_FLAG_SPECIAL_CONVERSATION flag set to 1. The perception script seems to work okay, calling ActionStartConversation with the object set to itself. However, the floating string doesn't appear, even when I'm not calling nw_d2_gen_check for the condition. The conversation does work because it activates when I click on the NPC. Does anybody know why this isn't working?

Thanks.

#2
Lugaid of the Red Stripes

Lugaid of the Red Stripes
  • Members
  • 955 messages
Isn't the name of the conversation supposed to be set somewhere (as a local string)?

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
look at the on spawn script handler ( one of the numbered ones like on death, etc. )

the constant is dealt with inside that script, or you can just apply it there.

#4
rjshae

rjshae
  • Members
  • 4 506 messages
It only seems to be passing OBJECT_SELF to ActionStartConversation,but I'll take a look. Thank you.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Do you have to give the conversation to the NPC in the "conversation" field?

#6
rjshae

rjshae
  • Members
  • 4 506 messages
Yep, it has a string in the conversation field. The NPC converses just fine when I interact directly.

The interesting thing is that when I made a copy of nw_c2_default2 and replaced:

  ActionStartConversation(OBJECT_SELF);

with:

  SpeakOneLinerConversation();

it worked perfectly! The floater string appeared almost as soon as the PC was perceived. Hmm... :blink:

Well almost perfectly. It's using the NPC's tokens rather than the PC's. Guess I'll have to get by without the tokens.

Modifié par rjshae, 01 mai 2012 - 12:24 .


#7
kamal_

kamal_
  • Members
  • 5 259 messages
Interesting. I have some npc's I want doing barkstrings on perception, and some that I don't, but are anyway.

#8
MasterChanger

MasterChanger
  • Members
  • 686 messages

rjshae wrote...

I'm trying to get an NPC to generate a float string when he perceives the PC, so I spawn the NPC with the NW_FLAG_SPECIAL_CONVERSATION flag set to 1. The perception script seems to work okay, calling ActionStartConversation with the object set to itself. However, the floating string doesn't appear, even when I'm not calling nw_d2_gen_check for the condition. The conversation does work because it activates when I click on the NPC. Does anybody know why this isn't working?


The way one sets these flags is confusing. It is not by storing a local int called "NW_FLAG_SPECIAL_CONVERSATION" with value = 1.

Take a look at x0_i0_spawncond. I cannot remember how this traces back to the OnPerceive handler but I seem to recall that it does. This script is where the spawn-in condition constants and functions are defined.

Take a look at GetSpawnInCondition, which is called in the OnPerceive:

// Returns TRUE if the specified condition has been set on the
// caller, otherwise FALSE.
int GetSpawnInCondition(int nCondition)
{
    int nPlot = GetLocalInt(OBJECT_SELF, sSpawnCondVarname);
    if(nPlot & nCondition)
    {
        return TRUE;
    }
    return FALSE;
}


The variable name this checks is defined at the start of the script: "NW_GENERIC_MASTER". Then it checks whether the integer stored in this variable bit-wise contains the flag you are asking about. The value of these flags is set right below NW_GENERIC_MASTER.

So, if you want the creature to have a special combat conversation and no other spawn-in conditions, you set a variable called "NW_GENERIC_MASTER" = 0x00040000 (which the toolset converts automatically to 262144. If you wanted others, you'd add those to 262144.

I'm a little fuzzy on the bitwise math, but everything else here is pretty solid.

#9
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
It's bit based, the on spawn script sets the bit and translates what the toolset person who has no idea what bits are ( via a function in the onspawn script ). You should look for the on spawn script and see how it's setting things - you figured out what it's doing, but there is a system for getting those bits set up initially.

#10
robertharris

robertharris
  • Members
  • 9 messages
To give a creature certain spawn in behaviors, create an integer variable on the creature called NW_GENERIC_MASTER and set it equal to the sum of the desired behavior's decimal value (see below).  For example, if you want a creature that uses stealth (4) and fast buffing (67108864), set NW_GENERIC_MASTER equal to 67108868.  Using the Windows calculator to convert this variables value into binary, you can see that this value is actually just a set of switches for each behavior (67108868 = 100000000000000000000000100).

SPAWN IN BEHAVIOR                     HEXIDECIMAL       DECIMAL         EXAMPLE
-------------------------------------------------------------------------------
NW_FLAG_SPECIAL_CONVERSATION        = 0x00000001;       1               0
NW_FLAG_SHOUT_ATTACK_MY_TARGET      = 0x00000002;       2               0
NW_FLAG_STEALTH                     = 0x00000004;       4               1
NW_FLAG_SEARCH                      = 0x00000008;       8               0
NW_FLAG_SET_WARNINGS                = 0x00000010;       16              0
NW_FLAG_ESCAPE_RETURN               = 0x00000020;       32              0
NW_FLAG_ESCAPE_LEAVE                = 0x00000040;       64              0
NW_FLAG_TELEPORT_RETURN             = 0x00000080;       128             0
NW_FLAG_TELEPORT_LEAVE              = 0x00000100;       256             0
NW_FLAG_PERCIEVE_EVENT              = 0x00000200;       512             0
NW_FLAG_ATTACK_EVENT                = 0x00000400;       1024            0
NW_FLAG_DAMAGED_EVENT               = 0x00000800;       2048            0
NW_FLAG_SPELL_CAST_AT_EVENT         = 0x00001000;       4096            0
NW_FLAG_DISTURBED_EVENT             = 0x00002000;       8192            0
NW_FLAG_END_COMBAT_ROUND_EVENT      = 0x00004000;       16384           0
NW_FLAG_ON_DIALOGUE_EVENT           = 0x00008000;       32768           0
NW_FLAG_RESTED_EVENT                = 0x00010000;       65536           0
NW_FLAG_DEATH_EVENT                 = 0x00020000;       131072          0
NW_FLAG_SPECIAL_COMBAT_CONVERSATION = 0x00040000;       262144          0
NW_FLAG_AMBIENT_ANIMATIONS          = 0x00080000;       524288          0
NW_FLAG_HEARTBEAT_EVENT             = 0x00100000;       1048576         0
NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS = 0x00200000;       2097152         0
NW_FLAG_DAY_NIGHT_POSTING           = 0x00400000;       4194304         0
NW_FLAG_AMBIENT_ANIMATIONS_AVIAN    = 0x00800000;       8388608         0
NW_FLAG_APPEAR_SPAWN_IN_ANIMATION   = 0x01000000;       16777216        0
NW_FLAG_SLEEPING_AT_NIGHT           = 0x02000000;       33554432        0
NW_FLAG_FAST_BUFF_ENEMY             = 0x04000000;       67108864        1


#11
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
The on spawn handler ( nw_c2_default9.nss ) has code like the following... ( it is adjusted to use my library but the default is the same basically with minor name changes. )

if (GetLocalInt(oCreature, "X2_L_SPAWN_USE_SEARCH") == TRUE) 
{
   SCSetSpawnInCondition(CSL_FLAG_SEARCH);
}

This abstracts back what is going on, from the more advanced methods the computer prefers, to something more convenient for end users. Pretty easy to adjust that script as well, think the specific constant would have to be added to the spawn script. Generally i try to set bits in script and not in the toolset, just because it's hard to read after you come back to it 6 months later. ( even though the first bit being set is always odd which is a nice short cut )

#12
rjshae

rjshae
  • Members
  • 4 506 messages

painofdungeoneternal wrote...

It's bit based, the on spawn script sets the bit and translates what the toolset person who has no idea what bits are ( via a function in the onspawn script ). You should look for the on spawn script and see how it's setting things - you figured out what it's doing, but there is a system for getting those bits set up initially.


Yes, that is what I am doing -- setting the special conversation flag by uncommenting an entry in the custom On Spawn script. That part is working okay because it is following the appropriate branch of the standard On Perceive script. I just wonder if there is a problem with the ActionStartConversation routine. I tried customizing it with the various options, but that didn't seem to help.

Modifié par rjshae, 01 mai 2012 - 07:30 .