Jump to content

Block mod


BobLennart

Recommended Posts

  • Replies 42
  • Created
  • Last Reply

Top Posters In This Topic

I may have found a better solution that would allow realistic blocking. If I use active magic effects on all humanoid actors to create the effect, not only can I correctly access GetRelativeAngle, I can much more easily place riders for race, weapon, etc. and fine-tune the effects of different weapons, e.g. torch blocks swords but not dragonfire.

 

When I have some time today and tomorrow I'll try this out.

Link to comment
Share on other sites

Wow that's alot of conditions from Darkfoot. Certainly way beyond my original request. I may be so bold as to change my original request just slightly.
So here are my contitions:

1. Blocking stops all incoming damage from any melee attack or non-magical projectile.

2.Dragons, trolls, bears and werewolves still do some damage. (And maybe some other big-ass creature but i can't think of any other atm.)

Link to comment
Share on other sites

Sorry guys, I am currently swamped with supporting my Pirates mod.

 

There is actually another thread on the same thing (100% block) in the mod authors sub forum and it is getting quite complicated. Crazy. You'd think this would be simple.

 

Anyway, I suggest giving the player a perk with ModIncomingDamage. And the conditions for the attacker can make use of GetLineOfSight, or GetRelativeAngle (I only know the numbers for getting behind the target though). And IsBlocking obviously.

 

The same perk could have ModAttackDamage and set it to zero when the target isblocking == 1 and GetLOS / GetRelativeAngle.

 

Then give the player the perk. It would make blocking 100% for the player and for enemies who are blocking the player, but not for enemies blocking other actors, unless they have the perk.

 

Conditions for dragons etc. are optional.

 

@newzilla: you can do all those condition checks with perks. you do not need magic effects.

Link to comment
Share on other sites

I found that it would be a grueling task to add the perk to every actor, as you cannot add perks dynamically. Instead, the effect right now is a constant spell/script that undoes any damage taken while blocking correctly. This isn't quite perfect, as the damage is still applied, but it does still allow for staggering, which is realistic, I guess. If someone knows a script function to replicate ModIncomingDamage, by all means let me know.
Link to comment
Share on other sites

Woohoo! I got something working!

 

Basically, when you start blocking the script saves your health. Whenever you take damage while blocking, as long as you meet the conditions (none at this point), your health is returned to the saved value. Unfortunately, Bethesda neglected to make it easy to access the needed values, so I had to create a somewhat convoluted system that tracks your max health and current percentage of that.

 

Here's the code, if anyone's interested.

Scriptname AbPerfectBlockingEffectScript extends ActiveMagicEffect
{removes all incoming damage under certain conditions}

Keyword Property ShieldKey auto
float savedHealthMax
float savedHealthPercentage

Function ActivatePerfectBlocking()
	debug.messagebox("Resetting health!")
	debug.messagebox("Saved max is " + savedHealthMax + ", saved percentage is " + savedHealthPercentage)
	
	float percentageDifference = savedHealthPercentage - GetCasterActor().GetAVPercentage("Health")
	debug.messagebox("Percent difference is (" + savedHealthPercentage + " - " + GetCasterActor().GetAVPercentage("Health") + " = " + percentageDifference + ")")
	float amountToRestore = percentageDifference * savedHealthMax
	debug.messagebox("Amount to restore is (" + percentageDifference + " * " + savedHealthMax + " = " + amountToRestore + ")")
	
	GetCasterActor().RestoreAV("Health", amountToRestore)
	debug.messagebox("New health is " + GetCasterActor().GetAV("Health"))
EndFunction

Event OnInit()
	debug.notification("Perfect Blocking script initialized.")
EndEvent

Event OnEffectStart(Actor akTarget, Actor akCaster)
	debug.notification("Effect started, setting health")
	savedHealthPercentage = akCaster.GetAV("Health")
	savedHealthMax = akCaster.GetAV("Health") / savedHealthPercentage
EndEvent

Event OnObjectEquipped(Form akBaseObject, ObjectReference akReference)
	debug.notification("Object equipped, setting health")
	savedHealthPercentage = GetCasterActor().GetAV("Health")
	savedHealthMax = (GetCasterActor().GetAV("Health") / savedHealthPercentage) * 100
EndEvent

Event OnHit(ObjectReference akAggressor, Form akSource, Projectile akProjectile, bool abPowerAttack, bool abSneakAttack, bool abBashAttack, bool abHitBlocked)

	if abHitBlocked
		debug.messagebox("Hit, but blocked. Activating Perfect Blocking...")
		ActivatePerfectBlocking()
	else
		debug.messagebox("Hit and not blocked! Resetting health...")
		savedHealthPercentage = GetCasterActor().GetAVPercentage("Health")
		debug.messagebox("New health percentage is " + savedHealthPercentage + ", or " + savedHealthPercentage * savedHealthMax)
	endif
	
EndEvent

Next up I'll be implementing some of the conditions we need.

Link to comment
Share on other sites

Just want to point out that all i ever cared about, as in wanted a mod to do, is that when i, the dragonborn, present my shield or weapon to block an incoming strike i will recieve no damage... Exactly how and why it happends bothers me little.
(If you didn't notice, i posted a comment before presenting all of the 2 conditions for my mod request.)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...