-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/1.18.2' into 1.19.x
- Loading branch information
Showing
9 changed files
with
2,032 additions
and
2,007 deletions.
There are no files selected for viewing
343 changes: 173 additions & 170 deletions
343
src/main/java/pokecube/api/entity/pokemob/moves/PokemobMoveStats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,170 +1,173 @@ | ||
package pokecube.api.entity.pokemob.moves; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.collect.Sets; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import pokecube.api.data.abilities.Ability; | ||
import pokecube.api.entity.pokemob.IPokemob; | ||
import pokecube.api.moves.MoveEntry; | ||
import pokecube.api.moves.utils.IMoveConstants; | ||
import pokecube.api.moves.utils.MoveApplication; | ||
import pokecube.core.network.pokemobs.PacketSyncNewMoves; | ||
|
||
public class PokemobMoveStats | ||
{ | ||
|
||
private static final PokemobMoveStats defaults = new PokemobMoveStats(); | ||
private static final Set<String> IGNORE = Sets.newHashSet(); | ||
static | ||
{ | ||
PokemobMoveStats.IGNORE.add("moves"); | ||
PokemobMoveStats.IGNORE.add("g_z_moves"); | ||
PokemobMoveStats.IGNORE.add("newMoves"); | ||
PokemobMoveStats.IGNORE.add("num"); | ||
PokemobMoveStats.IGNORE.add("exp"); | ||
} | ||
|
||
public Entity infatuateTarget; | ||
|
||
// Timers used for various move types. | ||
public int TOXIC_COUNTER = 0; | ||
public int ROLLOUTCOUNTER = 0; | ||
public int FURYCUTTERCOUNTER = 0; | ||
public int DEFENSECURLCOUNTER = 0; | ||
|
||
public boolean Exploding = false; | ||
public int boomState = -1; | ||
|
||
public int SPECIALCOUNTER = 0; | ||
/** Used for cooldown of crit chance moves */ | ||
public int SPECIALTYPE = 0; | ||
|
||
/** Used for moves such as bide/counter/mirror coat */ | ||
public int PHYSICALDAMAGETAKENCOUNTER = 0; | ||
public int SPECIALDAMAGETAKENCOUNTER = 0; | ||
|
||
/** Number of times detect, protect or similar has worked. */ | ||
public int BLOCKCOUNTER = 0; | ||
public int blockTimer = 0; | ||
public boolean blocked = false; | ||
|
||
public boolean biding = false; | ||
|
||
public float substituteHP = 0; | ||
|
||
public int changes = IMoveConstants.CHANGE_NONE; | ||
|
||
/** | ||
* Time when this creeper was last in an active state (Messed up code here, | ||
* probably causes creeper animation to go weird) | ||
*/ | ||
public int lastActiveTime; | ||
|
||
/** | ||
* The amount of time since the creeper was close enough to the player to | ||
* ignite | ||
*/ | ||
public int timeSinceIgnited; | ||
public int fuseTime = 30; | ||
|
||
/** The Previous lvl, used to determine which moves to try to learn. */ | ||
public int oldLevel = 0; | ||
|
||
/** The array of moves. */ | ||
public String[] moves = new String[4]; | ||
/** The array of moves. */ | ||
public String[] g_z_moves = new String[4]; | ||
/** Moves it is trying to learn. */ | ||
public List<String> newMoves = Lists.newArrayList(); | ||
/** Index of new move to learn from newMoves. */ | ||
public int num = 0; | ||
/** The last move we used. */ | ||
public String lastMove; | ||
/** Storing exp in here as well. */ | ||
public int exp = 0; | ||
/** Cache of currently selected move */ | ||
public MoveEntry selectedMove; | ||
/** The moves we are currently using */ | ||
public List<MoveApplication> movesInProgress = Lists.newArrayList(); | ||
public boolean targettingSelf = false; | ||
/** | ||
* This is the ability to apply in battle, out of battle it will be reset to | ||
* whatever the mob's normal ability was. | ||
*/ | ||
public Ability battleAbility = null; | ||
|
||
// Index in battle of targetted ally, owner is always last in the battle, | ||
// even if not in battle | ||
public int allyIndex = 0; | ||
// Index in battle of targetted enemy. | ||
public int enemyIndex = 0; | ||
|
||
public LivingEntity targetEnemy = null; | ||
public LivingEntity targetAlly = null; | ||
|
||
public void reset() | ||
{ | ||
for (final Field f : this.getClass().getFields()) try | ||
{ | ||
if (!PokemobMoveStats.IGNORE.contains(f.getName())) f.set(this, f.get(PokemobMoveStats.defaults)); | ||
} | ||
catch (final Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void checkMovesInProgress(IPokemob user) | ||
{ | ||
targettingSelf = false; | ||
movesInProgress.removeIf(s -> s.isFinished()); | ||
for (var move : movesInProgress) | ||
{ | ||
if (move.getTarget() == user.getEntity()) | ||
{ | ||
targettingSelf = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public void addMoveInProgress(IPokemob user, MoveApplication application) | ||
{ | ||
this.targettingSelf |= application.getTarget() == user.getEntity(); | ||
this.movesInProgress.add(application); | ||
} | ||
|
||
public boolean addPendingMove(String move, IPokemob notify) | ||
{ | ||
if (move == null) return false; | ||
if (newMoves.contains(move)) return false; | ||
newMoves.add(move); | ||
newMoves.sort(null); | ||
if (notify != null) PacketSyncNewMoves.sendUpdatePacket(notify); | ||
return true; | ||
} | ||
|
||
public void removePendingMove(String move) | ||
{ | ||
this.newMoves.remove(move); | ||
} | ||
|
||
public boolean hasLearningMove() | ||
{ | ||
return !this.newMoves.isEmpty(); | ||
} | ||
|
||
public String getLearningMove() | ||
{ | ||
if (this.newMoves.isEmpty()) return null; | ||
if (this.num < 0) this.num = this.newMoves.size() - 1; | ||
this.num = this.num % this.newMoves.size(); | ||
return newMoves.get(this.num); | ||
} | ||
} | ||
package pokecube.api.entity.pokemob.moves; | ||
|
||
import java.lang.reflect.Field; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import com.google.common.collect.Lists; | ||
import com.google.common.collect.Sets; | ||
|
||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import pokecube.api.data.abilities.Ability; | ||
import pokecube.api.entity.pokemob.IPokemob; | ||
import pokecube.api.moves.MoveEntry; | ||
import pokecube.api.moves.utils.IMoveConstants; | ||
import pokecube.api.moves.utils.MoveApplication; | ||
import pokecube.core.network.pokemobs.PacketSyncNewMoves; | ||
|
||
public class PokemobMoveStats | ||
{ | ||
|
||
private static final PokemobMoveStats defaults = new PokemobMoveStats(); | ||
private static final Set<String> IGNORE = Sets.newHashSet(); | ||
static | ||
{ | ||
PokemobMoveStats.IGNORE.add("moves"); | ||
PokemobMoveStats.IGNORE.add("g_z_moves"); | ||
PokemobMoveStats.IGNORE.add("newMoves"); | ||
PokemobMoveStats.IGNORE.add("num"); | ||
PokemobMoveStats.IGNORE.add("exp"); | ||
} | ||
|
||
public Entity infatuateTarget; | ||
|
||
// Timers used for various move types. | ||
public int TOXIC_COUNTER = 0; | ||
public int ROLLOUTCOUNTER = 0; | ||
public int FURYCUTTERCOUNTER = 0; | ||
public int DEFENSECURLCOUNTER = 0; | ||
|
||
public boolean Exploding = false; | ||
public int boomState = -1; | ||
|
||
public int SPECIALCOUNTER = 0; | ||
/** Used for cooldown of crit chance moves */ | ||
public int SPECIALTYPE = 0; | ||
|
||
/** Used for moves such as bide/counter/mirror coat */ | ||
public int PHYSICALDAMAGETAKENCOUNTER = 0; | ||
public int SPECIALDAMAGETAKENCOUNTER = 0; | ||
|
||
/** Number of times detect, protect or similar has worked. */ | ||
public int BLOCKCOUNTER = 0; | ||
public int blockTimer = 0; | ||
public boolean blocked = false; | ||
|
||
public boolean biding = false; | ||
|
||
public float substituteHP = 0; | ||
|
||
public int changes = IMoveConstants.CHANGE_NONE; | ||
|
||
/** | ||
* Time when this creeper was last in an active state (Messed up code here, | ||
* probably causes creeper animation to go weird) | ||
*/ | ||
public int lastActiveTime; | ||
|
||
/** | ||
* The amount of time since the creeper was close enough to the player to | ||
* ignite | ||
*/ | ||
public int timeSinceIgnited; | ||
public int fuseTime = 30; | ||
|
||
/** The Previous lvl, used to determine which moves to try to learn. */ | ||
public int oldLevel = 0; | ||
|
||
/** The array of moves. */ | ||
public String[] moves = new String[4]; | ||
/** The array of moves. */ | ||
public String[] g_z_moves = new String[4]; | ||
/** Moves it is trying to learn. */ | ||
public List<String> newMoves = Lists.newArrayList(); | ||
/** Index of new move to learn from newMoves. */ | ||
public int num = 0; | ||
/** The last move we used. */ | ||
public String lastMove; | ||
/** Storing exp in here as well. */ | ||
public int exp = 0; | ||
/** Cache of currently selected move */ | ||
public MoveEntry selectedMove; | ||
/** The moves we are currently using */ | ||
public List<MoveApplication> movesInProgress = Lists.newArrayList(); | ||
public boolean targettingSelf = false; | ||
/** | ||
* This is the ability to apply in battle, out of battle it will be reset to | ||
* whatever the mob's normal ability was. | ||
*/ | ||
public Ability battleAbility = null; | ||
|
||
// Index in battle of targetted ally, owner is always last in the battle, | ||
// even if not in battle | ||
public int allyIndex = 0; | ||
// Index in battle of targetted enemy. | ||
public int enemyIndex = 0; | ||
|
||
public LivingEntity targetEnemy = null; | ||
public LivingEntity targetAlly = null; | ||
|
||
// Moves for the transformed mob | ||
public String[] transformedMoves = moves; | ||
|
||
public void reset() | ||
{ | ||
for (final Field f : this.getClass().getFields()) try | ||
{ | ||
if (!PokemobMoveStats.IGNORE.contains(f.getName())) f.set(this, f.get(PokemobMoveStats.defaults)); | ||
} | ||
catch (final Exception e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
public void checkMovesInProgress(IPokemob user) | ||
{ | ||
targettingSelf = false; | ||
movesInProgress.removeIf(s -> s.isFinished()); | ||
for (var move : movesInProgress) | ||
{ | ||
if (move.getTarget() == user.getEntity()) | ||
{ | ||
targettingSelf = true; | ||
break; | ||
} | ||
} | ||
} | ||
|
||
public void addMoveInProgress(IPokemob user, MoveApplication application) | ||
{ | ||
this.targettingSelf |= application.getTarget() == user.getEntity(); | ||
this.movesInProgress.add(application); | ||
} | ||
|
||
public boolean addPendingMove(String move, IPokemob notify) | ||
{ | ||
if (move == null) return false; | ||
if (newMoves.contains(move)) return false; | ||
newMoves.add(move); | ||
newMoves.sort(null); | ||
if (notify != null) PacketSyncNewMoves.sendUpdatePacket(notify); | ||
return true; | ||
} | ||
|
||
public void removePendingMove(String move) | ||
{ | ||
this.newMoves.remove(move); | ||
} | ||
|
||
public boolean hasLearningMove() | ||
{ | ||
return !this.newMoves.isEmpty(); | ||
} | ||
|
||
public String getLearningMove() | ||
{ | ||
if (this.newMoves.isEmpty()) return null; | ||
if (this.num < 0) this.num = this.newMoves.size() - 1; | ||
this.num = this.num % this.newMoves.size(); | ||
return newMoves.get(this.num); | ||
} | ||
} |
Oops, something went wrong.