MARS Professions
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 |
The profession system provides a player with both skills and abilities that are specific to a player class or type.
Contents |
Setting up a profession
For clarity, professions are defined in the professions_db.py file in your world's config directory, for example multiverse/config/sampleworld/professions_db.py. Lets setup a profession that we will use throughout the rest of this article. Open the professions_db.py in your favorite editor and add the following lines:
# create a profession object
profession = ProfessionObject("Tutorial Profession")
# Now register that profession with the classabilityplugin
ClassAbilityPlugin.registerProfession(profession)
This simply creates the default ProfessionObject. It then registers the profession with the multiverse.mars.plugins.ClassAbilityPlugin so that the system can make use of it as we add to it. However, right now, the profession is merely just a name in the system.
Adding professions to character creation
To enable players to choose a profession, you need to make some changes to character creation. This will be where the player will actually choose their profession. Open up the \Scripts\SampleCharacterCreation.py file from the asset repository in a text editor and look for this line:
self.SetAttributes("characterName", {"characterName":"",
"model":"human_male.mesh",
"sex":"male",
"strength":"60",
"dexterity":"60",
"wisdom":"60",
"intelligence":"60",
"level":"1",
"class":"Soldier"})
This shows the default class as Soldier, so when someone creates a character without changing anything it will have the "soldier" profession. To change it to have your own profession as the default, change "Soldier" to "Tutorial Profession". If you are using a different name, make sure that the name is exactly as you set it in the profession_db.py file or an error will occur.
The rest of the file is setup correctly for assigning a player a profession, so look next at the actual GUI used to create a character. So open up the file Interface/FrameXML/MVCharCreation.xml and look for the following line:
<Button name="$parentButtonSoldier" hidden="false">
This line signifies the start of buttons used to choose the character's profession. Look for the ending </Button> shortly after the previous line you found and add the following code:
<Button name="$parentButtonTutorialProfession" hidden="false"> <Size> <AbsDimension x="52" y="51"/> </Size> <Anchors> <Anchor point="LEFT" relativeTo="$parentButtonSoldier" relativePoint="RIGHT"> <Offset> <AbsDimension x="3" y="0"/> </Offset> </Anchor> </Anchors> <NormalTexture name="$parentButtonTutorialProfessionDown" file="Interface\FantasyWorldIcons\ITEM_book_A"/> <HighlightTexture name="$parentTutorialProfessionUp" file="Interface\FantasyWorldIcons\ITEM_book_A"/> <Scripts language="python"> <OnClick>MvClassSelectionSoldier_OnClick(this)</OnClick> </Scripts> </Button>
This button will appear now on the page where a player creates their characters. If everything is working properly it should appear as a book with a rune on it, three pixels away from the current Soldier button. Since the character creation properties default to use "Tutorial Profession", then unless they click the soldier button during the creation process the character will automatically have that profession.
Adding skills and abilities
Now that you have created the basic profession, you are going to give the profession some capabilities.
A profession would not be complete without special skills and abilities that may or may not be specific to that profession. Lets come up with three basic skills and abilities that we can use for our tutorial class. Lets define the skills and abilities as this:
- Sword Skill - default ability: Pierce
- Magic Skill - default ability: Fireball
- Heal Skill - default ability: Heal
This simple list gives us both a skill and a default ability for that skill. It is important that you define a default ability for any skill you give the player, as when the player is given the skill it will provide them with that ability in their abilities bar.
Defining abilities
Lets start with the abilities first since the skills depend on them. Open your world's config folder's ability_db.py in your favorite editor and lets add the following code:
# Adding Tutorial Abilities
ability = MeleeCombatAbility("Pierce")
ability.setTargetType(MarsAbility.TargetType.ENEMY)
ability.setMaxRange(5000)
ability.setActivationEffect(Mars.EffectManager.get("default weaponskill effect"))
ability.addCoordEffect(MarsAbility.ActivationState.COMPLETED, attackEffect)
ability.setActivationCost(5)
ability.setCostProperty("stamina")
ability.setCompleteSound("swordhit.wav")
ability.setActivationTime(1000)
ability.setRequiredSkill(Mars.SkillManager.get("Sword"), 1)
ability.setIcon("Interface\FantasyWorldIcons\WEAPON_dagger_A")
Mars.AbilityManager.register(ability.getName(), ability)
ability = EffectAbility("Fireball")
ability.setActivationTime(3000)
ability.setActivationCost(10)
ability.setCostProperty("mana")
ability.setMaxRange(40000)
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, fireballCastingEffect)
ability.addCoordEffect(MarsAbility.ActivationState.COMPLETED, fireballTargetEffect)
ability.setRequiredSkill(Mars.SkillManager.get("Magic"), 1)
Mars.AbilityManager.register(ability.getName(), ability)
ability = EffectAbility("Heal")
ability.setTargetType(MarsAbility.TargetType.SELF)
ability.setMaxRange(1000)
ability.setActivationEffect(Mars.EffectManager.get("minor heal effect"))
ability.addCoordEffect(MarsAbility.ActivationState.COMPLETED, healCastingEffect)
ability.addCooldown(Cooldown("HEAL", 15000));
ability.setActivationCost(5)
ability.setCostProperty("stamina")
ability.setActivationTime(5000)
ability.setRequiredSkill(Mars.SkillManager.get("Heal"), 1)
ability.setIcon("Interface\FantasyWorldIcons\SPELL_heal_A")
Mars.AbilityManager.register(ability.getName(), ability)
Defining skills
Now we have the basic abilities for our skills. Now to create the skills. Open your world's config folder's skill_db.py in your favorite editor and lets add the following code:
# Adding skills for the tutorial
skill = MarsCombatSkill("Sword")
skill.setDefaultAbility("Pierce")
Mars.SkillManager.register(skill.getName(), skill)
skill = MarsCombatSkill("Magic")
skill.setDefaultAbility("Fireball")
Mars.SkillManager.register(skill.getName(), skill)
skill = MarsCombatSkill("Heal")
skill.setDefaultAbility("Heal")
Mars.SkillManager.register(skill.getName(), skill)
Adding skills and abilities to the profession
We now have our skill/ability tree that we want to apply to our profession. So now reopen the profession_db.py file, that is in your world's config folder, in your favorite editor, and modify your profession definition to look like the following:
# create a profession object
profession = ProfessionObject("Tutorial Profession")
# add skills to the profession
profession.addSkill("Sword")
profession.addSkill("Magic")
profession.addSkill("Heal")
# add abilities to the profession
profession.addAbility("Pierce")
profession.addAbility("Fireball")
profession.addAbility("Heal")
# Now register that profession with the classabilityplugin
ClassAbilityPlugin.registerProfession(profession)
Now you have a fully setup profession complete with the skills and abilities.
For more information on how players can gain access to new abilities and level up their skills, see MARS Experience System.
