Upload from upload_mods.ps1
This commit is contained in:
104
Scripts/MinEvents/NPCs/MinEventActionChangeWeaponRebirth.cs
Normal file
104
Scripts/MinEvents/NPCs/MinEventActionChangeWeaponRebirth.cs
Normal file
@@ -0,0 +1,104 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionChangeWeaponRebirth : MinEventActionRemoveBuff
|
||||
{
|
||||
private string itemName = "";
|
||||
private string jointName = "";
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
var theEntity = _params.Self as EntityNPCRebirth;
|
||||
|
||||
int i = 0;
|
||||
|
||||
Transform transform = theEntity.RootTransform.FindInChilds(theEntity.GetRightHandTransformName(), true);
|
||||
|
||||
float currentX = transform.localPosition.x;
|
||||
float currentY = transform.localPosition.y;
|
||||
float currentZ = transform.localPosition.z;
|
||||
|
||||
float newX = 0;
|
||||
float newY = 0;
|
||||
float newZ = 0;
|
||||
|
||||
//Log.Out("TRANSFORM Local Position X: " + transform.localPosition.x);
|
||||
//Log.Out("TRANSFORM Local Position Y: " + transform.localPosition.y);
|
||||
//Log.Out("TRANSFORM Local Position Z: " + transform.localPosition.z);
|
||||
//Log.Out("TRANSFORM GameObject Name: " + transform.gameObject.name);
|
||||
|
||||
foreach (string text in itemName.Split(new char[]
|
||||
{
|
||||
','
|
||||
}))
|
||||
{
|
||||
ItemStack itemStack = ItemStack.FromString(text.Trim());
|
||||
|
||||
var forId = ItemClass.GetForId(itemStack.itemValue.type);
|
||||
|
||||
if (forId.HasQuality)
|
||||
{
|
||||
itemStack.itemValue = new ItemValue(itemStack.itemValue.type, 1, 6);
|
||||
}
|
||||
else
|
||||
{
|
||||
itemStack.count = forId.Stacknumber.Value;
|
||||
}
|
||||
|
||||
//Log.Out("Item Name: " + text.Trim());
|
||||
if (i == 0)
|
||||
{
|
||||
Transform transform2 = theEntity.RootTransform.FindInChilds(jointName, true);
|
||||
|
||||
newX = transform2.localPosition.x;
|
||||
newX = transform2.localPosition.y;
|
||||
newX = transform2.localPosition.z;
|
||||
|
||||
newX = newX - currentX;
|
||||
newY = newY - currentY;
|
||||
newZ = newZ - currentZ;
|
||||
|
||||
//Log.Out("Joint Name: " + jointName);
|
||||
theEntity.rightHandTransformName = jointName;
|
||||
theEntity.emodel.SetInRightHand(transform2);
|
||||
|
||||
//Log.Out("TRANSFORM2 Local Position X: " + transform2.localPosition.x);
|
||||
//Log.Out("TRANSFORM2 Local Position Y: " + transform2.localPosition.y);
|
||||
//Log.Out("TRANSFORM2 Local Position Z: " + transform2.localPosition.z);
|
||||
//Log.Out("TRANSFORM2 GameObject Name: " + transform2.gameObject.name);
|
||||
}
|
||||
|
||||
theEntity.inventory.SetItem(i, itemStack);
|
||||
i++;
|
||||
}
|
||||
|
||||
theEntity.inventory.ForceHoldingItemUpdate();
|
||||
|
||||
//Log.Out("NEW TRANSFORM NAME: " + theEntity.GetRightHandTransformName());
|
||||
}
|
||||
|
||||
public override bool ParseXmlAttribute(XAttribute _attribute)
|
||||
{
|
||||
var flag = base.ParseXmlAttribute(_attribute);
|
||||
if (flag) return true;
|
||||
var name = _attribute.Name;
|
||||
|
||||
if (name == null)
|
||||
{
|
||||
return flag;
|
||||
}
|
||||
else if (name == "itemName")
|
||||
{
|
||||
itemName = _attribute.Value;
|
||||
return true;
|
||||
}
|
||||
else if (name == "jointName")
|
||||
{
|
||||
jointName = _attribute.Value;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user