public GameObject GetWeaponUsed()
 {
     if (!flags.HasFlag(D20CAF.TOUCH_ATTACK) || flags.HasFlag(D20CAF.THROWN_GRENADE))
     {
         return(weaponUsed);
     }
     return(null);
 }
    public static int DispatchProjectileDestroyed(this GameObject attacker, GameObject projectile,
                                                  D20CAF caf)
    {
        DispIoAttackBonus dispIo = DispIoAttackBonus.Default;

        dispIo.attackPacket.dispKey     = 1;
        dispIo.attackPacket.d20ActnType = D20ActionType.STANDARD_ATTACK;
        dispIo.attackPacket.attacker    = attacker;

        GameObject weapon;

        if (caf.HasFlag(D20CAF.SECONDARY_WEAPON))
        {
            weapon = GameSystems.Item.GetItemAtInvIdx(attacker, 204);
        }
        else
        {
            weapon = GameSystems.Item.GetItemAtInvIdx(attacker, 203);
        }

        if (weapon != null && weapon.type == ObjectType.weapon)
        {
            dispIo.attackPacket.weaponUsed = weapon;
        }

        dispIo.attackPacket.ammoItem = projectile;
        dispIo.attackPacket.flags    = caf;
        return(GameSystems.Stat.DispatchAttackBonus(attacker, null, ref dispIo, DispatcherType.ProjectileDestroyed,
                                                    0));
    }
    public GameObject GetAttackWeapon(GameObject obj, int attackCode, D20CAF flags)
    {
        if (flags.HasFlag(D20CAF.TOUCH_ATTACK) && !flags.HasFlag(D20CAF.THROWN_GRENADE))
        {
            return(null);
        }

        if (flags.HasFlag(D20CAF.SECONDARY_WEAPON))
        {
            return(GameSystems.Item.ItemWornAt(obj, EquipSlot.WeaponSecondary));
        }

        if (UsingSecondaryWeapon(obj, attackCode))
        {
            return(GameSystems.Item.ItemWornAt(obj, EquipSlot.WeaponSecondary));
        }

        if (attackCode > AttackPacket.ATTACK_CODE_NATURAL_ATTACK)
        {
            return(null);
        }

        return(GameSystems.Item.ItemWornAt(obj, EquipSlot.WeaponPrimary));
    }