Aller au contenu

Photo

Creating a new object


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

#1
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

When NPCs are created by encounters they are free to walk away. When NPCs are created by scripting, they are not able to walk away. NPCs created by function "CreateObject()" does not walk. 

 

How to make NPCs created by "CreateObject()" walk like NPCs created by encounters?



#2
Proleric

Proleric
  • Members
  • 2 356 messages
Are you using the same NPC template for both the encounter and the script?

By walking, do you mean walk waypoints, ambient animation or simply combat movement?

If walk waypoints, check that the creature tag (as specified in CreateObject, if any, or else the template) matches the waypoints. It definitely works.
  • WhiteTiger aime ceci

#3
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Are you using the same NPC template for both the encounter and the script?

By walking, do you mean walk waypoints, ambient animation or simply combat movement?

If walk waypoints, check that the creature tag (as specified in CreateObject, if any, or else the template) matches the waypoints. It definitely works.

 

Yes, I am sure that I am using both template for the encounter and the script. 

[...] By walking, do you mean walk waypoints? No. I mean the normal random walk onheartbeat (not in combat)

 

The npc just does not walk  :(

 

 

 

-edited

 

This is like when you create a creature using DM client. the creature stays stopped



#4
Proleric

Proleric
  • Members
  • 2 356 messages
Ah, I understand.

For scripted and placed creatures, ambient animations will only play if the spawn condition NW_FLAG_AMBIENT_ANIMATIONS is set. However, the Lexicon tells us that "these animations will play automatically for encounter creatures".

You could set the local integer X2_L_SPAWN_USE_AMBIENT on the creature template to force these animations in all cases.

That switch tells the standard spawn script to do this:

SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);

  • Rolo Kipp et WhiteTiger aiment ceci

#5
WhiteTiger

WhiteTiger
  • Members
  • 479 messages
 

Ah, I understand.

For scripted and placed creatures, ambient animations will only play if the spawn condition NW_FLAG_AMBIENT_ANIMATIONS is set. However, the Lexicon tells us that "these animations will play automatically for encounter creatures".

You could set the local integer X2_L_SPAWN_USE_AMBIENT on the creature template to force these animations in all cases.

That switch tells the standard spawn script to do this:
 

SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS);

 

 

 

Had not worked =(

 

I tried this...

 

   object oMonster = CreateObject(OBJECT_TYPE_CREATURE, "creature038", lLoc, TRUE);
    DelayCommand(2.0, SetLocalInt(oMonster, "X2_L_SPAWN_USE_AMBIENT", TRUE));
 
 
And after that I tried this on nw_c2_default9 (onspawn)
 
    if(GetTag(OBJECT_SELF) == "creature_038_TAG")
    {
        SetLocalInt(OBJECT_SELF, "X2_L_SPAWN_USE_AMBIENT", TRUE);
 
        //After I tried to set NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS to false
        //SetSpawnInCondition(NW_FLAG_IMMOBILE_AMBIENT_ANIMATIONS, FALSE);
    }

 

help me  :(

 



#6
Proleric

Proleric
  • Members
  • 2 356 messages
I tested this... it works for me:

Creature template > Advanced Tab > Variables > X2_L_SPAWN_USE_AMBIENT > 1 > Add

This is assuming you're using the default Bioware AI scripts, of course.

If you need to set it by script, remove the delay. Setting local variables immediately after CreateObject works fine (contrary to a popular myth). In this case, it's essential, because you want to set the switch before the OnSpawn script, which runs almost immediately after the script in which you CreateObject.

With the switch set, OnSpawn will do this:
 
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
I quoted the wrong spawn in condition above, apologies.
  • Rolo Kipp et WhiteTiger aiment ceci

#7
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I tested this... it works for me:

Creature template > Advanced Tab > Variables > X2_L_SPAWN_USE_AMBIENT > 1 > Add

This is assuming you're using the default Bioware AI scripts, of course.

If you need to set it by script, remove the delay. Setting local variables immediately after CreateObject works fine (contrary to a popular myth). In this case, it's essential, because you want to set the switch before the OnSpawn script, which runs almost immediately after the script in which you CreateObject.

With the switch set, OnSpawn will do this:
 

SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
I quoted the wrong spawn in condition above, apologies.

 

 

Yes, I'm using default nw scripts.

 

I just tested now...   Not worked =/
 
I tried to use the procedure you said  Creature template > Advanced Tab > Variables > X2_L_SPAWN_USE_AMBIENT > 1 > Add and had no effect on my creature



#8
kalbaern

kalbaern
  • Members
  • 824 messages

Make a custom OnSpawn script to test in a few select NPCs using this:

 

 

 

#include "x0_i0_anims"
void main()
{
SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
SetListeningPatterns();
//WalkWayPoints();
}

 

You can also just overwrite "nw_c2_default9" for a test instead. You can restore the original version by simply deleting the custom one.

 

I commented out "WalkWayPoints();" as its wasteful to use if the NPCs do not stand a post or walk a route. I have a seperate version with it uncommented out that I use for NPCs with actual walk points.



#9
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Make a custom OnSpawn script to test in a few select NPCs using this:

 

 

 

 

You can also just overwrite "nw_c2_default9" for a test instead. You can restore the original version by simply deleting the custom one.

 

I commented out "WalkWayPoints();" as its wasteful to use if the NPCs do not stand a post or walk a route. I have a seperate version with it uncommented out that I use for NPCs with actual walk points.

 

I have a bad... That does not work too =/

 

I think you guys does not understand properly the problem. I would like to make the creature move randomly onheartbeat. do the problem is onheartbeat script?



#10
kalbaern

kalbaern
  • Members
  • 824 messages

You said you were using Bioware scripts. If they are unmodified, then what I posted will work. The Bioware heartbeat scripts require you enable the AI variables either in the OnSpawn event or set as Proleric discribed. Perhaps you have modified versions. If the Bioware scripts show up in the module list when you open your script editor, they would be suspect.

 

If your module is experiencing lag, the "X2" scripts given to a new creature are prone to failure. This is because you are first firing one script that merely fires the original Bioware defaults. For some folks, especially if testing while in the toolset, these scripts fail. Make a script template using the scripts in the standard bandit and try that (along with my OnSpawn) as a test.

Heres the list of Events and scripts you should use.

 

OnBlocked - nw_c2_defaulte

OnCombatRoundEnd - nw_c2_default3

OnConversation - nw_c2_default4

OnDamaged - nw_c2_default6

OnDeath - nw_c2_default7

OnDisturbed - nw_c2_default8

OnHeartbeat - nw_c2_default1

OnPerception - nw_c2_default2

OnPhysicalAttacked - nw_c2_default5

OnRested - nw_c2_defaulta (you can leave this event blank if creature resting is not desired)

OnSpawn - nw_c2_default9 (either set the variable as Proleric explained or use my script in place of the default)

OnSpellCastAt - nw_c2_defaultb

OnUserDefined - nw_c2_defaultd (the Bioware default here is a null script so the event field can be left empty for any creature actually calling it)

 

If you are using NESS to spawn creatures, make certain that it isn't adding different AIs to your creatures.



#11
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I am with all Bioware standard scripts and I did exactly what you said. I created a onspawn script with the following code:

#include "x0_i0_anims"
void main()
{
SetSpawnInCondition(NW_FLAG_SHOUT_ATTACK_MY_TARGET);
SetSpawnInCondition(NW_FLAG_AMBIENT_ANIMATIONS);
SetListeningPatterns();
//WalkWayPoints();
}

Both ways, not worked. Creating NPC by function "CreateObject()" or creating by DM does not work, npc does not walk.

 

Have you tested it?



#12
Proleric

Proleric
  • Members
  • 2 356 messages
I tested it using the Bioware onspawn. It works for me.

Are you sure you don't have a local version of any AI scripts?

What event is creating your objects? What's the script?
  • WhiteTiger aime ceci

#13
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

I tested it using the Bioware onspawn. It works for me.

Are you sure you don't have a local version of any AI scripts?

 

 

Yes, I'm sure about that. 

 

 

"What event is creating your objects? What's the script?

 

OnHeartBeat is used to create my creature. the script is object oMonster = CreateObject(OBJECT_TYPE_CREATURE, "creature038", lLoc, TRUE);

 

--edited

 

after I give high AI (SetAILevel(oMonster, AI_...HIGH)



#14
Proleric

Proleric
  • Members
  • 2 356 messages
Which object's OnHeartBeat?

Might help to post the full script.

#15
WhiteTiger

WhiteTiger
  • Members
  • 479 messages

Which object's OnHeartBeat?

Might help to post the full script.

 

Is OnAreaHeartBeat... I just do some checks and start CreateObject(); nothing more else, and even creating the creature with the DM palette, it does not move automatically. 



#16
kalbaern

kalbaern
  • Members
  • 824 messages

Creating creatures as a DM, still needs a PC in the area for animations to work normally. Add the creatures to an encounter. If they work there, they should work whether created by a DM or script ... so long as there is a player on the map. Bioware AIs will go dormant normally (unless modified) if there is no Player present or you enable waypoints and have the NPC patrol a route or something.