Skip to content

Commit

Permalink
Small tweak to the speed
Browse files Browse the repository at this point in the history
  • Loading branch information
LyquidQrystal committed May 14, 2024
1 parent 03ed25d commit 8635adf
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package me.rufia.fightorflight;


import com.cobblemon.mod.common.Cobblemon;
import com.cobblemon.mod.common.api.types.ElementalType;
import com.cobblemon.mod.common.entity.pokemon.PokemonEntity;
import com.cobblemon.mod.common.pokemon.Pokemon;
Expand All @@ -12,6 +13,7 @@
import me.shedaniel.autoconfig.serializer.JanksonConfigSerializer;
import net.minecraft.core.particles.ParticleTypes;
import net.minecraft.server.level.ServerLevel;
import net.minecraft.util.Mth;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.entity.ai.goal.Goal;
Expand Down Expand Up @@ -71,22 +73,11 @@ public static void addPokemonGoal(PokemonEntity pokemonEntity) {
float maximum_movement_speed = CobblemonFightOrFlight.commonConfig().maximum_movement_speed;
float speed_limit= CobblemonFightOrFlight.commonConfig().speed_stat_limit;
float speed = pokemonEntity.getPokemon().getSpeed();
float speedMultiplier = minimum_movement_speed + (maximum_movement_speed - minimum_movement_speed) * speed/speed_limit;
float fleeSpeed = 1.5f * speedMultiplier;
float speedMultiplier = Mth.lerp(speed/speed_limit,minimum_movement_speed,maximum_movement_speed);

float fleeSpeed = 1.5f * speedMultiplier;
float pursuitSpeed = 1.2f * speedMultiplier;
/*
*
* boolean should_melee= shouldMelee(pokemonEntity);
if(should_melee){
goalAdder.accept(pokemonEntity, 3, new PokemonMeleeAttackGoal(pokemonEntity, pursuitSpeed, true));
}else{
goalAdder.accept(pokemonEntity,3,new PokemonRangedAttackGoal(pokemonEntity,1.0f,16));
}
*
*
* */

goalAdder.accept(pokemonEntity, 3, new PokemonMeleeAttackGoal(pokemonEntity, pursuitSpeed, true));
goalAdder.accept(pokemonEntity,3,new PokemonRangedAttackGoal(pokemonEntity,1.0f,16));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public class FightOrFlightCommonConfigModel implements ConfigData {
@Comment("The damage a pokemon would do on hit if it had 255 ATK or Sp.ATK.")
public float maximum_attack_damage = 7.0f;
@Comment("The movement speed multiplier of a pokemon if the Spe stat of this Pokemon is 0.")
public float minimum_movement_speed = 1.0f;
public float minimum_movement_speed = 1.1f;
@Comment("The movement speed multiplier of a pokemon if the Spe stat of this Pokemon reaches the value in the config.")
public float maximum_movement_speed = 2.0f;
@Comment("The speed stat required for a pokemon to reach the highest fleeing and pursuing speed.The default value(548) is the max speed stat of a lvl.100 Regieleki with a beneficial nature.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ public class PokemonMeleeAttackGoal extends MeleeAttackGoal {
public int ticksUntilNewAngerParticle = 0;

public int ticksUntilNewAngerCry = 0;
private final double speedModifier;

public PokemonMeleeAttackGoal(PathfinderMob mob, double speedModifier, boolean followingTargetEvenIfNotSeen) {
super(mob, speedModifier, followingTargetEvenIfNotSeen);
this.speedModifier=speedModifier;
}

public void tick() {
Expand All @@ -51,6 +53,8 @@ public void tick() {
if (!CobblemonFightOrFlight.commonConfig().do_pokemon_attack_in_battle) {
if (isTargetInBattle()) {
this.mob.getNavigation().setSpeedModifier(0);
}else{
this.mob.getNavigation().setSpeedModifier(this.speedModifier);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ public void tick() {
if (!bl) {
return;
}
float speedModifier = Math.max(0.1f, 1 - this.pokemonEntity.getSpeed() / CobblemonFightOrFlight.commonConfig().speed_stat_limit);
float f = (float) Math.sqrt(d) / this.attackRadius * speedModifier;
float attackSpeedModifier = Math.max(0.1f, 1 - this.pokemonEntity.getSpeed() / CobblemonFightOrFlight.commonConfig().speed_stat_limit);
float f = (float) Math.sqrt(d) / this.attackRadius * attackSpeedModifier;
//float g = Mth.clamp(f, 0.1F, 1.0F);
this.performRangedAttack(this.target);
((PokemonInterface) (Object) pokemonEntity).setAttackTime(0);
Expand Down

0 comments on commit 8635adf

Please sign in to comment.