CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2008
    Posts
    154

    Multiplying Values in a STRUCT

    I find Structs a little intimidating, and I am unsure how to approach this problem.

    I have a Struct of ints called StatisticsValue
    it hold stuff like
    int Hitpoints
    int MagicPoints
    int Strength....etc

    I have a Spell and spells affect 1 or more values in the StatisticsValue

    this gathers them
    StatisticsValue statEffect = spell.TargetEffectValue;

    but I need to multiply those statEffects by a modifier and doing it directly doesn't work.

    int modifiedEffect = Math.Abs(statEffect * ARCmodifier);

    My question is how do I multiply all of the possible values the Spell is effecting by the modifer int. And how do I know it doesn't modify all of the values in StatisticsValue???

    for instance a spell might alter Strength and Hitpoints, but ignore everything else.

  2. #2
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Multiplying Values in a STRUCT

    First ensure, that you understood the semantic difference between value types (struct) and reference types (class); look e.g. here.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured