Jump to content

  • Log In with Google      Sign In   
  • Create Account


Modifiers on items


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 menyo   Members   -  Reputation: 428

Like
0Likes
Like

Posted 22 February 2014 - 08:50 AM

Hi, i am fiddling around with an old abandoned game project I wrote. I want to add modifiers on my weapons such as +10 to +20 damage or +4 to strength. I am already using an enum for attributes such as the players strength and dexterity or weapon requirements. Another enum for magic alignment such as fire and ice for spells and resistance. The weapon damage itself, gold cost, speed, etc are just fields within the weapon class.

 

I am looking for a clean way to add modifiers to my items. I was thinking of creating a new enum with all the attributes, magical alignments, players stats, damage, etc and use that enum in a struct with a value field to modify the corresponding thing to modify. However, I don't see this as a very clean way. Can anyone suggest a nice and elegant way to create such a modifier that has the ability to change all kind of different character stats?

 

Thank you,


Current Project: TechnoFlux read all about it on my

DEV BLOG


Sponsor:

#2 dmatter   Crossbones+   -  Reputation: 3043

Like
1Likes
Like

Posted 22 February 2014 - 12:25 PM

An enum is maybe not a bad way of doing it, I would say it depends on the number of things that would need to be included in the enum - if it's a lot of things and/or if the list of things to enumerate is tricky to keep in-sync with the attributes in the entity then it may be less appropriate.
 
Another way of doing it is to attach a modifier as a delegate/interface with a signature something like: void Modify(Entity e);

You could then attach modifiers e.g. weapon.AddModifier( new DamageModifier(10) );

#3 dejaime   Crossbones+   -  Reputation: 4012

Like
0Likes
Like

Posted 22 February 2014 - 12:31 PM

I'd probably use a vector of modifiers in my actors, and these modifiers would have their own type, data, duration and possibly override rules (like in only one dmg modifier at a time).

 

So all you'd need to do is add a new modifier to the that vector through a add function, and maybe remove any expired ones when updating the actor.






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS