PDA

View Full Version : 4E ct npc atks parsed from powers



Paleotech
February 29th, 2016, 19:36
When you drop an NPC on to the 4E ct what function parses the atks lines?

In an NPC power card I can put +1 vs. AC in the 'Desc' field and it becomes (+1 vs. AC) in the ct atks lines.
But if I put anything after the AC and before the semicolon, something truncates it.
What function is truncating the extra text and putting that truncated value in the ct atks lines and attacks child of the NPCs ct DB?

Thanks!

Moon Wizard
February 29th, 2016, 20:46
The power descriptions should be entered exactly as described in the 4E Monster Manuals. The parsing code in the ruleset has been written based on this assumption.

Regards,
JPG

Paleotech
February 29th, 2016, 21:40
I've been able to trace the code coming out of the ct and found the function that string formats the atks lines using %(([%+%-]%d+) vs.? (%a*)%) for attacks and %(([d%+%-%d%s]*%d)%s?([%a,]*)%) for damage.

I understand that bit of code and I can trace from then on to rolling attacks and damage.

What I cannot trace is the jump from dropping an NPC on the ct and the difference in what is written in the powers Desc line and what shows up in the ct Atks lines. I understand you have a set string format you are using to encode that, what I am missing is the specific function that takes the string from powers Desc and puts it in the ct Atks line and what it does. If you could just point me to the function I am sure I can trace the rest and decode the string format.

Thanks!

Moon Wizard
February 29th, 2016, 21:56
It's an entire module of functions that picks apart the power descriptions using a simplistic natural language processing engine via a sort of state machine. It starts on line 378 of scripts/manager_combat2.lua in the 4E ruleset, which ends up calling an entire series of functions in scripts/manager_power.lua to parse the description into rolls/effects. After the call to PowerManager from CombatManager2, the reset of the loop in CombatManager2 converts the roll/effect data structures generated internally into a string for the CT lines.

It's much easier to just enter a creature power similar to the one you are trying to copy into the NPC prior to adding to the CT.

Regards,
JPG

Paleotech
February 29th, 2016, 22:12
Thank you! I've been running past that. Now I know why it's truncating...

I'm not trying to figure out how the 4E ruleset runs a game, I'm trying to figure out how it runs the code. I've traced through the logic pretty far and I know most of the paths from attack and damage to output. When I got to powers it was a bit more complicated, someone with a robot's grasp of logic made that code. But then, that's why I picked the 4E ruleset to trace, it seemed like the most complicated of the included rulesets.

Moon Wizard
February 29th, 2016, 23:03
I am the robot. ;)

JPG

Paleotech
February 29th, 2016, 23:08
LOL.. well domo arigato, that's some fine code you have there. It's been fun tracing, especially when I got to the powers.

damned
March 1st, 2016, 05:08
All hail the robot!