diff --git a/Data/Scripts/aschar.as b/Data/Scripts/aschar.as index 420b3b1df..e292997bb 100644 --- a/Data/Scripts/aschar.as +++ b/Data/Scripts/aschar.as @@ -7333,8 +7333,14 @@ void HandleAnimationCombatEvent(const string &in event, const vec3 &in world_pos range_extend += mix(1.0, 0.0, game_difficulty); range_extend *= mix(1.0, 0.0, game_difficulty); } - - if(event == "attackblocked" || distance(this_mo.position, target_pos) < (_attack_range + range_extend) * this_mo.rigged_object().GetCharScale()) { + + float range_adjust = 0.0f; + + if(attack_getter.HasRangeAdjust()){ + range_adjust = attack_getter.GetRangeAdjust(); + } + + if(event == "attackblocked" || distance(this_mo.position, target_pos) < (_attack_range + range_extend + range_adjust) * this_mo.rigged_object().GetCharScale()) { vec3 facing = this_mo.GetFacing(); vec3 facing_right = vec3(-facing.z, facing.y, facing.x); vec3 dir = normalize(target_pos - this_mo.position); diff --git a/Source/Asset/Asset/attacks.cpp b/Source/Asset/Asset/attacks.cpp index ae7ff4d55..995d9614e 100644 --- a/Source/Asset/Asset/attacks.cpp +++ b/Source/Asset/Asset/attacks.cpp @@ -62,6 +62,8 @@ void Attack::clear() { damage[1] = 0.0f; force[0] = 0.0f; force[1] = 0.0f; + has_range_adjust = false; + range_adjust = 0.0f; unblockable = false; flesh_unblockable = false; mobile = false; @@ -191,6 +193,12 @@ int Attack::Load(const string& path, uint32_t load_flags) { } else if (field_str == "force") { GetRange(field, "val", "min", "max", force[0], force[1]); } + else if (field_str == "range_adjust") + { + has_range_adjust = true; + field->QueryFloatAttribute("val", &range_adjust); + //GetRange(field, "val", "min", "max", range_adjust[0], range_adjust[1]); + } } } else { return kLoadErrorMissingFile; diff --git a/Source/Asset/Asset/attacks.h b/Source/Asset/Asset/attacks.h index a17e31f4e..2c2c70cb2 100644 --- a/Source/Asset/Asset/attacks.h +++ b/Source/Asset/Asset/attacks.h @@ -74,6 +74,8 @@ class Attack : public AssetInfo { float block_damage[2]; float damage[2]; float force[2]; + bool has_range_adjust; + float range_adjust; string materialevent; vec3 cut_plane; bool has_cut_plane; diff --git a/Source/Game/attackscript.cpp b/Source/Game/attackscript.cpp index d2fe5e21a..279756a57 100644 --- a/Source/Game/attackscript.cpp +++ b/Source/Game/attackscript.cpp @@ -138,6 +138,14 @@ float AttackScriptGetter::GetForce() { return attack_ref_.valid() ? RangedRandomFloat(attack_ref_->force[0], attack_ref_->force[1]) : 0.0f; } +bool AttackScriptGetter::HasRangeAdjust() { + return attack_ref_.valid() ? attack_ref_->has_range_adjust : false; +} + +float AttackScriptGetter::GetRangeAdjust() { + return attack_ref_.valid() ? attack_ref_->range_adjust : 0.0f; +} + std::string AttackScriptGetter::GetPath() { return path_; } @@ -188,6 +196,8 @@ void AttachAttackScriptGetter(ASContext *as_context) { as_context->RegisterObjectMethod("AttackScriptGetter", "float GetSharpDamage()", asMETHOD(AttackScriptGetter, GetSharpDamage), asCALL_THISCALL); as_context->RegisterObjectMethod("AttackScriptGetter", "float GetDamage()", asMETHOD(AttackScriptGetter, GetDamage), asCALL_THISCALL); as_context->RegisterObjectMethod("AttackScriptGetter", "float GetForce()", asMETHOD(AttackScriptGetter, GetForce), asCALL_THISCALL); + as_context->RegisterObjectMethod("AttackScriptGetter", "bool HasRangeAdjust()", asMETHOD(AttackScriptGetter, HasRangeAdjust), asCALL_THISCALL); + as_context->RegisterObjectMethod("AttackScriptGetter", "float GetRangeAdjust()", asMETHOD(AttackScriptGetter, GetRangeAdjust), asCALL_THISCALL); as_context->RegisterObjectMethod("AttackScriptGetter", "int GetMirrored()", asMETHOD(AttackScriptGetter, GetMirrored), asCALL_THISCALL); as_context->RegisterObjectMethod("AttackScriptGetter", "int GetMobile()", asMETHOD(AttackScriptGetter, GetMobile), asCALL_THISCALL); as_context->DocsCloseBrace(); diff --git a/Source/Game/attackscript.h b/Source/Game/attackscript.h index 2c14e9152..6c9b6c24c 100644 --- a/Source/Game/attackscript.h +++ b/Source/Game/attackscript.h @@ -49,6 +49,8 @@ class AttackScriptGetter { float GetSharpDamage(); float GetDamage(); float GetForce(); + bool HasRangeAdjust(); + float GetRangeAdjust(); std::string GetPath(); std::string GetSpecial(); int GetUnblockable();