chars, ...
This commit is contained in:
parent
eea23233f4
commit
3515fb1792
53 changed files with 688 additions and 543 deletions
|
@ -2,61 +2,21 @@ package game.entity.npc;
|
|||
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.item.RngLoot;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class CharacterInfo {
|
||||
public class CharacterInfo extends NpcInfo {
|
||||
public final boolean spawner;
|
||||
public final SpeciesInfo species;
|
||||
public final ClassInfo spclass;
|
||||
public final String name;
|
||||
public final String skin;
|
||||
public final String cape;
|
||||
public final int color1;
|
||||
public final int color2;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
|
||||
public CharacterInfo(SpeciesInfo species, ClassInfo spclass, String name, String skin, String cape, int color1, int color2, boolean spawner) {
|
||||
this.spawner = spawner; // ? SpeciesRegistry.CHARACTERS.size() : -1;
|
||||
public CharacterInfo(SpeciesInfo species, Enum type, String name, String skin, String cape, Alignment align, float height, int color1, int color2, boolean spawner) {
|
||||
super(type, name, skin, cape, align, height, (ItemStack[])null);
|
||||
this.spawner = spawner;
|
||||
this.species = species;
|
||||
this.spclass = spclass;
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.cape = cape;
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
SpeciesRegistry.SKINS.put(skin, species.renderer);
|
||||
if(!cape.isEmpty()) {
|
||||
if(!cape.isEmpty())
|
||||
SpeciesRegistry.CAPES.add(cape);
|
||||
}
|
||||
if(spclass != null)
|
||||
spclass.chars.add(this);
|
||||
// if(spawner)
|
||||
// SpeciesRegistry.CHARACTERS.add(this);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public ItemStack pickItem(int slot, Random rand) {
|
||||
WeightedList<RngLoot> list = this.items[slot];
|
||||
if(list.isEmpty()) {
|
||||
if(this.spclass != null) {
|
||||
list = this.spclass.getItems()[slot];
|
||||
}
|
||||
if(this.spclass == null || list.isEmpty()) {
|
||||
list = this.species.getItems()[slot];
|
||||
if(list.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
return list.pick(rand).getItem(rand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,31 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import game.collect.Lists;
|
||||
|
||||
import game.item.RngLoot;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class ClassInfo {
|
||||
public final SpeciesInfo species;
|
||||
public final Enum type;
|
||||
public final List<CharacterInfo> chars;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
|
||||
public ClassInfo(SpeciesInfo species, Enum type) {
|
||||
this.species = species;
|
||||
public ClassInfo(Enum type) {
|
||||
this.type = type;
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
this.chars = Lists.newArrayList();
|
||||
// SpeciesRegistry.SPCLASSES.add(this);
|
||||
this.species.classmap.put(this.type, this);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -224,7 +224,7 @@ public class EntityArachnoid extends EntityNPC
|
|||
return 0.25f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.EVIL, Alignment.LAWFUL, Alignment.NEUTRAL);
|
||||
}
|
||||
|
||||
|
@ -249,6 +249,10 @@ public class EntityArachnoid extends EntityNPC
|
|||
public boolean canUseMagic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.6f;
|
||||
}
|
||||
|
||||
public static class GroupData
|
||||
{
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -53,7 +55,11 @@ public class EntityBloodElf extends EntityNPC {
|
|||
return 0.3f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.9f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(50) ?
|
||||
(rand.chance(8) ? (rand.chance(5) ? Alignment.CHAOTIC : Alignment.LAWFUL) : Alignment.NEUTRAL) :
|
||||
(rand.chance(5) ? Alignment.EVIL : Alignment.LAWFUL_EVIL);
|
||||
|
@ -62,4 +68,8 @@ public class EntityBloodElf extends EntityNPC {
|
|||
public NameRegistry getNameType() {
|
||||
return NameRegistry.ELVEN;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return new ItemStack(this.rand.chance(4) ? this.rand.pick(Items.bow, Items.stone_sword) : Items.iron_sword);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,16 @@ import java.util.List;
|
|||
import game.collect.Lists;
|
||||
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.init.Items;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
public class EntityChaosMarine extends EntityNPC {
|
||||
public static enum Legion implements IStringSerializable {
|
||||
OTHER("other", "???", 0x000000, 0x000000, 2.15f, 200),
|
||||
OTHER("other", null, 0x000000, 0x000000, 2.15f, 200),
|
||||
EMPERORS_CHILDREN("emperorchild", "Emperors Children", 0xa224cc, 0xccb963, 2.43f, 300, "emperors_child");
|
||||
|
||||
public static final Object[] MARINES;
|
||||
|
@ -42,7 +44,7 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
|
||||
private Legion(String name, String display, int color1, int color2, float size, int health, String ... classes) {
|
||||
this.name = name;
|
||||
this.display = display + " Einheit";
|
||||
this.display = display == null ? "" : display + " Einheit";
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.size = size;
|
||||
|
@ -76,11 +78,15 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
return this.getLegion().health;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.15f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getLegion().size;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(Alignment.CHAOTIC_EVIL, Alignment.EVIL, 6);
|
||||
}
|
||||
|
||||
|
@ -115,4 +121,8 @@ public class EntityChaosMarine extends EntityNPC {
|
|||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.boltgun), null, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,11 +50,15 @@ public class EntityCpu extends EntityNPC {
|
|||
// return 0.0f;
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
public boolean isBreedingItem(ItemStack stack) {
|
||||
return stack.getItem() == Items.nieh_fragment;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,7 +98,7 @@ public class EntityCultivator extends EntityNPC {
|
|||
return rand.range(25, 40);
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.values());
|
||||
}
|
||||
|
||||
|
@ -110,6 +110,10 @@ public class EntityCultivator extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public void onStruckByLightning(EntityLightning lightningBolt) {
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,12 @@ public class EntityDarkMage extends EntityHoveringNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,11 @@ public class EntityDwarf extends EntityNPC {
|
|||
return 0.1f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.56f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.GOOD, Alignment.LAWFUL_GOOD, Alignment.NEUTRAL, Alignment.LAWFUL);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -54,7 +56,11 @@ public class EntityElf extends EntityNPC {
|
|||
return 0.4f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.95f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(50) ?
|
||||
(rand.chance(8) ? (rand.chance(5) ? Alignment.CHAOTIC_EVIL : Alignment.EVIL) : Alignment.LAWFUL_EVIL) :
|
||||
(rand.chance(5) ? Alignment.NEUTRAL : Alignment.LAWFUL);
|
||||
|
@ -67,4 +73,8 @@ public class EntityElf extends EntityNPC {
|
|||
public boolean canAmbush(EntityLiving entity) {
|
||||
return (float)this.getHealth() >= ((float)this.getMaxHealth() / 5.0f);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return new ItemStack(this.rand.chance(Items.bow, Items.iron_sword, 4));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,8 +56,12 @@ public class EntityFireDemon extends EntityFlyingNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.35f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.55f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -230,8 +230,12 @@ public class EntityGargoyle extends EntityFlyingNPC
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.05f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.CHAOTIC_EVIL;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,8 +25,12 @@ public class EntityGoblin extends EntityNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.1f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.4f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL, Alignment.LAWFUL_EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -292,6 +292,10 @@ public class EntityHaunter extends EntityNPC {
|
|||
public int getColor() {
|
||||
return 0x00ff00;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.55f;
|
||||
}
|
||||
|
||||
// public boolean isAggressive() {
|
||||
// return true;
|
||||
|
@ -333,7 +337,7 @@ public class EntityHaunter extends EntityNPC {
|
|||
// return 0.0f;
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import game.world.WorldServer;
|
|||
|
||||
public class EntityHuman extends EntityNPC {
|
||||
public static enum ClassType implements IStringSerializable {
|
||||
NONE("none", "???"),
|
||||
NONE("none", ""),
|
||||
KNIGHT("knight", "Krieger"),
|
||||
PEASANT("peasant", "Bauer"),
|
||||
MAGE("mage", "Magier"),
|
||||
|
@ -96,7 +96,11 @@ public class EntityHuman extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(ALIGNMENTS);
|
||||
}
|
||||
|
||||
|
|
|
@ -159,8 +159,12 @@ public class EntityMage extends EntityNPC
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.85f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.ItemRegistry;
|
||||
import game.init.MetalType;
|
||||
import game.item.ItemMetal;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
|
@ -55,7 +57,11 @@ public class EntityMetalhead extends EntityNPC {
|
|||
return 0.2f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.values());
|
||||
}
|
||||
|
||||
|
@ -66,4 +72,9 @@ public class EntityMetalhead extends EntityNPC {
|
|||
public boolean isMagnetic() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ItemStack pickLoot(int slot) {
|
||||
MetalType metal = this.rand.pick(MetalType.values());
|
||||
return new ItemStack(ItemRegistry.getRegisteredItem(this.rand.chance(5) ? metal.name + "_block" : (metal.name + (metal.isPowder ? "_powder" : "_ingot"))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -268,7 +268,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
this.extraInventory = new InventoryBasic("Items", false, 8);
|
||||
// this.setCharacter("");
|
||||
if(this.species != null)
|
||||
this.setSize(this.species.size * this.species.renderer.width / this.species.renderer.height, this.species.size); // /* 0.6F, */ 1.8F);
|
||||
this.setSize(this.getSpeciesBaseSize() * this.species.renderer.width / this.species.renderer.height, this.getSpeciesBaseSize()); // /* 0.6F, */ 1.8F);
|
||||
if(this.getNavigator() instanceof PathNavigateGround) {
|
||||
((PathNavigateGround)this.getNavigator()).setBreakDoors(true);
|
||||
((PathNavigateGround)this.getNavigator()).setAvoidsWater(true);
|
||||
|
@ -901,14 +901,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
public SpeciesInfo getSpecies() {
|
||||
return this.species;
|
||||
}
|
||||
|
||||
public ClassInfo getSpClass() {
|
||||
if(this.species == null)
|
||||
return null;
|
||||
Enum type = this.getNpcClass();
|
||||
return type == null ? null : this.species.classmap.get(type);
|
||||
}
|
||||
|
||||
|
||||
public void setAttackedBy(EntityLiving livingBase)
|
||||
{
|
||||
if(livingBase != null && /* livingBase.isPlayer() && */ this.isEntityAlive() && /* !this.isPeaceful() && */ this.getAttackedBy() != livingBase &&
|
||||
|
@ -1001,23 +994,23 @@ public abstract class EntityNPC extends EntityLiving
|
|||
public boolean isPropogatingSpawnData(boolean newGroup) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setItemInfo(CharacterInfo info) {
|
||||
for(int z = 0; z < 5; z++) {
|
||||
this.setItem(z, info.pickItem(z, this.rand));
|
||||
}
|
||||
int items = this.rand.zrange(4);
|
||||
ItemStack stack;
|
||||
this.extraInventory.clear();
|
||||
for(int z = 0; z < items; z++) {
|
||||
stack = info.pickItem(5, this.rand);
|
||||
if(stack == null) {
|
||||
break;
|
||||
}
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack pickArmor(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected ItemStack pickLoot(int slot) {
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int pickItemAmount() {
|
||||
return this.rand.zrange(4);
|
||||
}
|
||||
|
||||
// public EntityNPC createChild(EntityLiving ageable)
|
||||
// {
|
||||
// }
|
||||
|
@ -1145,8 +1138,10 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return 0.0f;
|
||||
}
|
||||
|
||||
public abstract float getSpeciesBaseSize();
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.species.size;
|
||||
return this.getSpeciesBaseSize();
|
||||
}
|
||||
|
||||
public boolean isVisibleTo(EntityNPC player)
|
||||
|
@ -1154,7 +1149,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return this.connection == null || !this.connection.isInEditor();
|
||||
}
|
||||
|
||||
// public abstract Alignment getNaturalAlign(Random rand);
|
||||
// public abstract Alignment getNaturalAlign();
|
||||
|
||||
// public float getBaseSize(Random rand) {
|
||||
// return ;
|
||||
|
@ -1175,9 +1170,9 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return NameRegistry.FANTASY;
|
||||
}
|
||||
|
||||
public String pickRandomName(Random rand, Enum type)
|
||||
public String pickRandomName()
|
||||
{
|
||||
return this.getNameType().generate(rand, rand.chance(40) ? (rand.chance(15) ? 5 : 4) : (rand.chance() ? 3 : 2));
|
||||
return this.getNameType().generate(this.rand, this.rand.chance(40) ? (this.rand.chance(15) ? 5 : 4) : (this.rand.chance() ? 3 : 2));
|
||||
}
|
||||
|
||||
// public int getColor() {
|
||||
|
@ -3282,12 +3277,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
private void updateSize() {
|
||||
// ModelType model = this.getModel();
|
||||
// this.changeSize(this.getHeight() * this.species.renderer.width / this.species.renderer.height, this.getHeight());
|
||||
this.changeSize(this.getHeight() * this.species.renderer.width, this.getHeight() * this.species.renderer.height);
|
||||
this.changeSize(this.getHeight() / this.species.renderer.height * this.species.renderer.width, this.getHeight());
|
||||
}
|
||||
|
||||
public double getReachDistance()
|
||||
{
|
||||
return Math.max(1.5, 5.0 * (double)this.getHeight()); // / 1.8);
|
||||
return Math.max(1.5, 5.0 * (double)this.height / 1.8);
|
||||
}
|
||||
|
||||
public float getRenderScale()
|
||||
|
@ -3297,12 +3292,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
protected void handleJumpLava()
|
||||
{
|
||||
this.motionY += 0.03999999910593033D * (this.getHeight() * 1.8f + 2.2f) / 4.0f;
|
||||
this.motionY += 0.03999999910593033D * (this.height /* this.getHeight() * 1.8f */ + 2.2f) / 4.0f;
|
||||
}
|
||||
|
||||
protected float getJumpUpwardsMotion()
|
||||
{
|
||||
return 0.42F * (this.getHeight() * 1.8f + 2.2f) / 4.0f;
|
||||
return 0.42F * (this.height /* this.getHeight() * 1.8f */ + 2.2f) / 4.0f;
|
||||
}
|
||||
|
||||
public void setAIMoveSpeed(float speedIn)
|
||||
|
@ -3476,7 +3471,6 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// align = this.getNaturalAlign(this.rand);
|
||||
// }
|
||||
this.setAlignment(align);
|
||||
this.setHeight(tagCompund.hasKey("Height", 5) ? tagCompund.getFloat("Height") : (this.isPlayer() ? this.getBaseSize(this.rand) / this.species.renderer.height * this.species.size : this.getBaseSize(this.rand)));
|
||||
this.setManaPoints(tagCompund.getInteger("Mana"));
|
||||
Enum type = null;
|
||||
if(tagCompund.hasKey("ClassType", 8) && this.species != null && this.species.classEnum != null) {
|
||||
|
@ -3489,6 +3483,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// }
|
||||
}
|
||||
this.setNpcClass(type);
|
||||
this.setHeight(tagCompund.hasKey("Height", 5) ? tagCompund.getFloat("Height") : this.getBaseSize());
|
||||
|
||||
NBTTagList nbttaglist = tagCompund.getTagList("Items", 10);
|
||||
|
||||
|
@ -4336,11 +4331,11 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public String getName()
|
||||
{
|
||||
if(this.isPlayer())
|
||||
return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : "<?>");
|
||||
// if(this.isPlayer())
|
||||
// return this.getAlignment().color + (this.hasCustomName() ? this.getCustomNameTag() : "<?>");
|
||||
String text = this.getPrefix();
|
||||
// Enum cls = this.getNpcClass();
|
||||
if(text == null) {
|
||||
if(text == null || text.isEmpty()) {
|
||||
text = this.getTypeName();
|
||||
}
|
||||
else {
|
||||
|
@ -4358,11 +4353,11 @@ public abstract class EntityNPC extends EntityLiving
|
|||
{
|
||||
if(!this.isPlayer())
|
||||
return 1.62F * this.height / 1.8f;
|
||||
float f = 1.62F * this.getHeight(); // / 1.8f;
|
||||
float f = 1.62F * this.height / 1.8f; // this.getHeight(); // / 1.8f;
|
||||
|
||||
if (this.isSneaking())
|
||||
if (this.isSneakingVisually())
|
||||
{
|
||||
f -= 0.08F * this.getHeight(); // / 1.8f;
|
||||
f -= 0.08F * this.height / 1.8f; // this.getHeight(); // / 1.8f;
|
||||
}
|
||||
|
||||
return f;
|
||||
|
@ -4468,17 +4463,60 @@ public abstract class EntityNPC extends EntityLiving
|
|||
CharacterInfo info = (livingdata instanceof CharacterTypeData) ? ((CharacterTypeData)livingdata).character :
|
||||
this.species.pickCharacter(this.worldObj.rand);
|
||||
AlignmentData align = livingdata instanceof AlignmentData ? ((AlignmentData)livingdata) : null;
|
||||
this.setNpcClass(info.spclass == null ? null : info.spclass.type);
|
||||
this.setChar(info.skin);
|
||||
this.setCape(info.cape);
|
||||
this.setCustomNameTag(info.name.isEmpty() ? this.pickRandomName(this.rand, info.spclass == null ? null :
|
||||
info.spclass.type) : info.name);
|
||||
if(!this.isPlayer())
|
||||
this.setItemInfo(info);
|
||||
this.setAlignment(align != null ? align.alignment : this.getNaturalAlign(this.rand));
|
||||
this.setHeight(this.isPlayer() ? this.getBaseSize(this.rand) / this.species.renderer.height * this.species.size : this.getBaseSize(this.rand));
|
||||
this.setStats(info);
|
||||
if(align != null)
|
||||
this.setAlignment(align.alignment);
|
||||
return align != null ? align : new AlignmentData(this.alignment);
|
||||
}
|
||||
|
||||
public void setStats(NpcInfo info) {
|
||||
this.setNpcClass(info.type == null ? this.pickRandomClass() : info.type);
|
||||
this.setChar(info.skin != null ? info.skin : this.pickRandomTexture());
|
||||
this.setCape(info.cape != null ? info.cape : this.pickRandomAccessory());
|
||||
this.setCustomNameTag(info.name.isEmpty() ? this.pickRandomName() : info.name);
|
||||
this.setAlignment(info.align != null ? info.align : this.getNaturalAlign());
|
||||
this.setHeight(info.height > 0.0f ? info.height : this.getBaseSize());
|
||||
if(!this.isPlayer()) {
|
||||
if(info.items != null) {
|
||||
for(ItemStack stack : info.items) {
|
||||
if(stack.getItem() instanceof ItemArmor)
|
||||
this.setItem(1 + ((ItemArmor)stack.getItem()).armorType, stack);
|
||||
else if(stack.getItem().canBeWielded())
|
||||
this.setItem(0, stack);
|
||||
else
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.setItem(0, this.pickItem());
|
||||
for(int z = 0; z < 4; z++) {
|
||||
this.setItem(z + 1, this.pickArmor(z));
|
||||
}
|
||||
int items = this.pickItemAmount();
|
||||
ItemStack stack;
|
||||
this.extraInventory.clear();
|
||||
for(int z = 0; z < items; z++) {
|
||||
stack = this.pickLoot(z);
|
||||
if(stack == null) {
|
||||
break;
|
||||
}
|
||||
this.extraInventory.addStack(stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String pickRandomTexture() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public String pickRandomAccessory() {
|
||||
return "";
|
||||
}
|
||||
|
||||
public Enum pickRandomClass() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean interactFirst(EntityNPC playerIn)
|
||||
{
|
||||
|
@ -4552,7 +4590,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public void setScaleForAge() {
|
||||
if(!this.isPlayer())
|
||||
this.setScale((float)((int)(100.0f * this.getHeight() * (this.getGrowingAge() < 0 ? 1.0f +
|
||||
this.setScale((float)((int)(100.0f * (this.getHeight() / this.getSpeciesBaseSize()) * (this.getGrowingAge() < 0 ? 1.0f +
|
||||
((float)Math.max(-24000, this.getGrowingAge()) / 24000.0f) * 0.6f : 1.0f))) / 100.0f);
|
||||
}
|
||||
|
||||
|
@ -4632,7 +4670,7 @@ public abstract class EntityNPC extends EntityLiving
|
|||
// return 20;
|
||||
// }
|
||||
|
||||
public abstract Alignment getNaturalAlign(Random rand); // {
|
||||
public abstract Alignment getNaturalAlign(); // {
|
||||
// return Alignment.NEUTRAL;
|
||||
// }
|
||||
|
||||
|
@ -4640,12 +4678,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
return !this.isPlayer() && this.getGrowingAge() <= -14000;
|
||||
}
|
||||
|
||||
public final float getBaseSize(Random rand) {
|
||||
return /* this.isPlayer() ? 1.8f : ( */ (this.getEntityBaseSize() + this.getHeightDeviation(rand)) / this.species.size; // );
|
||||
public final float getBaseSize() {
|
||||
return this.getEntityBaseSize() + this.getHeightDeviation(this.rand);
|
||||
}
|
||||
|
||||
public int getCurrentSize() {
|
||||
return (int)(this.species.renderer.height * this.getHeight() * 100.0f + 0.5f);
|
||||
return (int)(this.getHeight() * 100.0f + 0.5f);
|
||||
}
|
||||
|
||||
public int getDefaultSize() {
|
||||
|
@ -4675,12 +4713,12 @@ public abstract class EntityNPC extends EntityLiving
|
|||
|
||||
public LayerExtra getExtrasLayer()
|
||||
{
|
||||
return this.isPlayer() ? EntityTexManager.getLayer(this.getId(), this.species.renderer) : EntityTexManager.getNpcLayer(this.getChar(), this.species.renderer);
|
||||
return EntityTexManager.getLayer(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
|
||||
}
|
||||
|
||||
public String getLocationSkin()
|
||||
{
|
||||
return this.isPlayer() ? EntityTexManager.getSkin(this.getId(), this.species.renderer) : EntityTexManager.getNpcSkin(this.getChar(), this.species.renderer);
|
||||
return EntityTexManager.getSkin(this.isPlayer() ? this.getId() : -1, this.getChar(), this.species.renderer);
|
||||
}
|
||||
|
||||
public void sendDeathMessage() {
|
||||
|
|
|
@ -53,8 +53,12 @@ public class EntityOrc extends EntityNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.3f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.9f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@ import game.world.World;
|
|||
|
||||
public class EntityPrimarch extends EntityMobNPC {
|
||||
public static enum Founding implements IStringSerializable {
|
||||
OTHER("other", 0, 0x000000, 0x000000),
|
||||
OTHER("other", "", 0, 0x000000, 0x000000),
|
||||
DARK_ANGELS("darkangel", "Dark Angels", 1, 0xaf0000, 0x400000, "Lion El'Jonson:lion_el_jonson", 2.65f, 850, Alignment.GOOD),
|
||||
UNKNOWN_A("unkna", 2, 0xaf0000, 0x400000),
|
||||
UNKNOWN_A("unkna", "[Legion 2]", 2, 0xaf0000, 0x400000),
|
||||
EMPERORS_CHILDREN("emperorchild", "Emperors Children", 3, 0xaf0000, 0x400000, "Fulgrim", 2.65f, 1250, Alignment.NEUTRAL),
|
||||
IRON_WARRIORS("ironwarrior", "Iron Warriors", 4, 0xaf0000, 0x400000, "Perturabo", 2.65f, 450, Alignment.NEUTRAL),
|
||||
WHITE_SCARS("whitescar", "White Scars", 5, 0xaf0000, 0x400000, "Jaghatai Khan", 2.65f, 850, Alignment.NEUTRAL),
|
||||
|
@ -22,7 +22,7 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
NIGHT_LORDS("nightlord", "Night Lords", 8, 0xaf0000, 0x400000, "Konrad Curze", 2.65f, 850, Alignment.NEUTRAL),
|
||||
BLOOD_ANGELS("bloodangel", "Blood Angels", 9, 0xaf0000, 0x400000, "Sanguinius", 2.65f, 850, Alignment.CHAOTIC_GOOD),
|
||||
IRON_HANDS("ironhand", "Iron Hands", 10, 0xaf0000, 0x400000, "Ferrus Manus", 2.65f, 850, Alignment.NEUTRAL),
|
||||
UNKNOWN_B("unknb", 11, 0xaf0000, 0x400000),
|
||||
UNKNOWN_B("unknb", "[Legion 11]", 11, 0xaf0000, 0x400000),
|
||||
WORLD_EATERS("worldeater", "World Eaters", 12, 0xaf0000, 0x400000, "Angron", 2.65f, 850, Alignment.NEUTRAL),
|
||||
ULTRAMARINES("ultramarine", "Ultramarines", 13, 0xaf0000, 0x400000, "Roboute Guilliman", 2.65f, 850, Alignment.NEUTRAL),
|
||||
DEATH_GUARD("deathguard", "Death Guard", 14, 0xaf0000, 0x400000, "Mortarion", 2.65f, 850, Alignment.NEUTRAL),
|
||||
|
@ -59,8 +59,8 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
primarchs.clear();
|
||||
}
|
||||
|
||||
private Founding(String name, int num, int color1, int color2) {
|
||||
this(name, "???", num, color1, color2, null, 2.65f, 850, Alignment.NEUTRAL);
|
||||
private Founding(String name, String display, int num, int color1, int color2) {
|
||||
this(name, display, num, color1, color2, null, 2.65f, 850, Alignment.NEUTRAL);
|
||||
}
|
||||
|
||||
private Founding(String name, String display, int num, int color1, int color2, String primarch, float psize, int phealth,
|
||||
|
@ -125,6 +125,10 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
// return 0;
|
||||
// }
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.65f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getFounding().size;
|
||||
}
|
||||
|
@ -133,7 +137,7 @@ public class EntityPrimarch extends EntityMobNPC {
|
|||
// return 0.0f; // rand.frange(0.0f, 0.5f);
|
||||
// }
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return this.getFounding().align;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,8 +85,12 @@ public class EntitySlime extends EntityNPC
|
|||
public float getHeightDeviationMax() {
|
||||
return 3.0f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,14 +5,16 @@ import java.util.List;
|
|||
import game.collect.Lists;
|
||||
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.init.Items;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
public class EntitySpaceMarine extends EntityNPC {
|
||||
public static enum Legion implements IStringSerializable {
|
||||
OTHER("other", "???", 0x000000, 0x000000, 2.15f, 200),
|
||||
OTHER("other", null, 0x000000, 0x000000, 2.15f, 200),
|
||||
BLACK_TEMPLARS("blacktemplar", "Black Templars", 0x101010, 0xc0c0c0, 2.43f, 300, "black_templar");
|
||||
|
||||
public static final Object[] MARINES;
|
||||
|
@ -42,7 +44,7 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
|
||||
private Legion(String name, String display, int color1, int color2, float size, int health, String ... classes) {
|
||||
this.name = name;
|
||||
this.display = display + " Einheit";
|
||||
this.display = display == null ? "" : display + " Einheit";
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
this.size = size;
|
||||
|
@ -76,11 +78,15 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
return this.getLegion().health;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.15f;
|
||||
}
|
||||
|
||||
public float getEntityBaseSize() {
|
||||
return this.getLegion().size;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.NEUTRAL;
|
||||
}
|
||||
|
||||
|
@ -115,4 +121,8 @@ public class EntitySpaceMarine extends EntityNPC {
|
|||
super.applyEntityAttributes();
|
||||
this.getEntityAttribute(Attributes.ATTACK_DAMAGE).setBaseValue(12.0D);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.boltgun), null, 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.init.Items;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -48,7 +50,11 @@ public class EntitySpirit extends EntityNPC {
|
|||
return 0.1f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.65f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.LAWFUL_GOOD, Alignment.GOOD);
|
||||
}
|
||||
|
||||
|
@ -76,6 +82,10 @@ public class EntitySpirit extends EntityNPC {
|
|||
public float getLegRotation() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.snowball), null, 5);
|
||||
}
|
||||
|
||||
// public boolean canAmbush(EntityLiving entity) {
|
||||
// return true;
|
||||
|
|
|
@ -52,8 +52,12 @@ public class EntityTiefling extends EntityMobNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.4f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL, Alignment.LAWFUL_EVIL,
|
||||
Alignment.NEUTRAL, Alignment.LAWFUL, Alignment.CHAOTIC);
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import game.ai.EntityAIAvoidEntity;
|
|||
import game.entity.animal.EntityWolf;
|
||||
import game.entity.attributes.Attributes;
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
import game.world.WorldServer;
|
||||
|
@ -95,8 +97,12 @@ public class EntityUndead extends EntityNPC
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return Alignment.EVIL;
|
||||
}
|
||||
|
||||
|
@ -111,4 +117,8 @@ public class EntityUndead extends EntityNPC
|
|||
public boolean arePotionsInverted() {
|
||||
return true;
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(new ItemStack(Items.bow), null, 10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,12 @@ public class EntityVampire extends EntityNPC {
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.EVIL, Alignment.CHAOTIC_EVIL, Alignment.CHAOTIC, Alignment.NEUTRAL, Alignment.CHAOTIC_GOOD);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.entity.types.EntityLiving;
|
||||
import game.init.Items;
|
||||
import game.init.NameRegistry;
|
||||
import game.item.ItemStack;
|
||||
import game.rng.Random;
|
||||
import game.world.World;
|
||||
|
||||
|
@ -54,7 +56,11 @@ public class EntityWoodElf extends EntityNPC {
|
|||
return 0.25f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.75f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.chance(5) ? (rand.chance(5) ? Alignment.CHAOTIC : Alignment.NEUTRAL) : Alignment.LAWFUL;
|
||||
}
|
||||
|
||||
|
@ -65,4 +71,8 @@ public class EntityWoodElf extends EntityNPC {
|
|||
public boolean canAmbush(EntityLiving entity) {
|
||||
return (float)this.getHealth() >= ((float)this.getMaxHealth() / 3.0f);
|
||||
}
|
||||
|
||||
protected ItemStack pickItem() {
|
||||
return this.rand.chance(null, new ItemStack(Items.bow), 3);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -316,8 +316,12 @@ public class EntityZombie extends EntityNPC
|
|||
public float getHeightDeviationMax() {
|
||||
return 0.2f;
|
||||
}
|
||||
|
||||
public float getSpeciesBaseSize() {
|
||||
return 1.8f;
|
||||
}
|
||||
|
||||
public Alignment getNaturalAlign(Random rand) {
|
||||
public Alignment getNaturalAlign() {
|
||||
return rand.pick(Alignment.CHAOTIC_EVIL, Alignment.EVIL);
|
||||
}
|
||||
|
||||
|
|
23
java/src/game/entity/npc/NpcInfo.java
Normal file
23
java/src/game/entity/npc/NpcInfo.java
Normal file
|
@ -0,0 +1,23 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import game.item.ItemStack;
|
||||
|
||||
public class NpcInfo {
|
||||
public final Enum type;
|
||||
public final String name;
|
||||
public final String skin;
|
||||
public final String cape;
|
||||
public final Alignment align;
|
||||
public final float height;
|
||||
public final ItemStack[] items;
|
||||
|
||||
public NpcInfo(Enum type, String name, String skin, String cape, Alignment align, float height, ItemStack ... items) {
|
||||
this.type = type;
|
||||
this.name = name;
|
||||
this.skin = skin;
|
||||
this.cape = cape;
|
||||
this.align = align;
|
||||
this.height = height;
|
||||
this.items = items;
|
||||
}
|
||||
}
|
|
@ -1,37 +1,19 @@
|
|||
package game.entity.npc;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import game.collect.BiMap;
|
||||
import game.collect.HashBiMap;
|
||||
import game.collect.Lists;
|
||||
import game.collect.Maps;
|
||||
|
||||
import game.block.Block;
|
||||
import game.init.SpeciesRegistry;
|
||||
import game.init.SpeciesRegistry.ModelType;
|
||||
import game.item.Item;
|
||||
import game.item.ItemArmor;
|
||||
import game.item.ItemBow;
|
||||
import game.item.ItemGunBase;
|
||||
import game.item.ItemHoe;
|
||||
import game.item.ItemShears;
|
||||
import game.item.ItemStack;
|
||||
import game.item.ItemSword;
|
||||
import game.item.ItemTool;
|
||||
import game.item.RngLoot;
|
||||
import game.properties.IStringSerializable;
|
||||
import game.rng.Random;
|
||||
import game.rng.WeightedList;
|
||||
|
||||
public class SpeciesInfo {
|
||||
public final Map<Enum, ClassInfo> classmap;
|
||||
public final BiMap<String, Enum> classnames;
|
||||
public final Class<? extends EntityNPC> clazz;
|
||||
public final Class<? extends Enum> classEnum;
|
||||
public final ModelType renderer;
|
||||
public final float size;
|
||||
public final boolean prefix;
|
||||
public final String id;
|
||||
public final String origin;
|
||||
|
@ -39,46 +21,45 @@ public class SpeciesInfo {
|
|||
public final int color1;
|
||||
public final int color2;
|
||||
public final CharacterInfo[] chars;
|
||||
public final ClassInfo[] classes;
|
||||
private final WeightedList<RngLoot>[] items;
|
||||
private final int[] alignment = new int[Alignment.values().length];
|
||||
private final int[] energies = new int[Energy.values().length];
|
||||
private final int[] baseEnergy = new int[Energy.values().length];
|
||||
|
||||
public SpeciesInfo(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix, String origin, String name, ModelType renderer, float size, int color1, int color2,
|
||||
public SpeciesInfo(String id, Class<? extends EntityNPC> clazz, Class<? extends Enum> classEnum, boolean prefix, String origin, String name, ModelType renderer, int color1, int color2,
|
||||
Object ... names) {
|
||||
this.classmap = classEnum == null ? null : Maps.newEnumMap(classEnum);
|
||||
this.classnames = classEnum == null ? null : HashBiMap.create();
|
||||
this.clazz = clazz; // name.toLowerCase().replace(' ', '_');
|
||||
this.clazz = clazz;
|
||||
this.classEnum = classEnum;
|
||||
this.renderer = renderer;
|
||||
this.size = size;
|
||||
this.prefix = prefix;
|
||||
this.id = id; // clazz.getSimpleName().substring(6);
|
||||
this.id = id;
|
||||
this.origin = origin;
|
||||
this.name = name;
|
||||
this.color1 = color1;
|
||||
this.color2 = color2;
|
||||
List<CharacterInfo> chars = Lists.<CharacterInfo>newArrayList();
|
||||
List<ClassInfo> classes = Lists.<ClassInfo>newArrayList();
|
||||
ClassInfo spclass = null;
|
||||
Enum ctype = null;
|
||||
Alignment align = null;
|
||||
float height = 0.0f;
|
||||
for(int z = 0; z < names.length; z++) {
|
||||
if(names[z] == null) {
|
||||
spclass = null;
|
||||
ctype = null;
|
||||
align = null;
|
||||
height = 0.0f;
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Enum) {
|
||||
classes.add(spclass = new ClassInfo(this, (Enum)names[z]));
|
||||
ctype = (Enum)names[z];
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Alignment) {
|
||||
align = (Alignment)names[z];
|
||||
continue;
|
||||
}
|
||||
if(names[z] instanceof Float) {
|
||||
height = (Float)names[z];
|
||||
continue;
|
||||
}
|
||||
// String id = ((String)names[z]);
|
||||
// if(id.startsWith("$")) {
|
||||
// id = id.substring(1);
|
||||
// spclass = id.isEmpty() ? null : new ClassInfo(this, Enum.valueOf(this.classEnum, id.toUpperCase()));
|
||||
// if(spclass != null)
|
||||
// classes.add(spclass);
|
||||
// continue;
|
||||
// }
|
||||
String[] tok = ((String)names[z]).split(":", 3);
|
||||
int scolor1 = color1;
|
||||
int scolor2 = color2;
|
||||
|
@ -88,16 +69,10 @@ public class SpeciesInfo {
|
|||
scolor1 = scolor2;
|
||||
scolor2 = ((Integer)names[++z]).intValue();
|
||||
}
|
||||
chars.add(new CharacterInfo(this, spclass, tok[0], tok.length > 1 && !tok[1].isEmpty() ? tok[1] : (tok[0].isEmpty() ? this.id : tok[0]).toLowerCase().replace(' ', '_'),
|
||||
tok.length > 2 ? tok[2] : "", scolor1, scolor2, names.length > 1));
|
||||
chars.add(new CharacterInfo(this, ctype, tok[0], tok.length > 1 && !tok[1].isEmpty() ? tok[1] : (tok[0].isEmpty() ? this.id : tok[0]).toLowerCase().replace(' ', '_'),
|
||||
tok.length > 2 ? tok[2] : "", align, height, scolor1, scolor2, names.length > 1));
|
||||
}
|
||||
this.chars = chars.toArray(new CharacterInfo[chars.size()]);
|
||||
this.classes = classes.toArray(new ClassInfo[classes.size()]);
|
||||
this.items = new WeightedList[6];
|
||||
for(int z = 0; z < this.items.length; z++) {
|
||||
this.items[z] = new WeightedList();
|
||||
}
|
||||
// SpeciesRegistry.SPECIES.put(this.id, this);
|
||||
SpeciesRegistry.CLASSES.put(this.clazz, this);
|
||||
if(this.classEnum != null) {
|
||||
for(Enum type : this.classEnum.getEnumConstants()) {
|
||||
|
@ -110,96 +85,6 @@ public class SpeciesInfo {
|
|||
return rand.pick(this.chars);
|
||||
}
|
||||
|
||||
public WeightedList<RngLoot>[] getItems() {
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public void addItems(Object[] items) {
|
||||
WeightedList<RngLoot>[] lists = this.items;
|
||||
int curSlot = -1;
|
||||
ItemStack item;
|
||||
int chance = 1;
|
||||
int min = 1;
|
||||
int max = 1;
|
||||
for(int z = 0; z < items.length; z++) {
|
||||
Object stack = items[z];
|
||||
if(stack == null) {
|
||||
item = null;
|
||||
}
|
||||
else if(stack instanceof String) {
|
||||
String name = (String)stack;
|
||||
if(name.isEmpty()) {
|
||||
lists = this.items;
|
||||
continue;
|
||||
}
|
||||
if(name.startsWith("$")) {
|
||||
name = name.substring(1);
|
||||
Enum type = this.classnames.get(name);
|
||||
if(type == null) {
|
||||
throw new IllegalArgumentException("Item [" + z + "/" + name + "] is not a known class");
|
||||
}
|
||||
ClassInfo ci = this.classmap.get(type);
|
||||
// for(int c = 0; c < this.classes.length; c++) {
|
||||
// if(this.classnames.get(this.classes[c].type).equalsIgnoreCase(name)) {
|
||||
// ci = this.classes[c];
|
||||
// }
|
||||
// }
|
||||
lists = ci.getItems();
|
||||
continue;
|
||||
}
|
||||
CharacterInfo ch = null;
|
||||
for(int c = 0; c < this.chars.length; c++) {
|
||||
if(!this.chars[c].name.isEmpty() && this.chars[c].name.equals(name)) {
|
||||
ch = this.chars[c];
|
||||
}
|
||||
}
|
||||
if(ch == null) {
|
||||
throw new IllegalArgumentException("Item [" + z + "/" + name + "] is not a known character");
|
||||
}
|
||||
lists = ch.getItems();
|
||||
continue;
|
||||
}
|
||||
else if(stack instanceof Integer) {
|
||||
int n = (Integer)stack;
|
||||
if(n <= 0)
|
||||
curSlot = -n;
|
||||
else
|
||||
chance = n;
|
||||
continue;
|
||||
}
|
||||
else if(stack instanceof ItemStack) {
|
||||
item = (ItemStack)stack;
|
||||
max = item.stackSize;
|
||||
item.stackSize = 1;
|
||||
}
|
||||
else if(stack instanceof Item) {
|
||||
item = new ItemStack((Item)stack);
|
||||
}
|
||||
else if(stack instanceof Block) {
|
||||
item = new ItemStack((Block)stack);
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException("Item [" + z + "] has to be a stack, item, block or null");
|
||||
}
|
||||
int slot = curSlot;
|
||||
if(slot == -1 && item == null) {
|
||||
slot = 0;
|
||||
}
|
||||
else if(slot == -1) {
|
||||
slot = ItemArmor.getArmorPosition(item);
|
||||
if(slot == 0 && !(item.getItem() instanceof ItemTool || item.getItem() instanceof ItemSword || item.getItem() instanceof ItemBow ||
|
||||
item.getItem() instanceof ItemHoe || item.getItem() instanceof ItemShears || item.getItem() instanceof ItemGunBase)) {
|
||||
slot = 5;
|
||||
}
|
||||
}
|
||||
lists[slot].add(new RngLoot(item, min, max, chance));
|
||||
curSlot = -1;
|
||||
chance = 1;
|
||||
min = 1;
|
||||
max = 1;
|
||||
}
|
||||
}
|
||||
|
||||
public SpeciesInfo setEnergy(Energy type, int affinity, int base) {
|
||||
this.energies[type.ordinal()] = affinity;
|
||||
this.baseEnergy[type.ordinal()] = base;
|
||||
|
@ -222,4 +107,4 @@ public class SpeciesInfo {
|
|||
public int getAlignAffinity(Alignment type) {
|
||||
return this.alignment[type.ordinal()];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue