Exemplo n.º 1
0
    public static void CastSpell(this GameObject caster, int spellEnum, GameObject targetObj = null)
    {
        var spellClasses = new List <int>();
        var spellLevels  = new List <int>();

        if (!GameSystems.Spell.TryGetSpellEntry(spellEnum, out var spellEntry))
        {
            Logger.Warn("Trying to cast unknown spell: {0}", spellEnum);
            return;
        }

        SpellPacketBody spellPktBody = new SpellPacketBody();

        spellPktBody.spellEnum         = spellEnum;
        spellPktBody.spellEnumOriginal = spellEnum;
        spellPktBody.caster            = caster;
        if (!GameSystems.Spell.SpellKnownQueryGetData(caster, spellEnum, spellClasses, spellLevels))
        {
            return;
        }

        for (var i = 0; i < spellClasses.Count; i = ++i)
        {
            if (!GameSystems.Spell.spellCanCast(caster, spellEnum, spellClasses[i], spellLevels[i]))
            {
                continue;
            }

            spellPktBody.spellKnownSlotLevel = spellLevels[i];
            spellPktBody.spellClass          = spellClasses[i];
            GameSystems.Spell.SpellPacketSetCasterLevel(spellPktBody);

            var pickArgs = new PickerArgs();
            GameSystems.Spell.PickerArgsFromSpellEntry(spellEntry, pickArgs, caster, spellPktBody.casterLevel);
            pickArgs.flagsTarget &= ~UiPickerFlagsTarget.Range;
            pickArgs.flagsTarget |= UiPickerFlagsTarget.LosNotRequired;

            LocAndOffsets?loc = null;
            if (pickArgs.modeTarget.IsBaseMode(UiPickerType.Single) ||
                pickArgs.modeTarget.IsBaseMode(UiPickerType.Multi))
            {
                loc = targetObj?.GetLocationFull();
                pickArgs.SetSingleTgt(targetObj);
            }
            else if (pickArgs.modeTarget.IsBaseMode(UiPickerType.Cone))
            {
                loc = targetObj?.GetLocationFull();
                if (loc.HasValue)
                {
                    pickArgs.SetConeTargets(loc.Value);
                }
            }
            else if (pickArgs.modeTarget.IsBaseMode(UiPickerType.Area))
            {
                if (spellEntry.spellRangeType == SpellRangeType.SRT_Personal)
                {
                    loc = caster.GetLocationFull();
                }
                else
                {
                    loc = targetObj?.GetLocationFull();
                }

                if (loc.HasValue)
                {
                    pickArgs.SetAreaTargets(loc.Value);
                }
            }
            else if (pickArgs.modeTarget.IsBaseMode(UiPickerType.Personal))
            {
                loc = caster.GetLocationFull();
                pickArgs.SetSingleTgt(caster);
            }

            GameSystems.Spell.ConfigSpellTargetting(pickArgs, spellPktBody);
            if (spellPktBody.Targets.Length > 0 && GameSystems.D20.Actions.TurnBasedStatusInit(caster))
            {
                GameSystems.D20.Actions.GlobD20ActnInit();
                GameSystems.D20.Actions.GlobD20ActnSetTypeAndData1(D20ActionType.CAST_SPELL, 0);
                GameSystems.D20.Actions.ActSeqCurSetSpellPacket(spellPktBody, true);
                var spellData = new D20SpellData(spellEnum, spellClasses[i], spellLevels[i]);
                GameSystems.D20.Actions.GlobD20ActnSetSpellData(spellData);
                GameSystems.D20.Actions.GlobD20ActnSetTarget(targetObj, loc);
                GameSystems.D20.Actions.ActionAddToSeq();
                GameSystems.D20.Actions.sequencePerform();
                break;
            }
        }
    }
Exemplo n.º 2
0
 public static bool ShowPicker(PickerArgs picker, object callbackArgs = null)
 {
     return(UiSystems.InGameSelect.ShowPicker(picker, callbackArgs));
 }
 public void ModifyPicker(int data1, PickerArgs pickerArgs)
 {
     throw new System.NotImplementedException();
 }