Upload from upload_mods.ps1
This commit is contained in:
60
Scripts/MinEvents/NPCs/MinEventActionNPCGiveItemRebirth.cs
Normal file
60
Scripts/MinEvents/NPCs/MinEventActionNPCGiveItemRebirth.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using System.Xml.Linq;
|
||||
|
||||
public class MinEventActionNPCGiveItemRebirth : MinEventActionTargetedBase
|
||||
{
|
||||
private int numItems = 1;
|
||||
private string itemName = "";
|
||||
|
||||
public override void Execute(MinEventParams _params)
|
||||
{
|
||||
var myEntity = _params.Self as EntityAlive;
|
||||
if (myEntity == null)
|
||||
return;
|
||||
|
||||
if (myEntity.Buffs.HasBuff("FuriousRamsayNPCSilencer"))
|
||||
{
|
||||
EntityPlayerLocal player = myEntity.world.GetPrimaryPlayer();
|
||||
|
||||
var uiforPlayer = LocalPlayerUI.GetUIForPlayer(player as EntityPlayerLocal);
|
||||
var playerInventory = uiforPlayer.xui.PlayerInventory;
|
||||
if (playerInventory == null) return;
|
||||
|
||||
var item = ItemClass.GetItem(itemName);
|
||||
if (item == null)
|
||||
{
|
||||
//Log.Out("MinEventActionNPCGiveItemRebirth: Item Not Found: " + ID);
|
||||
return;
|
||||
}
|
||||
var itemStack = new ItemStack(item, numItems);
|
||||
if (!playerInventory.AddItem(itemStack, true))
|
||||
player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
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 == "numItems")
|
||||
{
|
||||
numItems = Int32.Parse(_attribute.Value);
|
||||
return true;
|
||||
}
|
||||
else if (name == "itemName")
|
||||
{
|
||||
itemName = _attribute.Value;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user