public static void set_spell_flag(GameObject obj, Co8SpellFlag flag) { var val = (Co8SpellFlag)obj.GetInt(SPELL_FLAGS_BASE); obj.SetInt(SPELL_FLAGS_BASE, (int)(val | flag)); obj.GetInt(SPELL_FLAGS_BASE); }
public static GameObject find_spell_obj_with_flag(GameObject target, int item, Co8SpellFlag flag) { GameObject ret = null; var item_holder = GameSystems.MapObject.CreateObject(ITEM_HOLDER, target.GetLocation()); var prot_item = target.FindItemByProto(item); while (prot_item != null && ret == null) { if (is_spell_flag_set(prot_item, flag)) { ret = prot_item; } prot_item.ClearItemFlag(ItemFlag.NO_DROP); item_holder.GetItem(prot_item); prot_item = target.FindItemByProto(item); } prot_item = item_holder.FindItemByProto(item); while (prot_item != null) { target.GetItem(prot_item); prot_item.SetItemFlag(ItemFlag.NO_DROP); prot_item = item_holder.FindItemByProto(item); } item_holder.Destroy(); return(ret); }
public static void unset_spell_flag(GameObject obj, Co8SpellFlag flag) { var val = get_spell_flags(obj); if ((val & flag) != 0) { val &= ~flag; obj.SetInt32(SPELL_FLAGS_BASE, (int)val); } }
public static bool destroy_spell_obj_with_flag(GameObject target, int proto_id, Co8SpellFlag flag) { var ret = false; var item_holder = GameSystems.MapObject.CreateObject(ITEM_HOLDER, target.GetLocation()); var prot_item = target.FindItemByProto(proto_id); while (prot_item != null) { if (is_spell_flag_set(prot_item, flag)) { ret = true; Logger.Info("found it"); break; } prot_item.ClearItemFlag(ItemFlag.NO_DROP); item_holder.GetItem(prot_item); prot_item = target.FindItemByProto(proto_id); } if (ret) { prot_item.Destroy(); Logger.Info("destroyed it"); } prot_item = item_holder.FindItemByProto(proto_id); while (prot_item != null) { target.GetItem(prot_item); if (proto_id == 6400) { prot_item.SetItemFlag(ItemFlag.NO_DROP); } prot_item = item_holder.FindItemByProto(proto_id); } item_holder.Destroy(); return(ret); }
public static bool is_spell_flag_set(GameObject obj, Co8SpellFlag flag) { return((obj.GetInt(SPELL_FLAGS_BASE) & (int)flag) != 0); }