[RPG] Skills and Professions

Discussion in 'WIP and Development Status' started by silthus, Nov 30, 2012.

Thread Status:
Not open for further replies.
  1. This is something I have been working on for quite a while now.

    The origin of it is the idea behind heroes and the concept of separate skills that can be loaded and used by demand. But for me Heroes was too inflexiable and has no database support. Since it is not open source I started coding this project from scratch.

    It basically consists out of two parts:
    • Spells: takes care of the generic spell mechanics like firing a fireball or throwing somebody around. This is splitted off the main project so it can be used for custom mobs (like in MobArena)
    • Skills (and Professions): is the core and handles all the different skills and professions (list below)
    Skills and Professions Features:
    • Database Support (MySQL, SQLite) for dynamic content storage
    • Skills can be targeted, areatargeted and passive at the same time (implementation of a simple interface)
    • Players can level based on their profession and skill level
    • Skills can level and have the strong/weak parents system - That means you can have something like SkillTrees
    • Skills can have effects that only apply when the skill hit something - Effects can be reused in other skills
    • +all the features that heroes currently has
    For all the programmers out there here is a example of the API structure:

    [​IMG]

    And here is a code example of the Fireball Skill which uses almost all of the possible options available right now:

    Show Spoiler

    Code:
    package de.raidcraft.skills.skills.magic;
     
    import de.raidcraft.skills.api.TargetedAttack;
    import de.raidcraft.skills.api.combat.AbstractEffect;
    import de.raidcraft.skills.api.combat.EffectInformation;
    import de.raidcraft.skills.api.exceptions.CombatException;
    import de.raidcraft.skills.api.hero.Hero;
    import de.raidcraft.skills.api.persistance.SkillProperties;
    import de.raidcraft.skills.api.skill.AbstractLevelableSkill;
    import de.raidcraft.skills.api.skill.Skill;
    import de.raidcraft.skills.api.skill.SkillInformation;
    import de.raidcraft.skills.tables.THeroSkill;
    import de.raidcraft.spells.api.SpellCallback;
    import de.raidcraft.spells.fire.RCFireball;
    import de.raidcraft.util.DataMap;
    import org.bukkit.entity.LivingEntity;
     
    /**
    * @author Silthus
    */
    @SkillInformation(
            name = "fireball",
            desc = "Schießt einen Feuerball auf den Gegener.",
            types = {Skill.Type.DAMAGING, Skill.Type.FIRE, Skill.Type.HARMFUL}
    )
    public class Fireball extends AbstractLevelableSkill implements TargetedAttack {
     
        private boolean afterBurner;
     
        public Fireball(Hero hero, SkillProperties skillData, THeroSkill database) {
     
            super(hero, skillData, database);
        }
     
        @Override
        public void load(DataMap data) {
     
            afterBurner = data.getBoolean("burn-after-hit", false);
        }
     
        @Override
        public void run(final Hero hero, final LivingEntity target) throws CombatException {
     
            // lets create a new Spell from the Spells component
            // you can also do your own stuff here but if you think
            // a boss can do this stuff too add a spell please
            RCFireball fireball = new RCFireball();
            // set the firetick damage based on the player level
            fireball.fireTicks = 20 * hero.getLevel().getLevel();
            // let it burn the target
            fireball.incinerate = true;
            // cast the fireball and wait for a callback after it hit
            fireball.run(hero.getBukkitPlayer(), new SpellCallback() {
                @Override
                public void run(LivingEntity target) {
     
                    // only apply the after burn effect if set in our custom config
                    if (!afterBurner) {
                        return;
                    }
                    // also add some extra damage after the fireball hit
                    // the total damage is calculated from config settings and the player, prof and skill level
                    try {
                        hero.damageEntity(target, getTotalDamage());
                    } catch (CombatException e) {
                        return;
                    }
                    addEffect(new FireballEffect().setDelay(5).setDuration(20).setInterval(2), target);
                }
            }, target);
            // add some exp to the profession and skill
            getProfession().getLevel().addExp(2);
            getLevel().addExp(5);
        }
     
        @EffectInformation(
                name = "FireballEffect",
                description = "Das Ziel brennt von der Hitze des Feuerballs."
        )
        public class FireballEffect extends AbstractEffect {
     
            @Override
            public void apply(Hero hero, LivingEntity target) throws CombatException {
     
                // reminder: this method is called every set interval for the duration after the delay
                // damage entity for 5 and let it burn for 1 second
                hero.damageEntity(target, 5);
                target.setFireTicks(20);
            }
        }
    }
    


    Status is: 80% finished - I only need to code some commands and make some last implementations.
     
  2. Offline

    Tomaz

    This looks pretty impressive.
     
Thread Status:
Not open for further replies.

Share This Page