cin problem

I'm making a calculator for dungeons and dragons. It's a house rule I'm using. I'm calculating the amount of impact force the enemies take as opposed to the swing of a bat. My problem is this: the code always designates person as 1, no matter what I put in. What am I missing here?

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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  #include <iostream>
#include <math.h>
#include <string>
#include <stdio.h>
using namespace std;
int main()
{
    int person;
    int weapon;
    int weight;
    float height;
    double gravity = 9.81;
    float densitya = 1.2754;
    double area;
    double drag = .5;
    float force;
    string name;
    double time;
    double velocity;
    float densityp = 990;
    float mass;
    double damage;
    cout << "Who is falling?" << endl;
    cout << "1 = Xaphe, 2 = Urg, 3 = Sprat, 4 = Dragon, 5 = Succubus, 6 = Babau" << endl;
    cin >> person;
    cout << endl;
    if (person = 1)
    {
               weight = 118;
               name = "Xaphe";
               mass = weight - (densityp*0.067);
    }
    else if (person = 2)
    {
               weight = 204;
               name = "Urg";
               mass = weight - (densityp*0.1);
    }
    else if (person = 3)
    {
               weight = 68;
               name = "Sprat";
               mass = weight - (densityp*0.067);
    }
    else if (person = 4)
    {
               weight = 27;
               name = "Dragon";
               mass = weight - (densityp*0.067);
    }
    else if (person = 5)
    {
               weight = 45;
               name = "Succubus";
               mass = weight - (densityp*0.067);
    }
    else if (person = 6)
    {
               weight = 60;
               name = "Babau";
               mass = weight - (densityp*0.067);
    }

    cout << "How many feet?" << endl;
    cin >> height;
    cout << endl;
    height = height * .3048;
    cout << "What are you hitting with?" << endl;
    cout << "1 = blade, 2 = fist/elbow, 3 = foot/big fist, 4 = butt, 5 = body, 6 = head" << endl;
    cin >> weapon;
    cout << endl;
    if (weapon = 1)
    {
               drag = .5;
               area = .30;
    }
    else if (weapon = 2)
    {
         drag = .5;
         area = .25;
    }
    else if (weapon = 3)
    {
         drag = .5;
         area = .25;
    }
    else if (weapon = 4)
    {
         drag = .5;
         area = .5;
    }
    else if (weapon = 5)
    {
         drag = .5;
         area = 1;
    }
    else if (weapon = 6)
    {
         drag = .5;
         area = .25;
    }
    time = sqrt(2*height/gravity);
    if (sqrt((2*mass*gravity)/(densitya*area*drag)) < sqrt(2*gravity*height))
    {
               velocity = sqrt((2*mass*gravity)/(densitya*area*drag));
    }
    else
    {
               velocity = sqrt(2*gravity*height);
    }
         force = mass*(velocity/.1) ;
         damage = force/6920.8;
         cout << name << " fell for " << time << " seconds at " << force << " Newtons. He takes " << height*3.28084/10 << " d6 of bludgeoning damage." << endl;
         cout << "Multiply your damage by " << damage << "." << endl;
         system ("PAUSE");
         
}
The operator for verifying equality in C++ is == (two 'equals'). One 'equal' means assignment.

so:

if (person == 1)
etc...
Oh I see. thank you!
Topic archived. No new replies allowed.