Tutorial 2: Advancing your Alterations with ArmorSets, Aliases, Et Cetera
So! You've made it this far with MD, and now you want to have some more power in your configs. This tutorial will briefly cover the basics of aliasing, using ArmorSets and ItemSets,
Our first example for Aliasing in this tutorial will be a redux of the configuration we used for Calculations in the first tutorial. Remember this?
on Damage
switch.attacker.group
RedWizards
switch.attacker.wielding
Book
targeteffect.heal: 2 # Heal any entity for 1 heart. Note that single-line nesting can be done here too.
Bookshelf
switch.target.group
RedTeam # Multigroup is awesome this way - only allow this to heal teammates.
targeteffect.heal: 6
Coal
if !target.group.RedTeam
targeteffect.setfireticks: range(100,200) # Sets the target on fire, though this is a fairly random number. Remember that in Minecraft there are 20 ticks/second.
Technically it's possible to use 'targeteffect.sethealth' to manage an entity's health.
Now let's say you wanted to implement a class of sword-wielders, too, which have a small bonus when hitting things with their preferred weapon. With our current knowledge of MD, we'd probably write something like this:
on Damage
switch.attacker.group
[...]
RedWarriors
if attacker.wielding.GOLD_SWORD or attacker.wielding.IRON_SWORD or attacker.wielding.DIAMOND_SWORD or attacker.wielding.WOOD_SWORD
+2
This is yucky. Not only do we have to write an entire long line of conditionals every time we want to know if somebody is wielding a sword and/or want to identify swords elsewhere, but if we change our minds and decide that we want to alter these same conditionals later...then we have to find everywhere we want to change the conditional likewise. Even worse, what if we're using a Wield switch?
on Damage
switch.attacker.wielding
GOLD_SWORD
[some routines]
IRON_SWORD
[the same routines]
DIAMOND_SWORD
[the same routines again]
WOODEN_SWORD
[the same routines again]
To reiterate: this is yucky. Fortunately, we don't have to do this, because of the aliasing system that has been included in ModDamage. Most attributes in Minecraft that can present this problem are aliasable, and here we can use Material aliases to define a list of materials that are a sword:
Aliases
Material
sword
WOOD_SWORD
IRON_SWORD
GOLD_SWORD
DIAMOND_SWORD
on Damage
switch.attacker.group
[...]
RedWarriors
if attacker.wielding._sword: +2 # Underscore, then the alias string!
It's obvious to see how much easier this is to manage, and increases overall readability in a configuration. Note how we did this - where ModDamage expected a quantity that aliases can handle, we used an underscore and then the alias string itself. For most aliasing systems that associate a single string for multiple values, you can use commas to delimit non-aliased values where you don't want to set up a fully-fledged alias. This would be useful, for instance, if we only referred to a certain set of items once. For our example with the swords:
on Damage
switch.attacker.group
[...]
RedWarriors
if attacker.wielding.GOLD_SWORD,IRON_SWORD,DIAMOND_SWORD,WOOD_SWORD
+2
Now, we'll provide with a much more complex example, which also serves to demonstrate the flexibility and power of MD to change Minecraft. Suppose that there's a server with two factions: nether dwellers called Firebreathers, and those of the overworld called...well, the Overlanders. :P
on Damage
switch.environment
NETHER
switch.attacker.type
Human
0
roll.7
if event.value.greaterthanequals.4 and chance.30: 0
switch.attacker.group
FireBreathers
if attacker.wielding._sword
+2
if attacker.wielding.DIAMOND_SWORD: +3
if target.group.Overlanders: +3 # PvP bonus against the Overlanders. :D
Overlanders
if target.group.FireBreathers: div.2 # Divide by 2 - could also be '\2', '/2'
Ghast
4
+roll.4
chance.20: 2 # Binomial calculation - define a 20 percent chance of executing
# another calculation string, here it's '2'
ZombiePigman
roll.12 # The 'roll' function gives an even probability distribution
# all positive output values <= the specified value (12)
switch.target.group
Firebreathers
switch.damage.type #these come from nature and are named 'damage' types, not 'attacker'
burn: 0
fire: 2
lava: 4
NORMAL
switch.attacker.group
Overlanders
0
chance.5: 10 # Basically a 5% chance for a 5-heart hit. D:
if target.type.mob,animal: +1
if attacker.wielding._farmtool: +2
FireBreathers: -4 # Pretty bad debuff for FireBreathers :<
switch.target.group
Firebreathers: +1 # Another mean debuff, but not so bad.
Aliases
item
axe
WOOD_AXE
STONE_AXE
IRON_AXE
GOLD_AXE
DIAMOND_AXE
hoe
WOOD_HOE
STONE_HOE
IRON_HOE
GOLD_HOE
DIAMOND_HOE
pickaxe
WOOD_PICKAXE
STONE_PICKAXE
IRON_PICKAXE
GOLD_PICKAXE
DIAMOND_PICKAXE
spade
WOOD_SPADE
STONE_SPADE
IRON_SPADE
GOLD_SPADE
DIAMOND_SPADE
sword
WOOD_SWORD
STONE_SWORD
IRON_SWORD
GOLD_SWORD
DIAMOND_SWORD
farmtool # You can refer to other aliases when defining aliases
# just make sure that there's no circular references.
_axe
_hoe
_pickaxe
_spade
A full analysis won't be broached here, but brief description of the configuration is as follows:
-
A FireBreather is much more powerful in the Nether - an Overlander attacked by a FireBreather with a diamond sword would be killed instantly (with normal player health settings). Resistance to fire-based damage is also a bonus.
-
FireBreathers have significant negative buffs associated with being in the world "normal".
-
An Overlander wielding a farming tool (spade, hoe, pickaxe) has a definite offensive advantage in the "normal" (non-Nether-type) world, and a slight defensive bonus against mobs when in world "normal".
-
Overlanders in the world "normal" have a 5% chance for a critical-type strike in which they deal 10 damage (5 hearts).
One can see how quickly a relatively small configuration (compared to a place like the Hall of Fame) can vastly orient damage relationships in Minecraft in different directions.
More robust examples of all types of aliasing can be found at the Aliasing FAQ.
There are several types of aliases in MD, and we will use them as the vehicle for teaching more of MD's other features.
Equipment sets in Minecraft are referred to as ArmorSets. Recommended reading for this is as follows:
TODO: Under construction!
Items can be dropped from any entity, and given/taken to/from any player.
-
Refer to routines
-
Enchantments
-
Entity references Explain which ones are available, what they refer to. Make a link in the currently incomplete Configuration Reference
-
Make formal introduction to Entity Status and Entity Block Status articles, give examples?