RPG Campaign code

Discussion and development of scenarios and campaigns for the game.

Moderators: Forum Moderators, Developers

Post Reply
User avatar
RaptureChicken
Posts: 1
Joined: November 22nd, 2015, 3:37 am

RPG Campaign code

Post by RaptureChicken »

Hi, a friend and I want to make a campaign with a level up system for hero characters (possibly all player units).
We're also thinking of including inventory and branching dialogues but a level up system is the main thing.

I've played UtBS and a multiplayer scenario with Bob's RPG era (Both are really fun) so I was hoping there are macros for this and or big chunks of WML I can use.

Anyone have experience with this and can share best practices (Balancing, character archetypes, etc.)?
Are there other campaigns that use implement RPG gameplay?

Thanks

User avatar
Dugi
Posts: 4944
Joined: July 22nd, 2010, 10:29 am
Location: Carpathian Mountains
Contact:

Re: RPG Campaign code

Post by Dugi »

Getting an RPG working needs quite a lot of tricky code, it's nothing easy.

If you want more examples regarding inventory and level-up system, go check my campaign, Legend of the Invincilbles. It's not an RPG campaign, but it has many of those RPG features, more than UtBS or Bob's RPG Era. However, it's quite a complicated code. A few years ago, I stripped the code of the campaign and added it to the 1.10 server as a resource pack that adds items and some custom level-ups, you might want to simply reuse it without going too deep into the code.

User avatar
Heindal
Posts: 1011
Joined: August 11th, 2011, 9:25 pm
Location: Germany

Re: RPG Campaign code

Post by Heindal »

You might also look into Strange Legacy, as well as Five Fates.

For Five Fates I've did a lot there with advancement pathes, allowing the player to gain new useable, new recruitment and a lot of passive abilities. You might also look into burning sun, as well as glorius victus and the wesnoth amla section of the wiki.

The inventory concept isn't top notch, but it works. Always wanted to add that weapons can break or be cursed, but never worked that out. There are also macro for allowing enemies to do spellcasting. You can find them in the addons.

Strange Legacy is however a whole rpg world, with macros for missions, random events, increased difficulty and so on - I'm not quite sure if that is what you are looking for.


Here is an example from five fates, which might show how to build units with amla pathes.

Code: Select all

#Based on Wesnoth Amla the scenario Glorius Victus and Burning Sun

[unit_type]
    id=Bandithero
    name= _ "Bandithero"
    image="units/human-outlaws/highwayman.png"
    profile="portraits/humans/bandit.png~RIGHT()"
    profile="portraits/humans/bandit.png"
    hitpoints=70
    movement_type=smallfoot
    movement=7
    experience=20
    level=3
    alignment=chaotic
    advances_to=null
    usage=fighter

    description= _ "Scarface was once a gladiator in an underground arena. Escaping from this horrible place, he has achieved a willpower beyond normal. He might not only learn to resist poison and take hard hits, he may also learn and remember some old gladiator tricks that might come in handy. He is the slowest of the characters and can only develop his melee abilities, thats his drawback."
    die_sound={SOUND_LIST:HUMAN_DIE}
    {DEFENSE_ANIM "units/human-outlaws/highwayman-defend-1.png" "units/human-outlaws/highwayman-defend-2.png" {SOUND_LIST:HUMAN_HIT} }
    [portrait]
        size=400
        side="left"
        mirror="false"
        image="portraits/humans/transparent/bandit.png"
    [/portrait]
    [portrait]
        size=400
        side="right"
        mirror="true"
        image="portraits/humans/transparent/bandit.png"
    [/portrait]
    [attack]
        name=mace
        description= _ "mace"
        icon=attacks/mace.png
        type=impact
        range=melee
        damage=11
        number=3
    [/attack]
    [attack_anim]
        [filter_attack]
            range=melee
        [/filter_attack]
        offset=0.0~0.2,0.2~0.6,0.6~0.4,0.4~0.0
        start_time=-500
        {SOUND:HIT_AND_MISS mace.wav {SOUND_LIST:MISS} 500}
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-1.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-2.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-3.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-4.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-5.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-6.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-7.png"
        [/frame]
        [frame]
            duration=100
            image="units/human-outlaws/highwayman-melee-8.png"
        [/frame]
    [/attack_anim]

    # abbilties bandit

    [advancement]
        id=hardinesspath0
        max_times=1
        strict_amla=no
        description= _ "Hardiness - Path (1): Steadfast and Higher Resistance"
        image=icons/shield_tower.png

        always_display=yes
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_STEADFAST}
            [/abilities]
        [/effect]
        [effect]
            apply_to=resistance
            replace=false
            [resistance]
                blade=-10
                pierce=-10
                impact=-10
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=hardinesspath1
        max_times=1
        strict_amla=no
        require_amla=hardinesspath0
        description= _ "Hardiness - Path (2): 15% more hitpoints"
        image=icons/potion_red_medium.png

        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total=15%
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
    [/advancement]

    [advancement]
        id=hardinesspath2
        max_times=1
        strict_amla=no
        require_amla=hardinesspath1
        description= _ "Hardiness Path (3): Poison Immunity"
        image=icons/jewelry_butterfly_pin.png

        always_display=yes
        [effect]
            apply_to=new_ability
            [abilities]
                [heals]
                    id=curing
                    name= _ "Poison Immunity"
                    affect_self=yes
                    poison=cured
                [/heals]
            [/abilities]
        [/effect]
        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=hardinesspath3
        max_times=1
        strict_amla=no
        require_amla=hardinesspath2
        description= _ "Hardiness Path (4): Higher Force Resistance"
        image=icons/cuirass_leather_studded.png

        always_display=yes
        [effect]
            apply_to=resistance
            replace=false
            [resistance]
                blade=-15
                pierce=-15
                impact=-15
            [/resistance]
        [/effect]
        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=hardinesspath4
        max_times=1
        strict_amla=no
        require_amla=hardinesspath3
        description= _ "Hardiness Path (5): Regeneration"
        image=attacks/fist-troll.png

        always_display=yes
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_REGENERATES}
            [/abilities]
        [/effect]
        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=hardinesspath5
        max_times=1
        strict_amla=no
        require_amla=hardinesspath4
        description= _ "Hardiness - Path (6): 25% more hitpoints"
        image=icons/potion_red_medium.png

        always_display=yes
        [effect]
            apply_to=hitpoints
            increase_total=25%
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath1
        max_times=1
        strict_amla=no
        description= _ "Weapon Path (1): Higher Melee Damage and Combat Focus"
        image=attacks/hammer-troll.png

        [effect]
            apply_to=attack
            range=melee
            increase_damage=3
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=extradamagemelee
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Combat Focus
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath2
        max_times=1
        strict_amla=no
        require_amla=weaponpath1
        description= _ "Weapon Path (2): Extra Strike for Melee Weapons"
        image=attacks/claws-undead.png

        [effect]
            apply_to=attack
            range=melee
            increase_attacks=1
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=extrastrikesmelee
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath3
        max_times=1
        strict_amla=no
        require_amla=weaponpath2
        description= _ "Weapon Path (3): Strong Slowing Attack"
        image=attacks/ram.png

        [effect]
            apply_to=new_attack
            name=Head Butt
            description= _"Head Butt"
            icon=attacks/ram.png
            type=impact
            range=melee
            damage=25
            number=1
            [specials]
                {WEAPON_SPECIAL_SLOW}
            [/specials]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=slowpath
        max_times=1
        strict_amla=no
        require_amla=weaponpath3
        description= _ "Upgrade Head Butt: Adds Splashslow to Slowing attack"
        image=attacks/ram.png

        [effect]
            apply_to=attack
            name=Head Butt
            [set_specials]
                mode=append
                {WEAPON_SPECIAL_SPLASHSLOW}
            [/set_specials]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath4
        max_times=1
        strict_amla=no
        require_amla=weaponpath3
        description= _ "Weapon Path (4): Risky, Sneak Attack"
        image=attacks/staff-green.png

        [effect]
            apply_to=new_attack
            name=Silent Killer
            description= _"Silent Killer"
            icon=attacks/spear.png
            type=pierce
            range=melee
            damage=15
            number=2
            [specials]
                {WEAPON_SPECIAL_CHARGE}
                {WEAPON_SPECIAL_BACKSTAB}
            [/specials]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Killer
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath5
        max_times=1
        strict_amla=no
        require_amla=weaponpath4
        description= _ "Weapon Path (5): Berserker Aspect"
        image=attacks/axe.png

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Berserkeraspect
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=25%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath6
        max_times=1
        strict_amla=no
        require_amla=weaponpath5
        description= _ "Weapon Path (6): Weapon Poison"
        image=attacks/fangs-snake.png

        [effect]
            apply_to=attack
            range=melee
            [set_specials]
                mode=append
                {WEAPON_SPECIAL_POISON}
            [/set_specials]
        [/effect]

        [effect]
            to=max_experience
            increase=50%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Poison Master
                    description="You are a master of poison beeing able to produce weaponpoison and poison bombs."
                [/dummy]
            [/abilities]
        [/effect]
    [/advancement]

    [advancement]
        id=weaponpath7
        max_times=1
        strict_amla=no
        require_amla=weaponpath6
        description= _ "Weapon Path (7): Advanced Poisonbomb (slightly damages an area and poisons several targets)"
        image=attacks/fangs-snake.png

        [effect]
            to=max_experience
            increase=50%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Poisonbomb
                    description="You are able to throw Poisonsbombs."
                [/dummy]
            [/abilities]
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath1
        max_times=1
        strict_amla=no

        description= _ "Thieves Path (1): Hire Thieves"
        image=units/human-outlaws/thief.png

        always_display=yes
        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Thieves
                    description="Your reputation has convinced additional units to help you. As your reputation grows you can hire better units."
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath2
        max_times=1
        strict_amla=no
        require_amla=thievespath1
        description= _ "Thieves Path (2): Hire Footpads"
        image=units/human-outlaws/footpad.png
        always_display=yes

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Thieves2
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath3
        max_times=1
        strict_amla=no
        require_amla=thievespath2
        description= _ "Thieves Path (3): Hire Poacher"
        image=units/human-outlaws/poacher.png
        always_display=yes

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Thieves3
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=20%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath4
        max_times=1
        strict_amla=no
        require_amla=thievespath3
        description= _ "Thieves Path (4): The perfect leader?"
        image=units/human-outlaws/highwayman-melee-6.png
        always_display=yes

        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_SKIRMISHER}
            [/abilities]
        [/effect]
        [effect]
            apply_to=movement
            increase=2
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Flee
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath5
        max_times=1
        strict_amla=no
        require_amla=thievespath4
        description= _ "Thieves Path (5): Hire Bandits"
        image=units/human-outlaws/bandit.png
        always_display=yes

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Thieves4
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        id=thievespath6
        max_times=1
        strict_amla=no
        require_amla=thievespath5
        description= _ "Thieves Path (6): Presence of Fear"
        image=attacks/gaze.png

        always_display=yes
        [effect]
            apply_to=new_ability
            [abilities]
                {ABILITY_PRESENCEOFFEAR}
            [/abilities]
        [/effect]

        [effect]
            apply_to=new_ability
            [abilities]
                [dummy]
                    id=Fear
                [/dummy]
            [/abilities]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=30%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        strict_amla=yes
        max_times=100
        description= _ "Standard Advance: Movement Increase"
        image=icons/boots_elven.png
        [effect]
            apply_to=movement
            increase=1
        [/effect]
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        strict_amla=yes
        max_times=100
        description= _ "Standard Advance: Light Hitpoint Increase"
        image=icons/potion_red_small.png
        [effect]
            apply_to=hitpoints
            increase_total=5%
            heal_full=yes
        [/effect]
        [effect]
            apply_to=max_experience
            increase=10%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]

    [advancement]
        strict_amla=yes
        max_times=100
        description= _ "Bandit Advance: Slightly Improved Resistance"
        image=icons/merc.png

        [effect]
            apply_to=resistance
            replace=false
            [resistance]
                blade=-1
                pierce=-1
                impact=-1
                fire=-1
                cold=-1
                arcane=-1
            [/resistance]
        [/effect]

        [effect]
            apply_to=max_experience
            increase=15%
        [/effect]
        [effect]
            apply_to=hitpoints
            heal_full=yes
        [/effect]
    [/advancement]
[/unit_type]
Btw. Legend of the Invincibles is really worth to check out ^^.
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses

User avatar
Xudo
Posts: 561
Joined: April 3rd, 2009, 5:26 pm

Re: RPG Campaign code

Post by Xudo »

Basic inventory is actually a set of messages with dynamic [option]'s.
You need to understand arrays, loops, units storing/modifying/unstoring and [insert_tag].

Post Reply