PDA

View Full Version : Automatically add NPC to combat tracker



alloowishus
April 6th, 2025, 18:57
I want to have an NPC added to the combat tracker automatically when a certain spell is cast.

So I outputted the contents of the "tCustom" data table from a random NPC which it is dragged into the combat tracker and I got this:

{ s'sTargetPath' = s'combattracker.list.id-00018'
, s'sRecordType' = s'npc'
, s'nodeRecord' = databasenode
= { npc.id-00438 }
, s'sClass' = s'npc'
, s'sRecord' = s'npc.id-00438'
, s'draginfo'
= dragdata
= { type = s'shortcut'
, desc = s'NPC: Ape'
, #slots = #1
, slot = #1
, string = s''
, num = #0
, diceexpr = {}
, shortcut = {npc:npc.id-00438}, asset = {, instance = }, custom = nil }
}

So how would I construct this tCustom data table manually? I assume that I need to manually create the "TargetPath" node, probably by getting the max node number in the combat tracker and adding 1? Also, how would I get the node of the NPC I want to add?

Thanks!

Moon Wizard
April 6th, 2025, 20:15
Where are you pulling that from? It seems like you're trying to inject in a place that's going to be hard to add to/from.

I would probably start with something similar to what the Encounters use:


CombatRecordManager.onRecordTypeEvent("npc", { sClass = "npc", nodeRecord = <databasenode of creature to add> });

You would just have to have it trigger in the code that "summons" the creature.

Regards,
JPG

alloowishus
April 7th, 2025, 03:45
Where are you pulling that from? It seems like you're trying to inject in a place that's going to be hard to add to/from.

I would probably start with something similar to what the Encounters use:


CombatRecordManager.onRecordTypeEvent("npc", { sClass = "npc", nodeRecord = <databasenode of creature to add> });

You would just have to have it trigger in the code that "summons" the creature.

Regards,
JPG

That's much easier, thank you!

alloowishus
April 7th, 2025, 04:31
Where are you pulling that from? It seems like you're trying to inject in a place that's going to be hard to add to/from.

I would probably start with something similar to what the Encounters use:


CombatRecordManager.onRecordTypeEvent("npc", { sClass = "npc", nodeRecord = <databasenode of creature to add> });

You would just have to have it trigger in the code that "summons" the creature.

Regards,
JPG

Ok, so based on the debug info, the NPC node I chose is this { npc.id-00438 }

So how do I get the node of the NPC based on the name? Thanks!

Moon Wizard
April 7th, 2025, 05:03
What is the type of the variable you are looking at? If it's a databasenode, you are done. If it's a string, then use DB.findNode(sPath).

Regards,
JPG

alloowishus
April 7th, 2025, 14:36
What is the type of the variable you are looking at? If it's a databasenode, you are done. If it's a string, then use DB.findNode(sPath).

Regards,
JPG

Basically I will make copies of NPCs and add "summon" to the end, so for instance "Wolf Summon". I want to be able to find the database node of this NPC based on its name and then pass to the function. Thanks.