Skip to content
Caliog edited this page Sep 27, 2018 · 9 revisions

Spells can be various things, most of them give you a magically created advantage in battle.
There are passive spells, like those which increase your defense or damage and active spells, those creating big explosions and such stuff.
Each spell has a power, which can be increased after you level up.
The power decides how strong the spell is, e.g. the damage/defense or the radius the spell takes place in or the time the spell is active.

Where to find and configure spells

You can find most available spells in the folder Rolecraft/Spells as YAML files.
Inside such a file you can change the name of the spell, configure the min-level players need to use the spell, the max-power you can level this spell and how much extra damage/defense players get while using this spell.

name: <custom-name>
min-level: 1 
max-power: 20 
damage:  
  '1': 0
  '5': 2
  '9': 3  
  '17': 5
defense:  
  '1': 1  
  '2': 2  
  '5': 3  
  '10': 4 
  '20': 6  

E.g. this spell would add 3 damage if the spell has a power between 9 and 17 and 4 defense if the spell has a power between 10 and 20.

How to create a curse

Video Tutorial

A curse is a prototype of an attack spell. If its triggered it shoots particles at the player's target, the type can be configured. To create a new curse, create a .yml file in the spells folder which looks like this:

min-level: 1
max-power: 60
damage:
  '1': 2
  '5': 3
  '10': 4
  '20': 5
  '30': 6
  '40': 7
  '55': 8
  '60': 9
defense:
  '1': 0
curse:
  color: SPELL
  direction: RAY

The color value determines the type and the color of the particles. Other possible values are:

color: AQUA, BLACK, BLUE, FUCHSIA, GRAY, GREEN, LIME, MAROON, NAVY, OLIVE, ORANGE, PURPLE, RED, SILVER, TEAL, WHITE, YELLOW, DOLPHIN, MAGIC, SPELL, WITCH, FLAME, HEART, SWEEP, AURA

direction: RAY, CONE, FULL, TWIRL, AUTO_TARGET

(some of them are only available for MC 1.13.1 +)

How to assign spells to classes

See Classes page.

How to use and power-up spells in game

If you level-up you will receive a spellpoints and your 'book of spells', which contains all spells of your class.
If you have a spellpoint you can click a spell in the spellbook to power it up.
To see which castcode you have to use to cast a spell, just hover over it with your mouse.

To cast a spell, you have to hold a rolecraft weapon in your hand. Now click the castcode to cast your spell.
E.g. left-right-left (you may have to press shift during the first mouse click).

How to create your own spells

If you know how to code with java and craftbukkit you can create your own spells.
If not you can also ask me to do it for you, but it will be a public spell afterwards.
Coding Spells:

  1. First add the Rolecraft.jar to your project build path. (Google helps if you don't know how.)

  2. Create a java class which extends the class Spell and add like this constructor
    Constructor

  3. Now override the execute like this:
    Execute
    The super.execute() call, returns true if the player is allowed to use the spell.

  4. Optional: If your spell is active over a period of time you should tell that by calling the method activate
    Activate
    with the time in ticks (one second = 20 ticks).
    In this example the time is dependent of the power of the spell.

  5. Now you can add whatever you want to happen. Some important methods are:

    • getPlayer(), which returns the RolecraftPlayer using the spell.
    • getPower(), which returns the power of the spell.
    • getDamage() & getDefense(), the values entered in the .yml file of this spell (you could also override them here).
    • Manager.scheduleRepeatingTask(Runnable task, long i, long j, long k) which starts repeating the task every j tick after i ticks and cancels it after k ticks.
      final.png
      In this example we shoot a lot of arrows (one each 250ms) and set it on fire.
  6. Final step: Do not forget to add a file called spell.info in the root directory of your java project.
    This file should contain the path to your spell classes, e.g. org.caliog.SpellCollection.Flamethrower.
    If you have more than one spell class, write them each in a different line.

You can find more examples in the SpellCollection repo.