Can't set actor values in function

Here is my main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <iostream>
#include <string>
#include "actor.h"
#include "LRPG_Functions.h"

using namespace std;

void setup_character(actor &a, int n)
{
    a.setexp(n);
    a.setlevel(a.getexp()%10);
    a.setcharisma(a.getlevel()*3);
    a.setconstitution(a.getlevel()*3);
    a.setdexterity(a.getlevel()*3);
    a.setintelligence(a.getlevel()*3);
    a.setMAX_hitpoints(a.getlevel() + (a.getconstitution() * 2));
    a.setstrength((a.getdexterity() + (a.getconstitution()*2))*10);
}

int main()
{
    string nname;
    //int llevel;
    int eexp;
    actor jo;
    actor *pete;
    pete = &jo;
    cin >> nname >> eexp;//llevel;
    jo.setname(nname);
    setup_character(jo,eexp);
    //cout << "name " << jo.getname() << "  " << "level " << pete->getlevel() << endl;
    //setlvl(jo,1);
    cout << "name " << jo.getname() << "  " << "level " << pete->getlevel() << endl;

    return 0;
}

My problem is that No matter what I put in as the experience, the level is always 0. Can someone tell me what I am doing wrong, please?
Are actor::setexp and actor::getexp working correctly?
They are just standard setter and getter member functions. They only set and get the data.

I did, however, realise that the modulo sign just presents the remainder and not the denominator. Doh! Another homer(read: noob) moment. It was working perfectly. I just had to change the equation to something that made sense. line 11 would actually be:
a.setlevel((25 + sqrt(625 + 100 * a.getexp())) / 50);
Last edited on
Topic archived. No new replies allowed.