LethalEncounter wrote:John Adams wrote:
For "packs" of NPCs (as I mentioned above) that move together - guards, enemy patrols, etc - could it be made easier to assign them a single script, and they just walk along together in formation based on their destination coords? Rather than give each and every NPC in formation movement commands...
I can see the need for group movement in the LUA code, but instead of adding a complex table to the database we handle it solely from the LUA scripts? IE instead of MovementLoopAddLocation(NPC, x, y, z, speed, delay), have a function called GroupMovementLoopAddLocation(Group Name, x, y, z, speed, delay). Group Name could be any string you wanted to describe the group and would make it a lot easier to keep track of rather than a group number. Have this function called from 1 script as many times as you would like for the locations. Then call a function called GroupMovementAddNPC(Group Name, NPC, x_offset, z_offset) for each NPC that comprises the group. The offsets would be the values added (or subtracted) from the x and z coords to keep them close to each other without overlapping.
So for the 'head' NPC's script:
Code: Select all
function spawn(NPC)
GroupMovementLoopAddLocation("Queen Island Guards", 22.19, -6.86, 183.95, 2, 5)
GroupMovementLoopAddLocation("Queen Island Guards", 30.76, -6.33, 196.28, 2, 5)
GroupMovementLoopAddLocation("Queen Island Guards", 20.70, -6.85, 206.43, 2, 5)
GroupMovementLoopAddLocation("Queen Island Guards", -.90, -5.47, 212.14, 2, 5)
GroupMovementLoopAddLocation("Queen Island Guards", 2.35, -4.73, 196.93, 2, 5)
GroupMovementAddNPC("Queen Island Guards", NPC, 0, 0)
end
For other NPCs in the same group:
Code: Select all
function spawn(NPC)
GroupMovementAddNPC("Queen Island Guards", NPC, 2, 2)
end
function spawn(NPC)
GroupMovementAddNPC("Queen Island Guards", NPC, -2, -2)
end
function spawn(NPC)
GroupMovementAddNPC("Queen Island Guards", NPC, 2, 0)
end
If someone has a better idea, let me know.