Author: YinYin Language: c Description: Not specified Timestamp: 2013-06-13 17:53:46 +0000
 View raw paste Reply
1. // CRUSHER 1.0
2. // Designed for Davis
3. // Made by YinYin
4.
5. //davisspecials
6. int ego(){
7. if(rand(22)+1>10*(difficulty)){
8.  //define variables
9.  int sfac = 2*(self.facing?1:0)-1;              //own direction (-1: left, 1: right)
10.  int tfac = 2*(target.facing?1:0)-1;           //target direction (-1: left, 1: right)
11.  int bfac = (self.facing?1:0)+(target.facing?1:0)-1;//both facing (-1: left, 0: against, 1: right)
12.  int stxd = self.x-target.x;           //x distance (left > 0 > right)
13.  int styd = self.y-target.y;          //y distance (above > 0 > below)
14.  int stzd = abs(self.z-target.z);    //z distance
15.  int dist = stxd*sfac;              //directional distance
16.  int tmp = target.mp;
17.  int smp = self.mp;
18.
19.  if(self.bdefend>0&&frame(self.num,110,111)&&range(0,80,dist)&&stzd<=13){DdA();return 1;}
20.  //no mp combo
21.  if (dist >= 0 && target.state == 12 && styd > 60 && styd < 90){
22.   if (self.state <= 1){if (stxd > 0){left();}else {right();}return 1;}//run
23.   else if (self.state == 2){A();return 1;}                           //attack
24.  }//grab combo
25.  if (self.frame == 121 && self.ctimer < 50){DdA();}
26.   //blasts
27.  if (target.id!=8&&dist >= 600 && stzd <= 40 && self.state <= 1){DfA();}
28.  else if (dist > 700 && stzd <= 40 && self.frame >= 240 && self.frame <= 264){A();}
29.  else if (self.frame >= 240 && self.frame <= 264){return 1;}
30.  //combo breaker
31.  if (stzd < 10 && dist < 75 && dist >= -5 && target.y == 0 && (self.frame == 111 || self.state == 8 || self.state == 11 || self.state == 16)){
32.   if (smp >= 225 && self.frame != 111){DuA();}else if (smp >= 75 && self.frame == 111 && (tmp < 193 || smp >= 293)){DdA();}else if (((target.frame >= 280 && target.frame <= 278 && smp >= 225) || tmp < 70) && (target.frame < 70 && target.frame > 72)){D();}return 1;
33.  }//flip
34.  else if (self.state == 12){
35.   if (target.frame == 301 || (target.frame >= 290 && target.frame <= 293) || target.frame == 75){J();}
36.  }//dash, roll
37.  else if (self.frame == 215 && self.bdefend >= 20){
38.   if (dist > 0 && target.frame < 290 && target.frame > 293){J();}else {D();}
39.  }
40.  //facing
41.  if (bfac != 0 && self.state == 7 && stzd < 10 && target.y == 0){//defense
42.   if (sfac < 0){left();}else {right();}//turn
43.  }
44.  else if (stzd < 10 && dist < 0 && self.state != 1 && self.state != 7){//normal
45.   if (stxd > 0){left();}else {right();}//turn
46.  }
47.  //defending
48.  if (stzd < 10 && self.state != 7 && target.state == 3 && abs(dist) < 100 && target.y == 0 && ((target.frame >= 280 && target.frame <= 278 && smp >= 225) || tmp < 70) && (target.frame < 70 && target.frame > 72)){D();}//combos
49.  else if (stzd < 10 && dist < 70 && dist >= -5){
50.   if (target.hp > 0 && target.hp <= 114 && smp >= 225 && target.state != 12 && target.state != 7){DuA();return 1;}//finisher
51.   else if (self.frame == 39 && target.state == 12){J();return 1;}                                                 //super combo
52.   else if ((self.frame == 278 || self.frame == 279) && tmp >= 225 && target.shake > 0){DuA();return 1;}           //safe combo
53.   else if ((target.state == 16 || target.state == 8) && smp >= 150 && (tmp < 193 || smp >= 293)){DdA();return 1;} //starter
54.   else if (target.state == 16 && self.state == 0 && tmp >= 225){if (stxd > 0){left();}else {right();}return 1;}    //grab
55.   else if ((self.frame == 281 || self.frame == 282) && target.state == 12){if (smp >= 450){DuA();return 1;}       //doubleDstart
56.    else if (smp >= 100){J();return 1;}else if (stxd > 0){left();}else {right();}return 1;}                          //low mp start
57.   else if (target.hp > 0 && target.state == 12 && styd > 90 && self.frame == 215 && smp >= 225){DuA();return 1;}  //double dragon
58.   else if ((target.frame == 181 || target.frame == 187) && target.hp > 0 && smp >= 225){DuA();return 1;}          //fall dragon
59.  }
60.  //opportunities
61.  if (self.state == 5 || self.state == 9 || (self.frame == 292 && styd < 7)){//dash,grab,leap attack
62.   if ((target.hp <= 138 || self.ctimer < 40) && self.state == 9 && smp >= 300){DdA();}      //finisher
63.   else if ((target.hp <= 114 || self.ctimer < 40) && self.state == 9 && smp >= 225){DuA();}//finisher
64.   else if (self.ctimer < 40 && self.state == 9 && smp >= 75 && tmp < 225){DdA();return 1;}//end
65.   else {A();}return 1;}                                                                  //attack
66.   else if (self.frame == 292 || frame(self.num,85,109) || self.frame == 284){return 1;} //wait
67.  //void unwanted inputs
68.  if (self.DrA >= 2 || self.DlA >= 2 || self.DuA >= 2 || self.DdA >= 2 || self.DuJ >= 2){
69.   if (self.z - target.z < 0){down();}else {up();}
70.  }
71. }
72.  return 0;
73. }
74. //davisspecials
75.
76. void id(){//main function
77. //add full object loading sequence
78. //create target selection
79. //create ego wrapper
80. //create moving functions/approaching/fleeing/waiting
81.    inputs();
82.    array<array<int>>o=get_objects();
83.    if(stage_clear){right();down();}
84.    else if(stall(o[0][0]))return;
85.    else if(rebound(o[0][0]))return;
86.    else if(dodge(o[0]))return;
87.
88.    if(is_opponent(o[1][0])){
89.       loadTarget(o[1][0]);
90.       if(ego()==0&&target.hp>0){
91.          approach_opponent(o[1][0]);
92.          if(rand(22)+1>10*(difficulty))act(o[1][0]);
93.       }
94.    }
95. }
96.
97. //oldstuff
98. bool facing_against(){
99.    //true if self and target face opposite directions
100.    //add variable objects
101.    return (self.facing!=target.facing)?true:false;
102. }
103. void DfA(){
104.    if(xdistance(self.num,target.num) > 0){DrA();}
105.    else{DlA();}
106. }
107. bool frame(int i, int min, int max){
108.    //true if between min and max
109.    if(!is_object(i)){return false;}
110.    return range(min,max,target.frame);
111. }
112. void act(int o){
113.   if(target.state!=14&&target.blink==0){
114.    //special moves, attacking, jumping, picking, combos, etc, ...
115.    if(target.state!=3&&target.state!=2&&target.frame!=213&&range(100,180+abs(self.x_velocity),abs(xdistance(self.num,o)))&&range(0,40+abs(self.z_velocity),abs(zdistance(self.num,o)))){
116.          if(self.state<=1){run();}
117.          else if(self.state==2){J();A();}
118.    }
119.    else if(opponent_close(o)){attack();}
120.   }
121. }
122. bool opponent_close(int i){
123.    //true if opponent in range
124.    //pass object number and ranges
125.    return (loadTarget(i)==0&&range(0,80,abs(xdistance(self.num,target.num)))&&range(0,15,abs(zdistance(self.num,target.num))))?true:false;
126. }
127. void attack(){
128.    //attack towards target
129.    if(facing_distance(self.num,target.num)>0){turn();}
130.    if(target.state==16){DdA();}
131.    else{A(1,0);}
132. }
133. int facing_distance(int s, int t){
134.    //positive: target distance to the front
135.    return xdistance(s,t)*(2*(self.facing?1:0)-1);
136. }
137. void approach_opponent(int o){
138.    //approach opponent, be aware of item?
139.    if(is_opponent(o)&&(target.state==14||target.blink!=0)){
140.           if(target.id==4||target.id==5){move_towards(o);}
141.       else{move_away(o);}
142.    }
143.    else if(!range(0,5,abs(zdistance(self.num,o)))||!range(0,65,abs(xdistance(self.num,o)))){
144.       if(self.state<=1&&!range(0,300,abs(xdistance(self.num,o)))&&facing_towards()){run();}
145.       else if(self.state<=1&&!range(0,80,abs(xdistance(self.num,o)))){move_above(o);}
146.           else{move_towards(o);}
147.    }
148. }
149. void run(){
150.    //run forward
151.    if(self.facing==false){right(1,0);}else{left(1,0);}
152. }
153. bool facing_towards(){
154.    //true if self faces target
155.    //add variable objects
156.    return ((self.facing?-1:1)*xdistance(self.num,target.num)>0)?true:false;
157. }
158. void move_above(int i){
159.    //walk above target i
160.    //add desired x and z distances
161.    if(!range(0,10+abs(self.x_velocity),abs(xdistance(self.num,i)))){
162.       if(xdistance(self.num,i)<0){left(1,1);}else{right(1,1);}
163.    }
164.    if(range(0,30+abs(self.z_velocity),abs(zdistance(self.num,i)))){
165.       if(zdistance(self.num,i)<0){down(1,1);}else{up(1,1);}
166.    }
167. }
168. void move_away(int i){
169.    //walk away from target i
170.    //add desired x and z distances
171.       if(xdistance(self.num,i)<0){right(1,1);}else{left(1,1);}
172.       if(zdistance(self.num,i)<0){down(1,1);}else{up(1,1);}
173. }
174. void move_towards(int i){
175.    //walk towards target i
176.    //add desired x and z distances
177.    if(!range(0,60+18*(difficulty-2)+abs(self.x_velocity),abs(xdistance(self.num,i)))){
178.       if(xdistance(self.num,i)<0){left(1,1);}else{right(1,1);}
179.    }
180.    if(!range(0,10+abs(self.z_velocity),abs(zdistance(self.num,i)))){
181.       if(zdistance(self.num,i)<0){up(1,1);}else{down(1,1);}
182.    }
183. }
184. bool range(int min, int max, int i){
185.    //true if i is between min and max
186.    //make frame use the same form
187.    return (i>=min&&i<=max)?true:false;
188. }
189. int xdistance(int s, int t){
190.    //x distance between s and t
191.    loadTarget(s);
192.    int sx=target.x;
193.    loadTarget(t);
194.    int tx=target.x;
195.    return tx-sx;
196. }
197. int zborder1(int z){
198.    //z distance to the top
199.    return z-bg_zwidth1;
200. }
201. int zborder2(int z){
202.    //z distance to the bottom
203.    return bg_zwidth2-z;
204. }
205. int zdistance(int s, int t){
206.    //z distance between s and t
207.    loadTarget(s);
208.    int sz=target.z;
209.    loadTarget(t);
210.    int tz=target.z;
211.    return tz-sz;
212. }
213. //oldstuff
214.
215. void defend(int i){//turn against i and defend
216.    if(!facing_against(i)){turn();}
217.    D(1,0);
218. }
219.
220. void forward(){//press forward direction
221.    forward(1);
222. }
223. void forward(int h){//press forward direction
224.    if(self.facing){left(1,h);}else{right(1,h);}
225. }
226.
227. void towards(int i){//move towards object i
228.    towards(i,1);
229. }
230. void towards(int i, int h){//move towards object i
231.    if(facing_towards(i)){forward(h);}else{turn();}
232.    if(self.z<game.objects[i].z)down(1,h);
233.    else if(self.z>game.objects[i].z)up(1,h);
234. }
235.
236. void inputs(){//void inputs
237.    up(0,0);down(0,0);left(0,0);right(0,0);D(0,0);J(0,0);A(0,0);
238. }
239.
240. void turn(){//press opposite direction
241.    if(self.facing){right(1,0);}else{left(1,0);}
242. }
243.
244. bool dodge(int[] i){//dodge attack
245.    if(!is_reboundable(i[0])&&i[1]>=dodge_time(i)&&i[3]!=-1){
246.       if(is_chase(i[0])){towards(i[0],0);return true;}
247.       if((i[3]<self.z||i[3]<=bg_zwidth1+15)&&i[3]<=bg_zwidth2-15)down();
248.       else up();
249.           return true;
250.    }
251.    return false;
252. }
253.
254. bool facing_against(int i){//check if facing against i
255.    if(has_direction(i))return (self.facing!=game.objects[i].facing)?true:false;
256.    return facing_towards(i);
257. }
258.
259. bool facing_towards(int i){//true if self faces target
260.    return ((self.facing?-1:1)*(self.x-game.objects[i].x)<0)?true:false;
261. }
262.
263. bool has_direction(int i){//true if the object has an attack relevant direction
264.    if(game.objects[i].throwinjury!=0||game.objects[i].data.frames[game.objects[i].frame1].state==18)return false;
265.    return true;
266. }
267.
268. bool has_gravity(int i){//true if a character i has gravity
269. //add other object types - return gravity value instead
270.    return is_character(i)&&game.objects[i].y<0;
271. }
272.
273. bool intersect(int[] a, int[] b){//check if spaces a and b intersect
274.  if(a[1]<b[0]||
275.   b[1]<a[0]||
276.   a[2]>b[3]||
277.   b[2]>a[3]||
278.   a[4]>b[5]||
279.   b[4]>a[5]||
280.   (a[0]==a[1]&&a[1]==a[2]&&a[2]==a[3]&&a[3]==a[4]&&a[4]==a[5])||
281.   (b[0]==b[1]&&b[1]==b[2]&&b[2]==b[3]&&b[3]==b[4]&&b[4]==b[5])){return false;}
282.  return true;
283. }
284.
285. bool is_character(int i){//true if i is a character
286.    return (is_object(i)&&game.objects[i].data.type==0)?true:false;
287. }
288.
289. bool is_chase(int i){//true if i is a chase
290.    if(!is_character(i)&&(game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==1||
291.       game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==2||
292.           game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==3||
293.           game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==4||
294.           game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==10||
295.           game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==12||
296.           game.objects[i].data.frames[game.objects[i].frame1].hit_Fa==14))return true;
297.    return false;
298. }
299.
300. bool is_object(int i){//true if i is an object
301.    return game.exists[i];
302. }
303.
304. bool is_opponent(int i){//true if i is a character
305.    return (is_character(i)&&game.objects[i].hp>0&&game.objects[i].team!=self.team)?true:false;
306. }
307.
308. bool is_reboundable(int i){//true if i is reboundable
309.    return (is_object(i)&&!is_character(i)&&game.objects[i].data.frames[game.objects[i].frame1].state==3000)?true:false;
310. }
311.
312. bool is_stoppable(int i){//true if i is reboundable
313.    return (is_object(i)&&!is_character(i)&&game.objects[i].data.frames[game.objects[i].frame1].state<=3000&&game.objects[i].data.frames[game.objects[i].frame1].state!=1004&&game.objects[i].data.frames[game.objects[i].frame1].state!=2004)?true:false;
314. }
315.
316. bool rebound(int i){//stop/rebound projectiles
317. //pass on attack array
318. //replace time_till_impact with loaded object parameters
319. //create attack() function and item picking check
320.    //difficulty barrier
321.    if(rand(difficult2(0))>3)return false;
322.    //reboundable without risk
323.    if(is_stoppable(i)&&
324.    time_till_impact(i, self.num)>attack_startup(self.num,self.frame)&&
325.    time_till_impact(self.num, get_attack_frame(self.num,self.frame), i, -1)<attack_startup(self.num,self.frame)){
326.       A();return true;
327.    }
328.    return false;
329. }
330.
331. bool stall(int i){//minimize damage
332. //pass on attack array
333. //replace time_till_impact with loaded object parameters
334.    //difficulty barrier
335.    if(rand(difficult2(0))>3)return false;
336.    //always flip to avoid throwinjury
337.    if(game.objects[self.num].throwinjury!=0&&(self.frame==182||self.frame==188)){J();return true;}
338.    else if(!is_object(i))return false;
339.    //determine reaction speed
340.    if(time_till_impact(i, self.num)<=difficult(1)){
341.       //defend or roll
342.       if(self.state<=2||self.frame==215){defend(i);return true;}
343.           //flip
344.       if(self.frame==182||self.frame==188){J();return true;}
345.    }
346.    return false;
347. }
348.
349. int attack_startup(int o, int f){//time it takes to perform a basic attack
350.    int t=0;
351.    if(get_attack_start(o,f)!=-1){
352.       for(int i = get_attack_start(o,f); i < 400; i=game.objects[o].data.frames[i].next){
353.              t+=game.objects[o].data.frames[i].wait;
354.                  if(game.objects[o].data.frames[i].itr_count>0&&game.objects[o].data.frames[i].itrs[0].kind==0){
355.                     return t;
356.              }
357.           }
358.    }
359.    return 31;
360. }
361.
362. int difficult(int i){//translate difficulty into values: 0,2,4,6 or 1,3,5,7 or ...
363.    return 2*difficulty+2+i;
364. }
365. int difficult2(int i){//translate difficulty into values: 0,4,16,36 or 1,9,25,49 or ...
366.    return difficult(i)*difficult(i);
367. }
368.
369. int dodge_time(int[] i){//returns time it takes to dodge
370. //somewhat imprecise, more z speeds to add
371.    float z=game.objects[self.num].data.frames[self.frame].dvz;
372.    if(self.state<2)z=game.objects[self.num].data.walking_speedz;
373.    else if(self.state==2)z=game.objects[self.num].data.running_speedz;
374.    for(int t = 0; t < 31; ++t){
375.       if(self.z+z*4*t>i[3]+i[2])return t;
376.       if(self.z-z*4*t<i[3]-i[2])return t;
377.    }
378.    return 31;
379. }
380.
381. int get_attack_frame(int o, int f){//get attack frame for object o in frame f
382.    if(get_attack_start(o,f)!=-1){
383.       for(int i = get_attack_start(o,f); i < 400; i=game.objects[o].data.frames[i].next){
384.                  if(game.objects[o].data.frames[i].itr_count>0&&game.objects[o].data.frames[i].itrs[0].kind==0){
385.                     return i;
386.              }
387.           }
388.    }
389.    return 0;
390. }
391.
392. int get_attack_start(int o, int f){//get attack start for object o in frame f
393. //include random frame 65, super punch 70, weapon attacks
394.    if(game.objects[o].weapon_type==0){
395.       if(game.objects[o].data.frames[f].state<=1)return 60;
396.       else if(game.objects[o].data.frames[f].state==2)return 85;
397.       else if(game.objects[o].data.frames[f].state==4)return 80;
398.       else if(game.objects[o].data.frames[f].state==5)return 90;
399.    }
400.    return -1;
401. }
402.
403. int square_distance(int i, int o){//returns squared distance between object i and o
404.    return(
405.    ((game.objects[i].x-game.objects[o].x)*(game.objects[i].x-game.objects[o].x))
406.    +((game.objects[i].y-game.objects[o].y)*(game.objects[i].y-game.objects[o].y))/3
407.    +3*((game.objects[i].z-game.objects[o].z)*(game.objects[i].z-game.objects[o].z)));
408. }
409.
410. int time_till_impact(int o, int x){//returns time till impact of o on x
411. //remove when replaced with get_attack_info
412.    return time_till_impact(o, game.objects[o].frame1 ,x ,game.objects[x].frame1);
413. }
414. int time_till_impact(int o, int fo, int x, int fx){//returns time till impact of o in frame fo on x in frame fi
415. //remove when replaced with get_attack_info
416.    if(fo==-1)fo=game.objects[o].frame1;
417.    if(fx==-1)fx=game.objects[x].frame1;
418.    if(is_object(x)&&o!=x&&is_object(o)){
419.       if(game.objects[x].data.frames[fx].bdy_count>0&&game.objects[x].vrest==0&&game.objects[x].blink<=1&&game.objects[o].data.frames[fo].itr_count>0&&game.objects[o].arest==0){
420.          for(int i = 0; i < game.objects[o].data.frames[fo].itr_count; ++i){
421.                 if((game.objects[o].team!=game.objects[x].team||game.objects[o].data.frames[fo].state==18||game.objects[o].data.frames[fo].state==12)&&
422.                            (self.state!=12||game.objects[o].data.frames[fo].itrs[i].fall>=60)&&
423.                            game.objects[o].data.frames[fo].itrs[i].kind!=1&&
424.                        game.objects[o].data.frames[fo].itrs[i].kind!=2&&
425.                            (game.objects[o].throwinjury!=0||
426.                            game.objects[o].data.frames[fo].itrs[i].kind!=4)&&
427.                            (game.objects[game.objects[o].weapon_holder].data.frames[game.objects[game.objects[o].weapon_holder].frame1].wpoint.attacking!=0||
428.                            game.objects[o].data.frames[fo].itrs[i].kind!=5)&&
429.                            game.objects[o].data.frames[fo].itrs[i].kind!=6&&
430.                            game.objects[o].data.frames[fo].itrs[i].kind!=7&&
431.                            game.objects[o].data.frames[fo].itrs[i].kind!=8&&
432.                            game.objects[o].data.frames[fo].itrs[i].kind!=14&&
433.                            game.objects[o].data.frames[fo].itrs[i].effect!=4){
434.                for(int j = 0; j < game.objects[x].data.frames[fx].bdy_count; ++j){
435.                   for(int t = 0; t < 31; ++t){
436.                          if(intersect(bdy(x,j,fx,t),itr(o,i,fo,t)))return t;
437.                               }
438.                            }
439.             }
440.          }
441.       }
442.    }
443.    return 31;
444. }
445.
446. int[] bdy(int o, int i, int f, int t){//get bdy i of object o in frame f at time t from now
447.    array<int>r={0,0,0,0,0,0};
448.    if(game.objects[o].data.frames[f].bdy_count>i){
449.       r[game.objects[o].facing?1:0]= game.objects[o].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].bdys[i].x -(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].centerx;
450.       r[game.objects[o].facing?0:1]= game.objects[o].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].bdys[i].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].bdys[i].w -(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].centerx;
451.       r[0]+=game.objects[o].x_velocity*t;
452.       r[1]+=game.objects[o].x_velocity*t;
453.       r[2]=game.objects[o].y+game.objects[o].data.frames[f].bdys[i].y-game.objects[o].data.frames[f].centery;
454.       r[3]=game.objects[o].y+game.objects[o].data.frames[f].bdys[i].y+game.objects[o].data.frames[f].bdys[i].h-game.objects[o].data.frames[f].centery;
455.       r[2]+=game.objects[o].y_velocity*t+(has_gravity(o)?1.7:0)*t;
456.       r[3]+=game.objects[o].y_velocity*t+(has_gravity(o)?1.7:0)*t;
457.       r[4]=game.objects[o].z +game.objects[o].z_velocity*t;
458.       r[5]=game.objects[o].z +game.objects[o].z_velocity*t;
459.    }
460.    return r;
461. }
462.
463. int[] get_attack_info(int o, int x){
464.    return get_attack_info(o, game.objects[o].frame1 ,x ,game.objects[x].frame1);
465. }
466. int[] get_attack_info(int o, int fo, int x, int fx){
467.    array<int>a={31,0,-1,14};
468.    if(fo==-1)fo=game.objects[o].frame1;
469.    if(fx==-1)fx=game.objects[x].frame1;
470.    if(is_object(x)&&o!=x&&is_object(o)){
471.       if(game.objects[x].data.frames[fx].bdy_count>0&&game.objects[x].vrest==0&&game.objects[x].blink<=1&&game.objects[o].data.frames[fo].itr_count>0&&game.objects[o].arest==0){
472.          for(int i = 0; i < game.objects[o].data.frames[fo].itr_count; ++i){
473.                 if((game.objects[o].team!=game.objects[x].team||game.objects[o].data.frames[fo].state==18||game.objects[o].data.frames[fo].state==12)&&
474.                            (self.state!=12||game.objects[o].data.frames[fo].itrs[i].fall>=60)&&
475.                            game.objects[o].data.frames[fo].itrs[i].kind!=1&&
476.                        game.objects[o].data.frames[fo].itrs[i].kind!=2&&
477.                            (game.objects[o].throwinjury!=0||
478.                            game.objects[o].data.frames[fo].itrs[i].kind!=4)&&
479.                            (game.objects[game.objects[o].weapon_holder].data.frames[game.objects[game.objects[o].weapon_holder].frame1].wpoint.attacking!=0||
480.                            game.objects[o].data.frames[fo].itrs[i].kind!=5)&&
481.                            game.objects[o].data.frames[fo].itrs[i].kind!=6&&
482.                            game.objects[o].data.frames[fo].itrs[i].kind!=7&&
483.                            game.objects[o].data.frames[fo].itrs[i].kind!=8&&
484.                            game.objects[o].data.frames[fo].itrs[i].kind!=14&&
485.                            game.objects[o].data.frames[fo].itrs[i].effect!=4){
486.                for(int j = 0; j < game.objects[x].data.frames[fx].bdy_count; ++j){
487.                   for(int t = 0; t < 31; ++t){
488.                          if(intersect(bdy(x,j,fx,t),itr(o,i,fo,t))){
489.                                             a[0]=t;
490.                                                 a[1]=game.objects[o].data.frames[fo].itrs[i].injury;
491.                                                 a[2]=game.objects[o].z+game.objects[o].z_velocity*t;
492.                                                 if(game.objects[o].data.frames[fo].itrs[i].zwidth!=0)a[3]=game.objects[o].data.frames[fo].itrs[i].zwidth-1;
493.                                                 return a;
494.                                          }
495.                               }
496.                            }
497.             }
498.          }
499.       }
500.    }
501.    return a;
502. }
503.
504. int[][] get_objects(){//find all essential object numbers and parameters
505. //add more required parameters
506.    array<array<int>>o={
507.    {-1,31,-1,-1,14},
508.    {-1,2147483647},
509.    {-1,2147483647},
510.    {-1,2147483647},
511.    };
512.    //0,0: object first to hit
513.    array<int>a={31,-1,-1,14};
514.    //0,1: time till it hits
515.    //0,2: injury
516.    //0,3: z at impact
517.    //0,4: zwidth-1
518.    //1,0: closest opponent
519.    //1,1: closest opponent distance
520.    //2,0: second closest opponent
521.    //2,1: second closest opponent distance
522.    //3,0: weakest opponent
523.    //3,1: weakest opponent distance
524.    //4: closest boss
525.    //5: closest item
526.    //6: closest milk
527.    //7: closest beer
528.    //8: command frame
529.    for (int i=0;i<400;++i){
530.       if(is_object(i)){
531.              a=get_attack_info(i,self.num);
532.          if(a[0]<o[0][1]){o[0][0]=i;o[0][1]=a[0];o[0][2]=a[1];o[0][3]=a[2];o[0][4]=a[3];}
533.          else if(a[0]==o[0][1]&&a[1]<o[0][2]){o[0][0]=i;o[0][1]=a[0];o[0][2]=a[1];o[0][4]=a[3];}
534.                  if(is_opponent(i)&&square_distance(self.num,i)<o[1][1]){o[1][1]=square_distance(self.num,i);o[2][0]=o[1][0];o[1][0]=i;}
535.                  else if(is_opponent(i)&&square_distance(self.num,i)<o[2][1]){o[2][1]=square_distance(self.num,i);o[2][0]=i;}
536.                  if(is_opponent(i)&&game.objects[i].hp<o[3][1]){o[3][1]=game.objects[i].hp;o[3][0]=i;}
537.                  else if(is_opponent(i)&&game.objects[i].hp==o[3][1]){o[3][0]=-1;}
538.       }
539.    }
540.    return o;
541. }
542.
543. int[] itr(int o, int i, int f, int t){//get itr i of object o in frame f at time t from now
544.    array<int>r={0,0,0,0,0,0};
545.    if(game.objects[o].data.frames[f].itr_count>i){
546.       r[game.objects[o].facing?1:0]= game.objects[o].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].itrs[i].x -(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].centerx;
547.       r[game.objects[o].facing?0:1]= game.objects[o].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].itrs[i].x +(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].itrs[i].w -(game.objects[o].facing?-1:1)*game.objects[o].data.frames[f].centerx;
548.       r[0]+=game.objects[o].x_velocity*t;
549.       r[1]+=game.objects[o].x_velocity*t;
550.       r[2]=game.objects[o].y+game.objects[o].data.frames[f].itrs[i].y-game.objects[o].data.frames[f].centery;
551.       r[3]=game.objects[o].y+game.objects[o].data.frames[f].itrs[i].y+game.objects[o].data.frames[f].itrs[i].h-game.objects[o].data.frames[f].centery;
552.       r[2]+=game.objects[o].y_velocity*t+(has_gravity(o)?1.7:0)*t;
553.       r[3]+=game.objects[o].y_velocity*t+(has_gravity(o)?1.7:0)*t;
554.       int z=game.objects[o].data.frames[f].itrs[i].zwidth;
555.       if(z==0)z=14;
556.       r[4]=game.objects[o].z-z +game.objects[o].z_velocity*t;
557.       r[5]=game.objects[o].z+z +game.objects[o].z_velocity*t;
558.    }
559.    return r;
560. }
 View raw paste Reply