MARS Abilities and Combat Plugin
From Multiverse
| MARS |
| Mob Server |
| Object Manager |
| Combat Server |
|
Abilities and Combat Plugin • Combat Statistics • Extending the MARS Combat System • Group System • Trainer Plug-in • Professions • Experience System |
| Tutorials |
| Other Examples |
|
Triggering an Action with a Mouseclick • Scheduled Execution • Working with Sound • Creating a Teleporter |
Contents |
Overview
The MARS abilities plugin defines:
- abilities An ability is an action that a mob or player can perform. When this happens, the ability is said to go through activation. Each ability goes through a series of states in the process of activation.
- effects. An effect is an immediate or persistent action that is applied to a target (a player or mob). Effects perform operations on the target when they are applied or removed. Abilities typically trigger effects at various points in their activation process and apply them to the caster or the target of the ability.
- combat. See MARS Combat Statistics.
Abilities
A Mars ability is an action that a player or mob can perform. It is implemented in the Java class multiverse.mars.core.MarsAbility. An ability goes through various states in the process of activation. This enables you to create a variety of types of abilities, for example:
- Instant abilities, that take effect immediately upon activation.
- Time-consuming abilities, such as spells that take a period of time to cast.
- Multi-stage abilities that "channel" and perform several actions over a period of time.
- Abilities that toggle on or off.
Typically, an ability applies one or more effects (MarsEffects) to the target as it goes through its various states. Effects may perform actions on being applied, being removed, or periodically while they persist.
When a mob or player activates an ability, it first enters the "activating" state. After an activation time, it switches to the "channeling" state where it periodically applies an effect to the target. In either of these states, the ability may be interrupted by actions directed at the caster or cancelled by the caster. These states may also be skipped, depending on how the ability is configured. At the end of the channeling state, the ability will enter either the "active" state if the ability is persistent, or the "completed" state, if not. Either of these states free the mob or player to perform another action.
Cooldowns
Another important way abilities may be configured is with the addition of cooldowns. A cooldown is a temporary property attached to the caster of an ability when the ability is activated. The ability will not be ready for activation again until all of the cooldowns that it depends on have expired from the caster. Need example.
You can define abilities that behave very differently by configuring them accordingly. For example, one ability designed for melee fighters might activate instantly but have a long cooldown. A spell ability might have a long casting time but no channeling phase or cooldown. A ritualistic spell could have a long activating time followed by a channeling phase with effects that are applied periodically as the spell is channeled.
Adding abilities to mobs and items
Add an ability to a mob or a player to enable them to use the ability. Add an ability to an item to enable a player to activate the abilitiy by clicking on the item in their inventory. Need example.
Callback
When an ability is activated or an effect is applied, use a callback to perform resistance checks or other gameplay-specific functions. To do this, create a sub-class of multiverse.mars.core.MarsAbility, and override one of the following methods, most of which are just stubs:
-
beginActivation -
completeActivation -
beginChannelling -
pulseChannelling -
completeChannelling -
beginActivated -
pulseActivated -
endActivated -
interrupt
Need examples.
Effects
A MarsEffect is an instant or persistent effect that is applied to a target, typically as a result of an ability. It is implemented in the Java class multiverse.mars.core.MarsEffect.
Persistent effects may also have a periodic operation that is performed as a sequence of "pulses" over the duration of the effect. For example, a DamageEffect could do damage when it is applied, to simulate a direct attack, or if it were a poison it could do damage periodically over time. Other examples of effects include:
- HealEffect: Heals the target of damage. See
multiverse.mars.effects.HealEffect. - StunEffect: Stuns the target, interrupting any current action and preventing it from moving or performing any actions while it is in effect. See
multiverse.mars.effects.StunEffect. - StatEffect: Modifies the stats of the target while it is active on the target. See
multiverse.mars.effects.StatEffect. - TeachAbilityEffect: This is a special type of effect that teaches a mob or player a new ability. See
multiverse.mars.effects.TeachAbilityEffect.
MARS implements a variety of different effects and it's straightforward to extend the system and add your own.
Example
Here's a simple example that creates a healing ability to be used on a potion:
effect = new HealEffect("heal effect")
effect.setMinInstantHeal(20)
effect.setMaxInstantHeal(20)
Mars.EffectManager.register(effect.getName(), effect)
ability = new EffectAbility("heal potion")
ability.setTargetType(MarsAbility.TargetType.SELF)
ability.setActivationEffect(Mars.EffectManager.get("heal effect"))
ability.addCooldown(new Cooldown("GLOBAL", 1500))
ability.addCooldown(new Cooldown("POTION", 120000))
Mars.AbilityManager.register(ability.getName(), ability)
And the following code defines the item:
item = new ItemTemplate("Healing Potion", "INV_spell_potion")
item.setActivateHook(new AbilityActivateHook("heal potion"))
item.setBoolProperty("consumable", true)
item.setPersistenceFlag(true)
item.spawn()
Mars.ItemTemplateManager.register(item.getName(), item)
Invoking a coordinated effect with an ability
Code in the Sampleworld multiverse/config/sampleworld/ability_db.py file provides an example of how to add a coordinated effect to an ability. The effect script used is the TestProjectile script described in the Coordinated Effects Example - Fireball article.
This creates a fireball spell that does 100 damage to the target. First create an instance of multiverse.mars.effects.DamageEffect, a subclass of multiverse.mars.core.MarsEffect that does damage to the target:
effect = DamageEffect("fireball effect")
effect.setMinInstantDamage(100)
effect.setMaxInstantDamage(100)
effect.setDamageType("Fire")
Mars.EffectManager.register(effect.getName(), effect)
Next, create an instance of the multiverse.mars.objects.CoordinatedEffect, that will invoke the coordinated effect script on the client to provide the visual effect of casting a fireball, the projectile flying to the target, and the impact:
fireballCastingEffect = CoordinatedEffect("SpellCastingEffect")
fireballCastingEffect.sendSourceOid(True)
fireballCastingEffect.putArgument("castingTime", Integer(5000))
fireballCastingEffect.putArgument("decalTexture", "eight-hearts.png")
fireballTargetEffect = CoordinatedEffect("MvFantasyFireball")
fireballTargetEffect.sendSourceOid(True)
fireballTargetEffect.sendTargetOid(True)
Finally, create an instance of multiverse.mars.abilities.EffectAbility that will provide a multiverse.mars.core.MarsAbility to trigger the fireball effect:
ability = EffectAbility("fireball")
ability.setActivationTime(5000)
ability.setActivationCost(10)
ability.setCostProperty(CombatInfo.COMBAT_PROP_ENERGY)
ability.setMaxRange(20000)
ability.setIcon("Interface\FantasyWorldIcons\SPELL_fireball_A")
ability.setTargetType(MarsAbility.TargetType.ENEMY)
ability.setActivationEffect(Mars.EffectManager.get("fireball effect"))
ability.addCooldown(Cooldown("GLOBAL", 1500))
ability.addCoordEffect(MarsAbility.ActivationState.ACTIVATING, fireballCoordFX)
Mars.AbilityManager.register(ability.getName(), ability)
