1 C# Text RPG Project: Part 3 – toxia.net

C# Text RPG Project: Part 3

Okay, so no complete battle system yet… but I have some very nice screenshots to show!

Here is the complete class diagram thus far.

As you can see I have added in StatusEffects, before this all Characters had Boolean flags for things like Poisoned, Frozen, Stunned, etc. However now all Characters have 3 StatusEffects (which are all null by default) that can be assigned to specific buffs or debuffs when the time calls for it. StatusEffects also manage the duration (turns in battle mode) of the effect.

Both Spellbook and Inventory are implemented as Lists as well as just about all the methods they will need. Below is a test of the inventory, where the player is given 4 items and they are shown in the side inventory (as well as in more detail when the player inputs /inv in PlayMode), from there they can also select a specific item to view all it’s details and use/equip it if it has that option.

Comments 4

  • love you long time baby , you are very avg at cs:go

  • This looks really awesome. Its like D&D but text based and single player. Would seriously play this.

  • Looks cool; I’d consider reworking your inheritance when it comes to characters – both players and NPCs – as it feels a little as though you’ll be writing some stuff twice. Not a big issue though.

    The two things I’m more interested in are how you’re processing player input (not very interesting but there is one way involving Dictionaries and delegates that take param arrays of strings that I would consider superior to any alternative I can think of), and how you’re going to handle complex stuff when it comes to spell effects and player/weapon/armor passives. Again, if I were making this game, I’d make something like

    public delegate void Effect(Character source, Character target);

    Then every spell could create an anonymous Effect and you would have significantly more flexibility and expandability than if you just list bools for potential effects. This way, all you have to do is modify your parser (if you’re storing game mechanics data in files). If you’re not using files (easier but less maintainable), it’s even easier, because then you just modify your spell code on a case by case basis to do what you want. Say you want to have a spell that modifies whether or not a character is immune to frost; currently, you’d have to add a bunch of bool fields and then do something like this:

    Buff frostImmunity = new Buff() { AgIncrease = 0, HotHeal = 0, IntIncrease = 0, SpIncrease = 0, StrIncrease = 0, GrantFrostImmunity = true };

    And then you’d have to apply it to the player. The alternative would look more like this:

    Effect grantFrostImmunity = (source, target) => target.ImmuneToFrost = true;
    grantFrostImmunity(Player.GetPlayerByName(“Toxia”));

    An extension to these is for timed effects, you could always call the anonymous effect functions asynchronously and have timeouts inside them. For example, you could call it and just move onto other stuff, but behind the scenes, the anonymous function is making the target immune to frost, waiting 10 minutes, and then setting the player’s immunity to its original value again.

    You could have more complex ones too, if only Players are valid targets of an effect, you could do something like this:

    Effect clearPlayerInventory = (source, target) => if(target.GetType() != typeof(Player) throw new Exception(“Invalid target”) else ((Player)target).Inventory = new List();
    clearPlayerInventory(scarlett);

    So this would clear the inventory of a targeted player, but fail against anything that is not a player.

    Anyway, don’t let my suggestions put you off. It looks really cool and I’m pretty bored and thought you might like some suggestions…… like 16 months later….

    /gravedig

Leave a Reply