PDA

View Full Version : Recognizing a killing blow?



celtani
05-07-2013, 03:18 PM
I've been working on a script to calculate how the increasing flare chance with 1608 works. I was hoping I could do this simply by counting every swing and flare and sorting them by the number of swings since the last flare. Unfortunately, I'm having a problem gathering the data, because I'm pretty sure that swings that kill the enemy before the flare could activate shouldn't count. Is there a way to identify when an attack kills an enemy, short of watching GameObj.npc constantly? Could I parse the xml updates to look for enemies getting killed? Thanks in advance.

DaCapn
05-07-2013, 04:48 PM
I think Tillmen's loot script detects killing blows. You might look there.

wandererjs
05-07-2013, 05:13 PM
Lich already does this via infomon, which updates GameObj.npc when the target is dead, either by a) Simu sending XML stating it's dead, or b) lich seeing a number of death messages on the critter, which vary by critter and attack.

from infomon.lic



fix_gameobj_status = proc { |server_string|
# false positive: shudders with sporadic convulsions as pearlescent ripples envelop .*? body
if server_string =~ /^(?:The fire in the|With a surprised grunt, the|A sudden blue fire bursts over the hair of a|You hear a sound like a weeping child as a white glow separates itself from the|A low gurgling sound comes from deep within the chest of the|The|A) (?:<pushBold\/>)?<a.*?exist=["'](\-?[0-9]+)["'].*?>.*?<\/a>(?:<popBold\/>)?(?:'s)? (?:body as it rises, disappearing into the heavens|falls to the ground and dies|falls back into a heap and dies|body goes rigid and collapses to the ground, dead|body goes rigid and collapses to the floor, dead|slowly settles to the ground and begins to dissipate|falls to the ground motionless|body goes rigid and <pushBold\/><a.*?>\w+<\/a><popBold\/> eyes roll back into <pushBold\/><a.*?>\w+<\/a><popBold\/> head as <pushBold\/><a.*?>\w+<\/a><popBold\/> dies|growls one last time, and crumples to the ground in a heap|spins backwards and collapses dead|falls to the ground as the stillness of death overtakes <pushBold\/><a.*?>(?:him|her|it)<\/a><popBold\/>|crumples to the ground motionless|howls in agony one last time and dies|howls in agony while falling to the ground motionless|moans pitifully as <pushBold\/><a.*?>(?:he|she|it)<\/a><popBold\/> is released|careens to the ground and crumples in a heap|hisses one last time and dies|flutters its wings one last time and dies|slumps to the ground with a final snarl|horn dims as (?:his|her) lifeforce fades away|blinks in astonishment, then collapses in a motionless heap|collapses in a heap, its huge girth shaking the floor around it|goes limp and .*? falls over as the fire slowly fades from .*? eyes|eyes slowly fades|sputters violently, cascading flames all around as .*? collapses in a final fiery display|falls to the ground in a clattering, motionless heap|goes limp and .*? falls over as the fire slowly fades from .*? eyes|collapses to the ground and shudders once before finally going still|crumbles into a pile of rubble|shudders once before .*? finally goes still|as .*? falls slack against the ground|totters for a moment and then falls to the ground like a pillar, breaking into pieces that fly out in every direction|collapses into a pile of rubble|rumbles in agony as .*? teeters for a moment, then falls directly at you|twists and coils violently in .*? death throes, finally going still|twitches one final time before falling still upon the floor|, consuming .*? form in the space of a breath|screams one last time and dies|breathes .*? last gasp and dies|rolls over and dies|as .*? falls slack against the floor|collapses to the ground, emits a final squeal, and dies|cries out in pain one last time and dies|crumples to a heap on the ground and dies|collapses to the ground, emits a final sigh, and dies|crumples to the ground and dies|lets out a final caterwaul and dies|screams evilly one last time and goes still|gurgles eerily and collapses into a puddle of water|shudders, then topples to the ground|shudders one last time before lying still|violently for a moment, then goes still|grumbles in pain one last time before lying still|rumbles in agony and goes still|falls to the ground dead|collapses to the ground, emits a final bleat, and dies)[\.!]\r?\n?$/
npc_id = $1
if npc = GameObj.npcs.find { |obj| obj.id == npc_id }
npc.status = 'dead'
end
elsif server_string =~ /^A calm washes over <pushBold\/>(?:a|an|the) <a exist="(.*?)" noun=".*?">.*?<\/a><popBold\/>\.\r?\n?$/
npc_id = $1
if npc = GameObj.npcs.find { |obj| obj.id == npc_id }
npc.status = 'calm'
end
end
server_string
}



For your script I'd try some logic like:

[Note: this is logic, pseudo-code, not Ruby]

if I_swung && target.status == 'dead' and it_flared = "true" then: #it flared on this swing, so it's a valid datapoint
swings +=1
flares += 1
elsif I_swung && target.status == 'dead' and it_flared = 'false' then: #it died before flare could have activated
do stuff
elsif blahblah.

celtani
05-07-2013, 05:23 PM
Thanks, guys, these are both really helpful suggestions. I think I can do it like loot.lic by grabbing the target's id when parsing the swing and checking whether it's alive, then handling the logic much the way that wandererjs has suggested. If that doesn't work I'll try the monster regex for death messages.

Appreciate the help!