Search in sources :

Example 1 with WalkingType

use of com.watabou.pixeldungeon.actors.mobs.WalkingType in project pixel-dungeon-remix by NYRDS.

the class CustomMob method fillMobStats.

private void fillMobStats(boolean restoring) {
    try {
        JSONObject classDesc = getClassDef();
        defenseSkill = classDesc.optInt("defenseSkill", defenseSkill);
        attackSkill = classDesc.optInt("attackSkill", attackSkill);
        exp = classDesc.optInt("exp", exp);
        maxLvl = classDesc.optInt("maxLvl", maxLvl);
        dmgMin = classDesc.optInt("dmgMin", dmgMin);
        dmgMax = classDesc.optInt("dmgMax", dmgMax);
        dr = classDesc.optInt("dr", dr);
        baseSpeed = (float) classDesc.optDouble("baseSpeed", baseSpeed);
        attackDelay = (float) classDesc.optDouble("attackDelay", attackDelay);
        name = StringsManager.maybeId(classDesc.optString("name", mobClass + "_Name"));
        name_objective = StringsManager.maybeId(classDesc.optString("name_objective", mobClass + "_Name_Objective"));
        description = StringsManager.maybeId(classDesc.optString("description", mobClass + "_Desc"));
        gender = Utils.genderFromString(classDesc.optString("gender", mobClass + "_Gender"));
        spriteClass = classDesc.optString("spriteDesc", "spritesDesc/Rat.json");
        flying = classDesc.optBoolean("flying", flying);
        lootChance = (float) classDesc.optDouble("lootChance", lootChance);
        if (classDesc.has("loot")) {
            loot = ItemFactory.createItemFromDesc(classDesc.getJSONObject("loot"));
        }
        viewDistance = classDesc.optInt("viewDistance", viewDistance);
        viewDistance = Math.min(viewDistance, ShadowCaster.MAX_DISTANCE);
        walkingType = Enum.valueOf(WalkingType.class, classDesc.optString("walkingType", "NORMAL"));
        defenceVerb = StringsManager.maybeId(classDesc.optString("defenceVerb", Game.getVars(R.array.Char_StaDodged)[gender]));
        canBePet = classDesc.optBoolean("canBePet", canBePet);
        attackRange = classDesc.optInt("attackRange", attackRange);
        scriptFile = classDesc.optString("scriptFile", scriptFile);
        if (!restoring) {
            setFraction(Enum.valueOf(Fraction.class, classDesc.optString("fraction", "DUNGEON")));
            friendly = classDesc.optBoolean("friendly", friendly);
            hp(ht(classDesc.optInt("ht", 1)));
            fromJson(classDesc);
        }
        runMobScript("fillStats");
    } catch (Exception e) {
        throw new TrackedRuntimeException(e);
    }
}
Also used : WalkingType(com.watabou.pixeldungeon.actors.mobs.WalkingType) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException) JSONObject(org.json.JSONObject) Fraction(com.watabou.pixeldungeon.actors.mobs.Fraction) TrackedRuntimeException(com.nyrds.android.util.TrackedRuntimeException)

Aggregations

TrackedRuntimeException (com.nyrds.android.util.TrackedRuntimeException)1 Fraction (com.watabou.pixeldungeon.actors.mobs.Fraction)1 WalkingType (com.watabou.pixeldungeon.actors.mobs.WalkingType)1 JSONObject (org.json.JSONObject)1