Search in sources :

Example 1 with ICombatCapability

use of jackiecrazy.wardance.capability.resources.ICombatCapability in project WarDance by Jackiecrazy.

the class MovementUtils method attemptDodge.

public static boolean attemptDodge(LivingEntity elb, int side) {
    /*
        stepping around logic:
        known: sidestep distance is 5, distance to mob is x
        acquire angle theta via cosine rule
        use theta to find the angle of other angles
        add said angle to yaw
        twiddle till it works :v
         */
    ICombatCapability itsc = CombatData.getCap(elb);
    if (!CombatConfig.dodge)
        return false;
    if (!itsc.isCombatMode() && (!WarCompat.elenaiDodge || itsc.getStaggerTime() == 0))
        return false;
    if (itsc.getRollTime() == 0) {
        // 
        if (side == 99)
            return attemptSlide(elb);
        itsc.setRollTime(CombatConfig.rollCooldown);
        // Entity target = GeneralUtils.raytraceEntity(elb.world, elb, 32);
        // float adjustment = 0;
        // if (target != null) {
        // float distsq = (float) (elb.getDistanceSq(target));
        // float toacos = (distsq + distsq - 36) / (2 * distsq);//magic number wee
        // float acos=(float) Math.acos(toacos);
        // adjustment = GeneralUtils.deg(acos) / 2f;
        // }
        double x = 0, y = 0.3, z = 0;
        DodgeEvent.Direction d = DodgeEvent.Direction.FORWARD;
        switch(side) {
            case // left
            0:
                // +adjustment
                x = MathHelper.cos(GeneralUtils.rad(elb.yRot));
                z = MathHelper.sin(GeneralUtils.rad(elb.yRot));
                d = DodgeEvent.Direction.LEFT;
                break;
            case // back
            1:
                x = MathHelper.cos(GeneralUtils.rad(elb.yRot - 90));
                z = MathHelper.sin(GeneralUtils.rad(elb.yRot - 90));
                d = DodgeEvent.Direction.BACK;
                break;
            case // right
            2:
                // -adjustment
                x = MathHelper.cos(GeneralUtils.rad(elb.yRot - 180));
                z = MathHelper.sin(GeneralUtils.rad(elb.yRot - 180));
                d = DodgeEvent.Direction.RIGHT;
                break;
            case // forward
            3:
                x = MathHelper.cos(GeneralUtils.rad(elb.yRot + 90));
                z = MathHelper.sin(GeneralUtils.rad(elb.yRot + 90));
                d = DodgeEvent.Direction.FORWARD;
                break;
        }
        DodgeEvent e = new DodgeEvent(elb, d, 1.5);
        MinecraftForge.EVENT_BUS.post(e);
        if (e.isCanceled())
            return false;
        x *= e.getForce();
        z *= e.getForce();
        // NeedyLittleThings.setSize(elb, min, min);
        elb.push(x, y, z);
        elb.hurtMarked = true;
        // elb.motionX=x;
        // elb.motionY=y;
        // elb.motionZ=z;
        itsc.consumePosture(0);
        return true;
    }
    return false;
}
Also used : ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability) DodgeEvent(jackiecrazy.wardance.event.DodgeEvent)

Example 2 with ICombatCapability

use of jackiecrazy.wardance.capability.resources.ICombatCapability in project WarDance by Jackiecrazy.

the class CombatUtils method getAttackMight.

public static float getAttackMight(LivingEntity seme, LivingEntity uke) {
    ICombatCapability semeCap = CombatData.getCap(seme);
    final float magicScale = 1.722f;
    // magic numbers scale the modified formula to 0.2 per sword hit
    final float magicNumber = 781.25f;
    final float cooldownSq = semeCap.getCachedCooldown() * semeCap.getCachedCooldown();
    // +0.5 makes sure heavies don't scale forever, light ones are still puny
    final double period = 20.0D / (seme.getAttribute(Attributes.ATTACK_SPEED).getValue() + 0.5d);
    float might = cooldownSq * cooldownSq * magicScale * (float) period * (float) period / magicNumber;
    // combo bonus
    might *= (1f + (semeCap.getRank() / 20f));
    float weakness = 1;
    if (seme.hasEffect(Effects.WEAKNESS))
        for (int foo = 0; foo < seme.getEffect(Effects.WEAKNESS).getAmplifier() + 1; foo++) {
            weakness *= GeneralConfig.weakness;
        }
    // weakness malus
    might *= weakness;
    AttackMightEvent ame = new AttackMightEvent(seme, uke, might);
    MinecraftForge.EVENT_BUS.post(ame);
    return ame.getQuantity();
}
Also used : ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability) AttackMightEvent(jackiecrazy.wardance.event.AttackMightEvent)

Example 3 with ICombatCapability

use of jackiecrazy.wardance.capability.resources.ICombatCapability in project WarDance by Jackiecrazy.

the class Kick method additionally.

protected void additionally(LivingEntity caster, LivingEntity target) {
    final ICombatCapability cap = CombatData.getCap(target);
    if (cap.getStaggerTime() > 0) {
        cap.setStaggerTime(cap.getStaggerTime() + CombatConfig.staggerDuration);
        cap.setStaggerCount(cap.getStaggerCount() + CombatConfig.staggerHits);
    }
}
Also used : ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability)

Example 4 with ICombatCapability

use of jackiecrazy.wardance.capability.resources.ICombatCapability in project WarDance by Jackiecrazy.

the class SkillEventHandler method sleep.

@SubscribeEvent(priority = EventPriority.LOWEST)
public static void sleep(PlayerWakeUpEvent e) {
    boolean flag = !e.wakeImmediately() && (!e.updateWorld() || e.getPlayer().level.isDay());
    if ((flag || ResourceConfig.sleepingHealsDecay == ResourceConfig.ThirdOption.FORCED) && e.getEntityLiving().isEffectiveAi()) {
        if (ResourceConfig.sleepingHealsDecay != ResourceConfig.ThirdOption.FALSE) {
            final ICombatCapability cap = CombatData.getCap(e.getPlayer());
            float res = cap.getResolve() + 1;
            cap.addFatigue(-res * cap.getTrueMaxPosture() / 10);
            cap.addBurnout(-res * cap.getTrueMaxSpirit() / 10);
            cap.addWounding(-res * GeneralUtils.getMaxHealthBeforeWounding(e.getPlayer()) / 10);
            cap.setResolve(0);
        }
        ISkillCapability isc = CasterData.getCap(e.getEntityLiving());
        for (Skill s : isc.getEquippedSkills()) {
            if (s != null)
                isc.changeSkillState(s, Skill.STATE.INACTIVE);
        }
    }
}
Also used : ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability) Skill(jackiecrazy.wardance.skill.Skill) ISkillCapability(jackiecrazy.wardance.capability.skill.ISkillCapability) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Example 5 with ICombatCapability

use of jackiecrazy.wardance.capability.resources.ICombatCapability in project WarDance by Jackiecrazy.

the class Keybinds method handleInputEvent.

@SubscribeEvent(priority = EventPriority.HIGHEST)
public static void handleInputEvent(InputEvent event) {
    Minecraft mc = Minecraft.getInstance();
    if (mc.player == null)
        return;
    ICombatCapability itsc = CombatData.getCap(mc.player);
    if (COMBAT.getKeyConflictContext().isActive() && COMBAT.consumeClick()) {
        ClientEvents.combatTicks = Integer.MAX_VALUE;
        mc.player.displayClientMessage(new TranslationTextComponent("wardance.combat." + (itsc.isCombatMode() ? "off" : "on")), true);
        CombatChannel.INSTANCE.sendToServer(new CombatModePacket());
    }
    if (CAST.getKeyConflictContext().isActive() && CAST.consumeClick() && mc.player.isAlive()) {
        mc.setScreen(new SkillCastScreen(CasterData.getCap(mc.player).getEquippedSkills()));
    }
    if (SELECT.getKeyConflictContext().isActive() && SELECT.consumeClick() && mc.player.isAlive()) {
        mc.setScreen(new SkillSelectionScreen());
    }
    if (BINDCAST.getKeyConflictContext().isActive() && BINDCAST.consumeClick() && mc.player.isAlive()) {
        CombatChannel.INSTANCE.sendToServer(new EvokeSkillPacket());
    }
}
Also used : CombatModePacket(jackiecrazy.wardance.networking.CombatModePacket) SkillCastScreen(jackiecrazy.wardance.client.screen.SkillCastScreen) ICombatCapability(jackiecrazy.wardance.capability.resources.ICombatCapability) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) SkillSelectionScreen(jackiecrazy.wardance.client.screen.SkillSelectionScreen) EvokeSkillPacket(jackiecrazy.wardance.networking.EvokeSkillPacket) Minecraft(net.minecraft.client.Minecraft) SubscribeEvent(net.minecraftforge.eventbus.api.SubscribeEvent)

Aggregations

ICombatCapability (jackiecrazy.wardance.capability.resources.ICombatCapability)22 SubscribeEvent (net.minecraftforge.eventbus.api.SubscribeEvent)13 LivingEntity (net.minecraft.entity.LivingEntity)7 Minecraft (net.minecraft.client.Minecraft)6 ItemStack (net.minecraft.item.ItemStack)6 PlayerEntity (net.minecraft.entity.player.PlayerEntity)5 CombatDamageSource (jackiecrazy.wardance.api.CombatDamageSource)3 ISkillCapability (jackiecrazy.wardance.capability.skill.ISkillCapability)3 Skill (jackiecrazy.wardance.skill.Skill)3 StealthUtils (jackiecrazy.wardance.utils.StealthUtils)3 Entity (net.minecraft.entity.Entity)3 DodgeEvent (jackiecrazy.wardance.event.DodgeEvent)2 ProjectileParryEvent (jackiecrazy.wardance.event.ProjectileParryEvent)2 CombatUtils (jackiecrazy.wardance.utils.CombatUtils)2 MatrixStack (com.mojang.blaze3d.matrix.MatrixStack)1 Pair (com.mojang.datafixers.util.Pair)1 ICombatItemCapability (jackiecrazy.wardance.capability.weaponry.ICombatItemCapability)1 SkillCastScreen (jackiecrazy.wardance.client.screen.SkillCastScreen)1 SkillSelectionScreen (jackiecrazy.wardance.client.screen.SkillSelectionScreen)1 FearEntity (jackiecrazy.wardance.entity.FearEntity)1