I have no idea how yo fix this issue. it keeps telling me that I have no matching function to call to and it keeps saying no known conversion for argument 1 from 'Npc**' to 'Npc*
specifically, it's saying there's an issue with handleDialogueTwo(&nonplayer); and handleDialogueThree(&nonplayer);
I'm sure this is some dumb fix, but I've been scratching my head over it and shuffling things around for hours now. Please help
void Dungeon::handleRoomWithNpc(Room * room) {
Npc nonplayer = room->nonplayer.front();
cout << "Inside, you see a " << nonplayer.name << ".\n";
string actions[] = {
"a: Talk to " + nonplayer.name,
"b: Fight " + nonplayer.name,
"c: Leave",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueOne(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer.attack);
cout << nonplayer.name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else if (input == "c") {
player.changeRooms(player.previousRoom);
enterRoom(player.currentRoom);
return;
} else {
cout << "Wrongo, Bucko.\n";
}
}
}
void Dungeon::handleDialogueOne(Npc * nonplayer) {
cout << nonplayer->dialogueOne;
string actions[] = {
"a: continue",
"b: die",
"c: fight",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueTwo(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
}
} else if (input == "c") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else {
cout << "Wrongo, Bucko!\n";
}
}
}
void Dungeon::handleDialogueTwo(Npc * nonplayer) {
cout << nonplayer->dialogueTwo;
string actions[] = {
"a: continue",
"b: die",
"c: fight",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueThree(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
}
} else if (input == "c") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else {
cout << "Wrongo, Bucko!\n";
}
}
}
void Dungeon::handleDialogueThree(Npc * nonplayer) {
cout << nonplayer->dialogueThree;
string actions[] = {
"a: continue",
"b: die",
"c: win",
};
while(true) {
printActions(3, actions);
string input;
cin >> input;
if (input == "a") {
handleDialogueTwo(&nonplayer);
return;
} else if (input == "b") {
int damage = player.takeDamage(nonplayer->attack);
cout << nonplayer->name << " hits you for " << damage << " damage! \n";
if (player.checkIsDead()){
return;
};
} else if (input == "c") {
nonplayer->currentHealth = 0;
return;
} else {
cout << "Wrongo, Bucko!\n";
}
}
}
The data nonplayer
has type Npc *
and the type of the callee's argument is also Npc *
, so you won't need &
in handleDialogueTwo(&nonplayer);
and handleDialogueThree(&nonplayer);
. Remove them.