71 lines
4.5 KiB
C#
71 lines
4.5 KiB
C#
class ItemActionMeleeSDX : ItemActionMelee
|
|
{
|
|
// This is a copy of the GetExecuteActionTarget() minus the EntityEnemy check on the line 32 (holdingEntity.IsBreakingBlocks)
|
|
public override WorldRayHitInfo GetExecuteActionTarget(ItemActionData _actionData)
|
|
{
|
|
ItemActionMelee.InventoryDataMelee inventoryDataMelee = (ItemActionMelee.InventoryDataMelee)_actionData;
|
|
EntityAlive holdingEntity = inventoryDataMelee.invData.holdingEntity;
|
|
inventoryDataMelee.ray = holdingEntity.GetLookRay();
|
|
if (holdingEntity.IsBreakingBlocks)
|
|
{
|
|
if (inventoryDataMelee.ray.direction.y < 0f)
|
|
{
|
|
inventoryDataMelee.ray.direction = new Vector3(inventoryDataMelee.ray.direction.x, 0f, inventoryDataMelee.ray.direction.z);
|
|
ItemActionMelee.InventoryDataMelee inventoryDataMelee2 = inventoryDataMelee;
|
|
inventoryDataMelee2.ray.origin = inventoryDataMelee2.ray.origin + new Vector3(0f, -0.7f, 0f);
|
|
}
|
|
}
|
|
else if (holdingEntity.GetAttackTarget() != null)
|
|
{
|
|
Vector3 direction = holdingEntity.GetAttackTargetHitPosition() - inventoryDataMelee.ray.origin;
|
|
inventoryDataMelee.ray = new Ray(inventoryDataMelee.ray.origin, direction);
|
|
}
|
|
ItemActionMelee.InventoryDataMelee inventoryDataMelee3 = inventoryDataMelee;
|
|
inventoryDataMelee3.ray.origin = inventoryDataMelee3.ray.origin - 0.15f * inventoryDataMelee.ray.direction;
|
|
int modelLayer = holdingEntity.GetModelLayer();
|
|
holdingEntity.SetModelLayer(2, false);
|
|
float distance = Utils.FastMax(this.Range, this.BlockRange) + 0.15f;
|
|
if (holdingEntity.IsBreakingBlocks)
|
|
{
|
|
Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, 1073807360, 128, 0.4f);
|
|
}
|
|
else
|
|
{
|
|
EntityAlive x = null;
|
|
int layerMask = -538767381;
|
|
if (Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, layerMask, 128, this.SphereRadius))
|
|
{
|
|
x = (ItemActionAttack.GetEntityFromHit(Voxel.voxelRayHitInfo) as EntityAlive);
|
|
}
|
|
if (x == null)
|
|
{
|
|
Voxel.Raycast(inventoryDataMelee.invData.world, inventoryDataMelee.ray, distance, -538488837, 128, this.SphereRadius);
|
|
}
|
|
}
|
|
holdingEntity.SetModelLayer(modelLayer, false);
|
|
return _actionData.GetUpdatedHitInfo();
|
|
}
|
|
|
|
/*public override void hitTheTarget(
|
|
ItemActionMelee.InventoryDataMelee _actionData,
|
|
WorldRayHitInfo hitInfo,
|
|
float damageScale)
|
|
{
|
|
EntityAlive holdingEntity = _actionData.invData.holdingEntity;
|
|
ItemValue itemValue = _actionData.invData.itemValue;
|
|
float _weaponCondition = 1f;
|
|
if (itemValue.MaxUseTimes > 0)
|
|
_weaponCondition = ((float)itemValue.MaxUseTimes - itemValue.UseTimes) / (float)itemValue.MaxUseTimes;
|
|
float _originalValue = Mathf.Clamp01(_actionData.invData.item.CritChance.Value * (holdingEntity.Stamina / holdingEntity.Stats.Stamina.Max));
|
|
float _criticalHitChanceOLD = EffectManager.GetValue(PassiveEffects.CriticalChance, itemValue, _originalValue, holdingEntity);
|
|
_actionData.attackDetails.WeaponTypeTag = ItemActionAttack.MeleeTag;
|
|
int _flags = 1;
|
|
if (this.bUseParticleHarvesting && (this.particleHarvestingCategory == null || this.particleHarvestingCategory == this.item.MadeOfMaterial.id))
|
|
_flags |= 4;
|
|
float _blockDamage = this.GetDamageBlock(itemValue, ItemActionAttack.GetBlockHit(_actionData.invData.world, hitInfo), holdingEntity, _actionData.indexInEntityOfAction) * damageScale;
|
|
float damageEntity = this.GetDamageEntity(itemValue, holdingEntity, _actionData.indexInEntityOfAction);
|
|
|
|
ItemActionAttack.Hit(hitInfo, holdingEntity.entityId, this.DamageType == EnumDamageTypes.None ? EnumDamageTypes.Bashing : this.DamageType, _blockDamage, damageEntity, holdingEntity.Stats.Stamina.ValuePercent, _weaponCondition, _criticalHitChanceOLD, ItemAction.GetDismemberChance((ItemActionData)_actionData, hitInfo), this.item.MadeOfMaterial.SurfaceCategory, this.damageMultiplier, this.getBuffActions((ItemActionData)_actionData), _actionData.attackDetails, _flags, this.ActionExp, this.ActionExpBonusMultiplier, (ItemActionAttack)this, this.ToolBonuses, _actionData.bHarvesting ? ItemActionAttack.EnumAttackMode.RealAndHarvesting : ItemActionAttack.EnumAttackMode.RealNoHarvesting);
|
|
GameUtils.HarvestOnAttack((ItemActionData)_actionData, this.ToolBonuses);
|
|
}*/
|
|
} |