/////////////////////////////////////////////////////////// ////// Released under the GPL ////// see gpl.txt ////// Written by and copyrighted by: ////// Michael Gibson ////// (c)2003, 2004, 2006, 2007 /////////////////////////////////////////////////////////// /////////////////////////////// // attack_possible /////////////////////////////// int attack_possible(int player_1_x, int player_1_y, int player_1_exp, int player_1_wep, int player_2_x, int player_2_y, int player_2_charm){ // player 1 attacking player 2 // is it possible? int return_value=0; //default is 0 false // 0 out of range // 1 is possible; // 2 possible/limited // 3 not possible (spell); int x_diff; //difference between the two players x cord int y_diff; //difference between the two players y cord x_diff = player_1_x - player_2_x; y_diff = player_1_y - player_2_y; if(player_1_wep >= 1 && player_1_wep <= 5){ //if player 1 has hand to hand weapon if(x_diff <=1 && x_diff >= -1){ //if standing close enough... if(y_diff <=1 && y_diff >= -1){ return_value=1; //then player 1 can attack player 2 } } if(player_2_charm==1){ //is player you are attacking charmed? if(player_1_exp <= 30){ //does player 1 have enough experiance to attack a //charmed person? return_value=3; //no if not more than 30 experiance points } //end exp check } //end charmed check } //end of hand to hand check if(player_1_wep >=6 && player_1_wep <= 9){ //if player 1 has projection weapon if(x_diff <=3 && x_diff >= -3){ //if standing close enough... if(y_diff <=3 && y_diff >= -3){ return_value=1; //then player 1 can attack player 2 } } if(x_diff == 4 ){ //if standing 'just' close enough and only if(y_diff == 4 ){ //to one side return_value=2; //then player 1 can attack player 2 (but limited) } //just as this spot is. } } //end of projection check return(return_value); } //////////////////////////////////// // attack_success /////////////////////////////////// // this funtion returns if the player actually // hit the other player int attack_success(int player_1_dex, int player_1_adj_dex, int *player_1_wep_wear, int *player_1_exp, int player_2_dex, int player_2_total_armor){ int return_value=0; //simply returns 0 or 1 for failure or success int chance; int player_1_true_dex; player_1_true_dex= player_1_dex - player_1_adj_dex; //calculate player 1 true dex due to weapon. chance = rand()/((double)40 + 1); //calculate chance random number between 0-40 chance = chance + (player_1_true_dex - 5) - player_2_dex; //take into consideration players ability chance = chance - player_2_total_armor; //take into consideration player 2 armor if(chance >= 1) return_value=1; //attack is a success damage occured to other else return_value=0; //player failed to do damage to other if(return_value==1){ *player_1_wep_wear = *player_1_wep_wear - 1; //successfull use of weapon, account for wear *player_1_exp = *player_1_exp + 1; //increase experiance 1 unit for successful hit } return(return_value); }