Samuel - unit json 3(spells, specunitactions)
Posted: Sat Sep 23, 2017 7:36 pm
ok, next will be harder, spells and specunitactions
2 units to jsonize:
assassin and templar.
ids:
public static final int UNIT_ASSASSIN = 34;
public static final int UNIT_TEMPLAR = 35;
images: (see on bottom)
else if (u.type == UNIT_ASSASSIN){
u.fillTexts(c, "UNIT_ASSASSIN");
u.costTurn = 4;
u.sight = 5; //visiblity range
u.hpMax = 8; //health points
u.armorPierce = 0; //how big the armor against arrows
u.armorNormal = 0; //how big the armor against normal attack
u.power = 6; // u.power of its attack
u.rangeWalk = 3; // how far it can walk
u.canWalkHill = false;
u.canWalkForest = true;
u.canOccupyBuilding = false;
u.canBeCarried = true;
u.bonusHealing = 1; // if this unit have bonus when it is healed by an other unit. 1,1 means 10% bonus.
u.convertResistance = 1; // victim property: 0.2 = 20% -> if priest has 30% than 30 - 30*0,2 => priest has 26% to convert.
u.isStealthUnit = true; //not visible to enemy (with restrictions)
u.canSeeStealthUnits = true; //sees stealth units normally
u.haveBonusAgainst = new int[]{// "this" unit have bonus against these units
};
u.specUnitActions = new ESpecUnitAction[]{
ESpecUnitAction.STEALTH_UNIT,
ESpecUnitAction.STEALTH_CAN_SEE_STEALTH,
};
u.bestAgainstMeGround = am(U_CHEAP_INFANTRY_MELEE, U_CHEAP_ARCHERS);
u.bestAgainstMeWater = U_SHIP_ATTACK;
u.modifiers = new int[]{//"type"-s (TECH) that modifies its properties
EFFECT_POISONED_ARROWS,
};
u.builders = new int[]{ //is it built in a TC? or in an archery range? or a worker builds it?
UNIT_TC
};
u.races = new int[] { // only these races can build this
RacesLoader.RACE_HUMAN
};
}//typeif
else if (u.type == UNIT_TEMPLAR){
u.fillTexts(c, "UNIT_TEMPLAR");
u.costTurn = 6;
u.sight = 5; //visiblity range
//u.rangeAttack = 1; //attack range (what maximal range it can attack) (1 means only nearby unit)
u.hpMax = 32; //health points
u.armorPierce = 2; //how big the armor against arrows
u.armorNormal = 2; //how big the armor against normal attack
u.power = 10; // u.power of its attack
u.rangeWalk = 3; // how far it can walk
u.rangeHeal = 1; //healrange (what maximal range it can heal) (1 means only nearby unit)
u.healRate = 7; // how many HP healed by turn (by this healing unit)
u.canWalkHill = false;
u.canWalkForest = true;
u.canOccupyBuilding = true;
u.canBeCarried = true;
u.bonusHealing = 2; // if this unit have bonus when it is healed by an other unit. 1,1 means 10% bonus.
u.convertResistance = 1; // victim property: 0.2 = 20% -> if priest has 30% than 30 - 30*0,2 => priest has 26% to convert.
u.weaponEffects = new SparseIntArray();
u.weaponEffects.append(Unit.WEAPON_EFFECT_SLOT_SPELLCAST, ConstLoader.EFFECT_INSTANT_HEAL);
u.weaponEffectOptions = new SparseArray<int[]>();
u.weaponEffectOptions.put(Unit.WEAPON_EFFECT_SLOT_SPELLCAST,
new int[] {
ConstLoader.EFFECT_INSTANT_HEAL, //priest
ConstLoader.EFFECT_INSTANT_EXORCISM,
}
);
bonusG(u, am (U_BUILDINGS, U_ANTI_BUILDING_MACHINE, a (U_CHEAP_ARCHERS, UNIT_ASSASSIN)), 1f,
new Gb(a (U_CHEAP_ARCHERS, UNIT_ASSASSIN), 0.5f)
);
u.bestAgainstMeGround = a(U_MOUNTED_KNIGHTS, UNIT_DOUBLE_SWORDMAN, UNIT_IMPERIAL_SHIELDER, UNIT_WAR_ELEPHANT);
u.bestAgainstMeWater = U_SHIP_ATTACK;
u.builders = new int[]{ //is it built in a TC? or in an archery range? or a worker builds it?
UNIT_TC,
UNIT_BUILDING_BARRACKS
};
u.grantorShopItems = new int[]{ //"shop item"-s that is required to have/build this one
ShopItemLoader.ITEM_TEMPLAR,
};
u.modifiers = new int[]{//"type"-s (TECH) that modifies its properties
TECH_ARMOR_INFANTRY_LV1,
TECH_ARMOR_INFANTRY_LV2,
TECH_SWORD_LV1,
TECH_SWORD_LV2,
EFFECT_POISONED_ARROWS,
};
u.races = new int[] { // only these races can build this
RacesLoader.RACE_HUMAN
};
}//typeif
here you need to see only the
a) image name,
b) and the sounds used
c) any special "arrows" on any special ability (getFeatureSpriteID, in temlar case the HEALING)
public static class UiUnitAssassin extends Ui.UiUnit{
//The ones you have to change when creating new Unit type
public static String IMG_NAME = "32_unit_assassin.png";
@Override
public Unit getNewUnitInstance(WorldMap map){return new Unit(map, Units.UNIT_ASSASSIN);}
//the ones need no change when creating unit types
public static TextureHolder imgBuildable;
@Override
public TiledTextureRegion getImgTexture(EColors color){return imgBuildable.get(color);}
@Override
public String getImgName(){return IMG_NAME;}
@Override
public Integer getSoundPack(ESoundEvents event){
Integer result = null;
switch (event) {
case UNIT_SELECTED: result = SoundsDefLoader.SOUND_PACK_UNIT_SELECT_LAND_UNIT; break;
case UNIT_AFFIRM_MOVE: result = SoundsDefLoader.SOUND_PACK_UNIT_AFFIRM_LAND_UNIT; break;
case UNIT_ATTACK: result = SoundsDefLoader.SOUND_PACK_UNIT_ATTACK_SWING; break;
case UNIT_DAMAGE: result = SoundsDefLoader.SOUND_PACK_UNIT_DAMAGED_HUMAN; break;
}
return result;
}
public UiUnitAssassin() {
super();
}//UiUnitAssassin
}//UiUnitAssassin
public static class UiUnitTemplar extends Ui.UiUnit{
//The ones you have to change when creating new Unit type
public static String IMG_NAME = "32_unit_templar.png";
@Override
public Unit getNewUnitInstance(WorldMap map){return new Unit(map, Units.UNIT_TEMPLAR);}
//the ones need no change when creating unit types
public static TextureHolder imgBuildable;
@Override
public TiledTextureRegion getImgTexture(EColors color){return imgBuildable.get(color);}
@Override
public String getImgName(){return IMG_NAME;}
@Override
public Integer getSoundPack(ESoundEvents event){
Integer result = null;
switch (event) {
case UNIT_SELECTED: result = SoundsDefLoader.SOUND_PACK_UNIT_SELECT_LAND_UNIT; break;
case UNIT_AFFIRM_MOVE: result = SoundsDefLoader.SOUND_PACK_UNIT_AFFIRM_LAND_UNIT; break;
case UNIT_ATTACK: result = SoundsDefLoader.SOUND_PACK_UNIT_ATTACK_SWING; break;
case UNIT_DAMAGE: result = SoundsDefLoader.SOUND_PACK_UNIT_DAMAGED_HUMAN; break;
case UNIT_HEAL: result = SoundsDefLoader.SOUND_PACK_UNIT_HEAL; break;
}
return result;
}
@Override
public int getFeatureSpriteID(EUnitSpriteFeatureTypes type){
switch (type) {
case HEAL: return PreparedSpritesLoader.SPRITE_ARROW_HEAL;
}
return 0;
}
public UiUnitTemplar() {
super();
}//UiUnitTemplar
}//UiUnitTemplar
2 units to jsonize:
assassin and templar.
ids:
public static final int UNIT_ASSASSIN = 34;
public static final int UNIT_TEMPLAR = 35;
images: (see on bottom)
else if (u.type == UNIT_ASSASSIN){
u.fillTexts(c, "UNIT_ASSASSIN");
u.costTurn = 4;
u.sight = 5; //visiblity range
u.hpMax = 8; //health points
u.armorPierce = 0; //how big the armor against arrows
u.armorNormal = 0; //how big the armor against normal attack
u.power = 6; // u.power of its attack
u.rangeWalk = 3; // how far it can walk
u.canWalkHill = false;
u.canWalkForest = true;
u.canOccupyBuilding = false;
u.canBeCarried = true;
u.bonusHealing = 1; // if this unit have bonus when it is healed by an other unit. 1,1 means 10% bonus.
u.convertResistance = 1; // victim property: 0.2 = 20% -> if priest has 30% than 30 - 30*0,2 => priest has 26% to convert.
u.isStealthUnit = true; //not visible to enemy (with restrictions)
u.canSeeStealthUnits = true; //sees stealth units normally
u.haveBonusAgainst = new int[]{// "this" unit have bonus against these units
};
u.specUnitActions = new ESpecUnitAction[]{
ESpecUnitAction.STEALTH_UNIT,
ESpecUnitAction.STEALTH_CAN_SEE_STEALTH,
};
u.bestAgainstMeGround = am(U_CHEAP_INFANTRY_MELEE, U_CHEAP_ARCHERS);
u.bestAgainstMeWater = U_SHIP_ATTACK;
u.modifiers = new int[]{//"type"-s (TECH) that modifies its properties
EFFECT_POISONED_ARROWS,
};
u.builders = new int[]{ //is it built in a TC? or in an archery range? or a worker builds it?
UNIT_TC
};
u.races = new int[] { // only these races can build this
RacesLoader.RACE_HUMAN
};
}//typeif
else if (u.type == UNIT_TEMPLAR){
u.fillTexts(c, "UNIT_TEMPLAR");
u.costTurn = 6;
u.sight = 5; //visiblity range
//u.rangeAttack = 1; //attack range (what maximal range it can attack) (1 means only nearby unit)
u.hpMax = 32; //health points
u.armorPierce = 2; //how big the armor against arrows
u.armorNormal = 2; //how big the armor against normal attack
u.power = 10; // u.power of its attack
u.rangeWalk = 3; // how far it can walk
u.rangeHeal = 1; //healrange (what maximal range it can heal) (1 means only nearby unit)
u.healRate = 7; // how many HP healed by turn (by this healing unit)
u.canWalkHill = false;
u.canWalkForest = true;
u.canOccupyBuilding = true;
u.canBeCarried = true;
u.bonusHealing = 2; // if this unit have bonus when it is healed by an other unit. 1,1 means 10% bonus.
u.convertResistance = 1; // victim property: 0.2 = 20% -> if priest has 30% than 30 - 30*0,2 => priest has 26% to convert.
u.weaponEffects = new SparseIntArray();
u.weaponEffects.append(Unit.WEAPON_EFFECT_SLOT_SPELLCAST, ConstLoader.EFFECT_INSTANT_HEAL);
u.weaponEffectOptions = new SparseArray<int[]>();
u.weaponEffectOptions.put(Unit.WEAPON_EFFECT_SLOT_SPELLCAST,
new int[] {
ConstLoader.EFFECT_INSTANT_HEAL, //priest
ConstLoader.EFFECT_INSTANT_EXORCISM,
}
);
bonusG(u, am (U_BUILDINGS, U_ANTI_BUILDING_MACHINE, a (U_CHEAP_ARCHERS, UNIT_ASSASSIN)), 1f,
new Gb(a (U_CHEAP_ARCHERS, UNIT_ASSASSIN), 0.5f)
);
u.bestAgainstMeGround = a(U_MOUNTED_KNIGHTS, UNIT_DOUBLE_SWORDMAN, UNIT_IMPERIAL_SHIELDER, UNIT_WAR_ELEPHANT);
u.bestAgainstMeWater = U_SHIP_ATTACK;
u.builders = new int[]{ //is it built in a TC? or in an archery range? or a worker builds it?
UNIT_TC,
UNIT_BUILDING_BARRACKS
};
u.grantorShopItems = new int[]{ //"shop item"-s that is required to have/build this one
ShopItemLoader.ITEM_TEMPLAR,
};
u.modifiers = new int[]{//"type"-s (TECH) that modifies its properties
TECH_ARMOR_INFANTRY_LV1,
TECH_ARMOR_INFANTRY_LV2,
TECH_SWORD_LV1,
TECH_SWORD_LV2,
EFFECT_POISONED_ARROWS,
};
u.races = new int[] { // only these races can build this
RacesLoader.RACE_HUMAN
};
}//typeif
here you need to see only the
a) image name,
b) and the sounds used
c) any special "arrows" on any special ability (getFeatureSpriteID, in temlar case the HEALING)
public static class UiUnitAssassin extends Ui.UiUnit{
//The ones you have to change when creating new Unit type
public static String IMG_NAME = "32_unit_assassin.png";
@Override
public Unit getNewUnitInstance(WorldMap map){return new Unit(map, Units.UNIT_ASSASSIN);}
//the ones need no change when creating unit types
public static TextureHolder imgBuildable;
@Override
public TiledTextureRegion getImgTexture(EColors color){return imgBuildable.get(color);}
@Override
public String getImgName(){return IMG_NAME;}
@Override
public Integer getSoundPack(ESoundEvents event){
Integer result = null;
switch (event) {
case UNIT_SELECTED: result = SoundsDefLoader.SOUND_PACK_UNIT_SELECT_LAND_UNIT; break;
case UNIT_AFFIRM_MOVE: result = SoundsDefLoader.SOUND_PACK_UNIT_AFFIRM_LAND_UNIT; break;
case UNIT_ATTACK: result = SoundsDefLoader.SOUND_PACK_UNIT_ATTACK_SWING; break;
case UNIT_DAMAGE: result = SoundsDefLoader.SOUND_PACK_UNIT_DAMAGED_HUMAN; break;
}
return result;
}
public UiUnitAssassin() {
super();
}//UiUnitAssassin
}//UiUnitAssassin
public static class UiUnitTemplar extends Ui.UiUnit{
//The ones you have to change when creating new Unit type
public static String IMG_NAME = "32_unit_templar.png";
@Override
public Unit getNewUnitInstance(WorldMap map){return new Unit(map, Units.UNIT_TEMPLAR);}
//the ones need no change when creating unit types
public static TextureHolder imgBuildable;
@Override
public TiledTextureRegion getImgTexture(EColors color){return imgBuildable.get(color);}
@Override
public String getImgName(){return IMG_NAME;}
@Override
public Integer getSoundPack(ESoundEvents event){
Integer result = null;
switch (event) {
case UNIT_SELECTED: result = SoundsDefLoader.SOUND_PACK_UNIT_SELECT_LAND_UNIT; break;
case UNIT_AFFIRM_MOVE: result = SoundsDefLoader.SOUND_PACK_UNIT_AFFIRM_LAND_UNIT; break;
case UNIT_ATTACK: result = SoundsDefLoader.SOUND_PACK_UNIT_ATTACK_SWING; break;
case UNIT_DAMAGE: result = SoundsDefLoader.SOUND_PACK_UNIT_DAMAGED_HUMAN; break;
case UNIT_HEAL: result = SoundsDefLoader.SOUND_PACK_UNIT_HEAL; break;
}
return result;
}
@Override
public int getFeatureSpriteID(EUnitSpriteFeatureTypes type){
switch (type) {
case HEAL: return PreparedSpritesLoader.SPRITE_ARROW_HEAL;
}
return 0;
}
public UiUnitTemplar() {
super();
}//UiUnitTemplar
}//UiUnitTemplar