On forum: 09/20/2009
NPC spawned by script automatically grouping even from across the map|
I'm having a problem with my NPCs.
Let's say that I spawn 2 neutral stalkers by script, very far from each other (they can't see or hear each other).
When I shoot one of them, the other "knows" it and come right to where I shot the first one to investigate, like he heard the shot or the screams...
How can I make it so that NPCs from the same faction aren't affected by this? Let's say that every time I spawn an NPC, I want him to be in a "new" group so when I kill him, no other NPC will care about it, even if they are from the same faction.
I did some testing with the all.spawn and Tolik, Wolf and Petruha to check if the variables "g_squad" & "g_group" had an impact on this matter and it did.
So I tried to manipulate those variables with "packet_utils.script" right after spawning a NPC but it doesn't do anything.
I change Tolik's "g_squad" to 1 and "g_group" to 127 so when I spawned 2 NPC, at least one of them should be "grouping" with him, but no cigar
Here's the code I'm running:
f_pos = db.actor:position()
f_level_id = db.actor:level_vertex_id()
f_game_id = db.actor:game_vertex_id()
f_npc = sim:create("esc_stalker_respawn_1", f_pos, f_level_id, f_game_id)
f_object_data = packet_utils.get_object_data(f_npc)
if (p_group == true) then
f_object_data.g_squad = 1
f_object_data.g_group = 127
f_object_data.g_squad = 2
f_object_data.g_group = 30
Please note that when changing the variables for Tolik, Wolf and Petruha directly in "all.spawn", it does what it's supposed to do, meaning I can kill Wolf without the rookie camp moving a finger, as they are'nt in the same group anymore. Same with Tolik and Petruha, who are in the same group by default.
I also tried to alter their logic by setting a [danger@ignore] section. It kinda worked, as the stalkers from afar didn't get up to rush me, but once I got close to them, they were already enemies, because they "knew" I killed one guy from their faction 2km away...
I also looke into some script to find how NPC would detect a danger and eventually enter combat mode but didn't get far.
Thanks for any input on this.