示例#1
0
    public override void Execute(MinEventParams _params)
    {
        Debug.Log("Executing Random Loot");
        EntityAliveSDX entity = _params.Self as EntityAliveSDX;

        // Only EntityAliveSDX
        if (entity == null)
        {
            return;
        }

        GameRandom _random = GameManager.Instance.World.GetGameRandom();
        float      Count   = 1f;

        if (entity.Buffs.HasCustomVar("spLootExperience"))
        {
            Count = entity.Buffs.GetCustomVar("spLootExperience");
        }

        Count = MathUtils.Clamp(Count, 1, 5);
        int MaxCount = (int)Math.Round(Count);

        // Loot group
        if (this.lootgroup.Length > 0)
        {
            Debug.Log("Generating Items : " + MaxCount);
            for (int x = 0; x < MaxCount; x++)
            {
                ItemStack item = LootContainer.GetRewardItem(lootgroup, Count);
                Debug.Log("Adding Item: " + item.ToString());
                entity.lootContainer.AddItem(item);
            }
        }
    }