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 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
int freistoss (int posx, int posy, player_data player1[], player_data player2[]){
/*
player1: opfer
player2: tater
*/
struct player_data *pl1_data;
pl1_data= (struct player_data *) player1;
struct player_data *pl2_data;
pl2_data= (struct player_data *) player2;
int schutzeteam=pl1_data->team;
int twx;
double alpha, dist1, dist2;
if(schutzeteam==home){
alpha=pow((guestgoal-posx),2)+((36-posy)*(29-posy));
dist1=sqrt(abs(pow((guestgoal-posx),2) + pow(36-posy,2)));
dist2=sqrt(abs(pow((guestgoal-posx),2) + pow(29-posy,2)));
twx=guestgoal;
}else if(schutzeteam==guest){
alpha=pow((homegoal-posx),2)+((36-posy)*(29-posy));
dist1=sqrt(abs(pow((homegoal-posx),2) + pow(36-posy,2)));
dist2=sqrt(abs(pow((homegoal-posx),2) + pow(29-posy,2)));
twx=homegoal;
}
if(dist1==0){dist1=1;}else if(dist2==0){dist2=1;}
alpha=alpha/(dist1*dist2);
alpha=ceil(acos(alpha)*180/3.141592654);
double dist;
int twy, targety;
if(posy>36){dist=(floor(dist2));twy=31;targety=35;}
else if(posy<29){dist=(floor(dist1));twy=34;targety=30;}
/*
Schutze und TW heraussuchen
*/
struct player_data *his_data;
int t=0;
int mynum, twnum;
int playerteam=pl1_data->team;
// herausfinden wer schiesst
double maxstandard=0;
while(t<NUM_THREADS){
his_data = (struct player_data *) &player[t];
int histeam=his_data->team;
if(histeam==schutzeteam){
double standard=his_data->standard;
int schussg=his_data->schussg;
int schusskraft=his_data->schusskr;
if(standard>maxstandard && schussg!=0 && schusskraft!=0){
maxstandard=standard;
mynum=t;
}
}else if(histeam!=schutzeteam){
int pos=his_data->pos;
if(pos==1){
twnum=t;
}
}
t++;
}
// Spieler ausgesucht
// Schutze
struct player_data *schutz_data;
schutz_data = (struct player_data *) &player[mynum];
schutz_data->posx=posx;
schutz_data->posy=posy;
schutz_data->playerlock=1;
// TW
struct player_data *tw_data;
tw_data = (struct player_data *) &player[twnum];
tw_data->posx=twx;
tw_data->posy=twy;
tw_data->playerlock=1;
// Mauer aussuchen
t=0;
int count=0;
while(t<NUM_THREADS){
his_data = (struct player_data *) &player[t];
int histeam=his_data->team;
if(histeam!=schutzeteam){
int pos=his_data->pos;
if(pos!=1 && pos!=2 && count<=4){
count++;
if(twx==100){
his_data->posx=(posx+9);
his_data->posy=(posy-count);
}else if(twx==0){
his_data->posx=(posx-9);
his_data->posy=(posy-count);
}
his_data->playerlock=1;
}
}
t++;
}
// Strafraum
t=0;
int placeme, nolock;
while(t<NUM_THREADS){
his_data = (struct player_data *) &player[t];
int histeam=his_data->team;
int pos=his_data->pos;
if(histeam==schutzeteam){
if(pos!=1 && pos!=2){
placeme=1;
}
}
if(histeam!=schutzeteam){
int pos=his_data->pos;
if(pos!=4){
placeme=1;
}
}
nolock=his_data->playerlock;
if(placeme==1 && nolock==0){
if(twx==100){
his_data->posx=rand() % 100 + 84;
}else if(twx==0){
his_data->posx=rand() % 16 + 0;
}
his_data->posy=rand() % 52 +12;
his_data->playerlock=1;
}
t++;
}
printf("Flugkurve?");
// Flugkurve
/*
*dist: Distanz zum Tor
*alpha: Winkel
*targety: Ziel (y)
targetx: Ziel (x)
targetz: Ziel (z)
*s_schusskr: schusskraft schütze
*s_schussgen: schussgen schütze
int s_schusskr=schutz_data->schusskr;
int s_schussgen=schutz_data->schussg;
int s_technik=schutz_data->technik;
*/
printf("schusskraft: ");
int schusskr=schutz_data->schusskr;
int schussgen=schutz_data->schussg;
int technik=schutz_data->technik;
double standard=schutz_data->standard;
int fehlerx=0, fehlery=0, fehlerz=0, zufall=0, targetx=0, targetz=0;
//printf("standard: %lf\n", schusskr);
//printf("standard: %d\n", schusskr);
// Unlock players
t=0;
while(t<NUM_THREADS){
his_data = (struct player_data *) &player[t];
his_data->playerlock=0;
t++;
}
}
|