Chase.cpp : Flexible difficulty
1525 char dodgedrive(void)
1555 if(!activesquad->squad[driver]->skill_check(SKILL_DRIVING,DIFFICULTY_EASY))
1582 if(!encounter[driver].skill_check(SKILL_DRIVING,DIFFICULTY_EASY))If this were changed to...
1525 char dodgedrive(int risk_taken)
1555 if(!activesquad->squad[driver]->skill_check(SKILL_DRIVING,risk_taken))
1582 if(!encounter[driver].skill_check(SKILL_DRIVING,risk_taken))...then there's a basis for doing vehicular stunts that the chasers have to match to keep up.
Then, by rewriting obstacledrive()
char obstacledrive(short obstacle,char choice)
{
switch(obstacle)
{
case CARCHASE_OBSTACLE_CROSSTRAFFIC:
if(choice==0)
{
if(dodgedrive())return 1;
}
else if(choice==1)
{
clearmessagearea();
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(16,1);
addstr("You slow down, and turn the corner.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(17,1);
addstr("Here they come!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
}
break;
case CARCHASE_OBSTACLE_TRUCKPULLSOUT:
if(choice==0)
{
if(dodgedrive())return 1;
}
else if(choice==1)
{
clearmessagearea();
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(16,1);
addstr("You slow down, and carefully evade the truck.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(17,1);
addstr("Here they come!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
}
break;
case CARCHASE_OBSTACLE_FRUITSTAND:
if(choice==0)
{
if(dodgedrive())return 1;
}
else if(choice==1)
{
clearmessagearea();
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(16,1);
addstr("Fruit smashes all over the windshield!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(5))
{
set_color(COLOR_RED,COLOR_BLACK,1);
move(17,1);
addstr("The fruit seller is squashed!", gamelog);
gamelog.newline(); //All this logging and lining...
refresh();
getch();
criminalizeparty(LAWFLAG_MURDER);
}
}
break;
case CARCHASE_OBSTACLE_CHILD:
if(choice==0)
{
if(dodgedrive())return 1;
}
else if(choice==1)
{
clearmessagearea();
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(16,1);
addstr("You slow down and carefully avoid the kid.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_RED,COLOR_BLACK,1);
move(17,1);
addstr("The kid screams as a hail of gunfire breaks out!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
else
{
set_color(COLOR_GREEN,COLOR_BLACK,1);
move(17,1);
addstr("Both sides refrain from exchanging fire...", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
}
}
break;
}
return 0;
}
moving the choice above the switch, the "choice" can be put to work as a measure of how daring the driver wants to be.
char obstacledrive(short obstacle,char choice)
{
if (choice==0)//playing it safe
{
clearmessagearea();
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(16,1);
switch(obstacle)
{
case CARCHASE_OBSTACLE_CROSSTRAFFIC:
addstr("You slow down, and turn the corner.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(17,1);
addstr("Here they come!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
break;
case CARCHASE_OBSTACLE_TRUCKPULLSOUT:
addstr("You slow down, and carefully evade the truck.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_YELLOW,COLOR_BLACK,1);
move(17,1);
addstr("Here they come!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
break;
case CARCHASE_OBSTACLE_FRUITSTAND:
addstr("Fruit smashes all over the windshield!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(5))
{
set_color(COLOR_RED,COLOR_BLACK,1);
move(17,1);
addstr("The fruit seller is squashed!", gamelog);
gamelog.newline(); //All this logging and lining...
refresh();
getch();
criminalizeparty(LAWFLAG_MURDER);
}
break;
case CARCHASE_OBSTACLE_CHILD:
addstr("You slow down and carefully avoid the kid.", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
if(!LCSrandom(3))
{
set_color(COLOR_RED,COLOR_BLACK,1);
move(17,1);
addstr("The kid screams as a hail of gunfire breaks out!", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
enemyattack();
youattack();
}
else
{
set_color(COLOR_GREEN,COLOR_BLACK,1);
move(17,1);
addstr("Both sides refrain from exchanging fire...", gamelog);
gamelog.newline(); //New line.
refresh();
getch();
}
break;
//more cases here
}//end of switch
}
else//evasive driving
{
if(dodgedrive(choice))return 1;
}
return 0;
}
(0 and 1 reversed)
In functions like chasesequence(), obstacledrive() could then be called with either
obstacledrive(obstacle,0) for no risk or
obstacledrive(obstacle,DIFFICULTY_CONSTANT
) for various stunts.
Dodgedrive() could probably use a difficulty-switch to print a more impressive-sounding avoidance message depending on the stunt, and obstacledrive() maybe give juice for success.