is there something like a GetDamageReceived?

Post » Tue May 17, 2011 7:43 am

i want to make chance to knockdown/knockout depend on damage dealt by a weapon. is there a way to tell how much damage is dealt/received? before and after DT, and before and after critical hit? thanks
User avatar
natalie mccormick
 
Posts: 3415
Joined: Fri Aug 18, 2006 8:36 am

Post » Tue May 17, 2011 8:35 am

I'd play with something like this:

int lasthealthint damageBegin Onhit  set damage to lasthealth - getav health  set lasthealth to getav health  if damage > 0     if GetLastHitCritical        [...Critical hit...]     endif        endifendbegin OnMagicEffectHit REHE  set lasthealth to getav healthend


The Onhit block keeps track of the damage done, the other one resets the variable on healing

Getting the DT is no problem (getav damagethreshold), but it may be hard to determine how much (if any) of the DT was bypassed.
User avatar
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Tue May 17, 2011 2:54 am

Thanks again JOG. I'll try that.

EDIT: btw, if you dont mind explaining a bit how it works? i dont quite understand how the first two lines on the OnHit block work to get the damage done. If i understood scripting better that'll reduce my posts bugging people like you for help :D
User avatar
Margarita Diaz
 
Posts: 3511
Joined: Sun Aug 12, 2007 2:01 pm

Post » Tue May 17, 2011 10:59 am

Thanks again JOG. I'll try that.

EDIT: btw, if you dont mind explaining a bit how it works? i dont quite understand how the first two lines on the OnHit block work to get the damage done. If i understood scripting better that'll reduce my posts bugging people like you for help :D


http://geck.gamesas.com/index.php/GetActorValue returns the current health, in the variable lasthealth the script stored the current health the last time that block was called. The difference of those two values is the damage done.

Of course this script needs to run on the damaged actor, you can't really do this as a scripted effect on the weapon.
User avatar
Matt Bigelow
 
Posts: 3350
Joined: Sun Sep 30, 2007 6:36 pm

Post » Tue May 17, 2011 11:29 am

can it be done like this:
Begin ScriptEffectStart        set damage to lasthealth - getav health        set lasthealth to getav health               if damage > 0                      if GetLastHitCritical                         [...Critical hit...]                      endif                     endifEnd


...to make it a scripted effect on the weapon that runs on hit? i saw a script that put a scripted effect on a weapon as an effect.
User avatar
Lexy Dick
 
Posts: 3459
Joined: Mon Feb 12, 2007 12:15 pm

Post » Tue May 17, 2011 8:03 am

BUMP for more questions

in addition to the above question, it seems that in NV, weapons that damage fatigue (like the boxing gloves) use
the OnHit block for its effect.

1) if both can be used, which (OnHit or ScriptEffectStart) is better to use?
2)can i still use JOG's suggested script to get the damage if i use OnHit (which seems better to me only because of GetOwnerLastTarget)?
3) can a similar formula be used to determine which body part is hit or is there a better way (since GetHitLocation wont work on OnHit)?
User avatar
Samantha Mitchell
 
Posts: 3459
Joined: Mon Nov 13, 2006 8:33 pm

Post » Tue May 17, 2011 12:39 pm

begin OnMagicEffectHit REHE  set lasthealth to getav healthend

The Onhit block keeps track of the damage done, the other one resets the variable on healing

Does this cover all types of healing, such as stimpak, food, sleeping, doctor conversation, regen perk?
User avatar
sunny lovett
 
Posts: 3388
Joined: Thu Dec 07, 2006 4:59 am

Post » Tue May 17, 2011 12:17 pm

BUMP for more questions

in addition to the above question, it seems that in NV, weapons that damage fatigue (like the boxing gloves) use
the OnHit block for its effect.


They do?
Yep... Interesting... That's a new feature to NV, but I think it can be quite useful...

1) if both can be used, which (OnHit or ScriptEffectStart) is better to use?


ScriptEffectStart runs in the script effect's script. To use it you have to create the script, effect, enchantment and weapon, the weapon uses the enchantment, the enchantment the effect, and the effect the script.

OnHit runs in the weapon's script. To use it, you just have to make the script and use it for the weapon.
Aside from being much easier to use, OnHit also has the advantage that you can easily get the weapon's owner, if the weapon is used by a NPC.

2)can i still use JOG's suggested script to get the damage?


Yes, but no matter whether you use OnAdd or a Script Effect, there still is the problem that the weapon only keeps track of one attacked NPC. If you attack another it will compare his health with the health of the NPC you've hit last time.

If you want to use this on the weapon and keep track of everyone's health, you'd best use tokens (instead of setting the variable, give the NPC dummy items: 1 item per hitpoint, just make the items unplayable so the player can't loot them)


3) can a similar formula be used to determine which body part is hit or is there a better way (since GetHitLocation wont work on OnHit)?


I think it's worth trying if GetHitLocation is available in a Weapon's OnHit script, the statement that it doesn't work is back from FO3 and primarly refers to the NPC's onHit Script. GetHitLocation doesn't work on the weapon's object effect either, so this might be another reason for extending OnHit's functionality in NV.
User avatar
Pants
 
Posts: 3440
Joined: Tue Jun 27, 2006 4:34 am

Post » Tue May 17, 2011 2:14 am

Does this cover all types of healing, such as stimpak, food, sleeping, doctor conversation, regen perk?


OnMagicEffectHit REHE covers the REstore HEalth effect, no matter whether trough potions, spells, abilities or effects. But for it would be better to set a variable in the OnMagicEffectHit block, and then wait in the gamemode block until HasMagicEffect REHE == 0. This will fail when the NPC has another, permanent restore health effect of course.

Sleep and doctor conversations are different things. I'm not sure whether NPCs actually regenerate while sleeping or how to keep track of it, but well, that's the fun of modding, trial and error until it seems to work but has oversights that become obvious to everyone as soon as you release the mod. I don't want to cut Norbingel out of all that fun by thoroughly testing and reconsidering everything ;)



@Norbingel:
Another thing you could check is the timing, maybe the weapon's onHit runs *before* damage is done. ScriptEffectStart definitely runs *after* damage was done, so this might be an elegant way to calculate the damage done by that attack, without keeping track of the taget's health or worrying about healing items.
User avatar
Kayla Keizer
 
Posts: 3357
Joined: Tue Dec 12, 2006 4:31 pm


Return to Fallout: New Vegas