Upload from upload_mods.ps1
This commit is contained in:
129
Scripts/MinEvents/MinEventActionRagdollRebirth.cs
Normal file
129
Scripts/MinEvents/MinEventActionRagdollRebirth.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System.Globalization;
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionRagdollRebirth : MinEventActionTargetedBase
|
||||
{
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute START");
|
||||
DamageResponse dmResponse = DamageResponse.New(false);
|
||||
dmResponse.StunDuration = this.duration;
|
||||
dmResponse.Strength = (int)this.force;
|
||||
if (this.cvarRef && this.targets.Count > 0)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 1");
|
||||
dmResponse.StunDuration = this.targets[0].Buffs.GetCustomVar(this.refCvarName, 0f);
|
||||
}
|
||||
Vector3 vector = _params.StartPosition;
|
||||
if (vector.y == 0f)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 2");
|
||||
vector = _params.Self.position;
|
||||
}
|
||||
for (int i = 0; i < this.targets.Count; i++)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute i: " + i);
|
||||
EntityAlive entityAlive = this.targets[i];
|
||||
|
||||
if (entityAlive != null)
|
||||
{
|
||||
bool shouldAttack = RebirthUtilities.VerifyFactionStanding(_params.Self, entityAlive);
|
||||
|
||||
if (!shouldAttack)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (var text in excludeTags.Split(','))
|
||||
{
|
||||
if (entityAlive.HasAnyTags(FastTags<TagGroup.Global>.Parse(text)))
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute entity cannot be ragdolled: " + entityAlive.EntityClass.entityClassName);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (entityAlive.emodel.IsRagdollActive)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (entityAlive.AttachedToEntity != null)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 3");
|
||||
entityAlive.Detach();
|
||||
}
|
||||
Vector3 vector2 = entityAlive.position - vector;
|
||||
if (this.scaleY == 0f)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 4");
|
||||
vector2.y = 0f;
|
||||
dmResponse.Source = new DamageSource(EnumDamageSource.External, EnumDamageTypes.Bashing, vector2.normalized);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 5");
|
||||
vector2.y = _params.Self.GetLookVector().y * this.scaleY;
|
||||
float num = this.force;
|
||||
if (this.massScale > 0f)
|
||||
{
|
||||
//Log.Out("MinEventActionRagdollRebirth-Execute 6");
|
||||
num *= EntityClass.list[entityAlive.entityClass].MassKg * this.massScale;
|
||||
}
|
||||
dmResponse.Source = new DamageSource(EnumDamageSource.External, EnumDamageTypes.Falling, vector2.normalized * num);
|
||||
}
|
||||
entityAlive.DoRagdoll(dmResponse);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
bool flag = base.ParseXmlAttribute(_attribute);
|
||||
if (!flag)
|
||||
{
|
||||
string localName = _attribute.Name.LocalName;
|
||||
if (localName == "duration")
|
||||
{
|
||||
if (_attribute.Value.StartsWith("@"))
|
||||
{
|
||||
this.cvarRef = true;
|
||||
this.refCvarName = _attribute.Value.Substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.duration = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (localName == "force")
|
||||
{
|
||||
this.force = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
|
||||
return true;
|
||||
}
|
||||
if (localName == "massScale")
|
||||
{
|
||||
this.massScale = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
|
||||
return true;
|
||||
}
|
||||
if (localName == "scaleY")
|
||||
{
|
||||
this.scaleY = StringParsers.ParseFloat(_attribute.Value, 0, -1, NumberStyles.Any);
|
||||
return true;
|
||||
}
|
||||
if (localName == "excludetags")
|
||||
{
|
||||
this.excludeTags = _attribute.Value;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return flag;
|
||||
}
|
||||
|
||||
private float duration = 2.5f;
|
||||
private bool cvarRef;
|
||||
private string refCvarName = string.Empty;
|
||||
private float force;
|
||||
private float scaleY;
|
||||
private float massScale;
|
||||
private string excludeTags = "";
|
||||
}
|
||||
Reference in New Issue
Block a user