Having trouble within a function

Hello all, I have been doing the tutorial from this website and i thought i was getting the hang of it until a couple of days ago i ran into a problem that has halted my work on my current project. The problem in question is line
58 and 67. This program is going to be a text based rpg. The current code compiles and runs except those 2 lines which tell the program if pc or creature has less then or 0 hit points then call function Dead(). The program totaly ignores those lines and fightning never ends unless you "run away", any help will be much appreciated.

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
void Melee()                            // ***** Melee To Hit/Miss *****
{
	int die; char menuChoice, magicChoice;

	die = rand() % 20+1;
     Bnpc.toHit = 20 - (Snpc.ac - Spc.agi);
	  Bpc.toHit = 20 - (Snpc.ac + Bnpc.weaBns);
   
	cout << "\n\n          *** The Battle Begins ***";

	
	 cout << "\n(A)ttack (C)ast spell (U)se item (R)un away :";    //Battle menu
	  cin >> menuChoice;

	if (menuChoice=='s') {    //Stats
	 CharStats();
	  Melee();
	}

	if (menuChoice=='a') {    //Attacking
	 cout << "\nYou need a " << Bpc.toHit << " to hit";
	  cout << "\nYou rolled : " << die;

	if (die<Bpc.toHit) cout << "\nMiss!";

    else { 
	 cout << "\nHit!!";
	  whoDam=1;
	   Damage(); 

	}

	die = rand() % 20+1;    //Creature attacks
	 cout << "\n\nThe creature requires " << Bnpc.toHit << " to hit you";
	  cout << "\nCreature rolls : " << die;
	if (die<Bnpc.toHit) cout << "\nMiss!";

	else { 
	 cout << "\nHit!!";
	  whoDam = 2;
	   Damage();
	}

    Melee();
}




void Damage()                           // ***** Calculate Weapon Damage *****
{
	int die; 
    
	if (whoDam==1) {    //Player hits, calculate damage
     die=rand()%(Bpc.maxWeaDam+Spc.agi)+1;
	  cout << "\nYou have caused " << die << " damage";
	   Snpc.hp-=die;
    if (Snpc.hp<=0) void Dead();

    return;
	}

	else die=rand()%Bnpc.maxWeaDam+1;    //Creature hits, calculate damage
	 cout << "\nThe creature has caused " << die << " damage";
	  Spc.hp-=die;
    
	if (Spc.hp<=0) void Dead();

	return;
}


remove the void keyword.

1
2
3
4
if (Snpc.hp <= 0) {
 Dead();
 return;
}
Topic archived. No new replies allowed.