# DrawCollision.zh

Mar 11th, 2018
94
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. //TileCollision.zh
2.
3. bool DrawTileCollision(npc n, int layer, int x, int y, int tile, int blockw, int blockh, int cset, int rx, int ry, int rangle, int flip, bool transparency, int opacity){
4.     int objx = n->X;
5.     int objy = n->Y
6.     int onbx = n->Z; //We should have a separate function with int UseZ, for this.
7.     bool matchX;
8.     bool matchY;
9.     DrawTile(layer, x, y, tile, blockw, blockh, cset, -1, -1, rx, ry, rangle, flip, transparency, opacity);
10.     int collBoxX = x + (blockw*16);
11.     int collBoxY = y + (blockh*16);
12.     if ( ( objx <= collBoxX-4 && objx > collBoxX-5 ) || ( objx >= collBoxX +12 && objx < collBoxX+13 ) ) matchX = true;
13.     if ( ( objy <= collBoxY-4 && objy > collBoxY-5 ) || ( objy >= collBoxY +12 && objy < collBoxY+13 ) ) matchY = true;
14.     if ( matchX && matchY ) return true;
15.
16.     //here, we need to consider the collision box of the npc, and calculate X/Y offsets for that, too.
17.
18. }
19.
20. bool DrawTileCollision(ffc f, int layer, int x, int y, int tile, int blockw, int blockh, int cset,  int rx, int ry, int rangle, int flip, bool transparency, int opacity){
21.     int objx = f->X;
22.     int objy = f->Y
23.     int onbx = f->Z; //We should have a separate function with int UseZ, for this.
24.     bool matchX;
25.     bool matchY;
26.     DrawTile(layer, x, y, tile, blockw, blockh, cset, -1, -1, rx, ry, rangle, flip, transparency, opacity);
27.     int collBoxX = x + (blockw*16);
28.     int collBoxY = y + (blockh*16);
29.     if ( ( objx <= collBoxX-4 && objx > collBoxX-5 ) || ( objx >= collBoxX +12 && objx < collBoxX+13 ) ) matchX = true;
30.     if ( ( objy <= collBoxY-4 && objy > collBoxY-5 ) || ( objy >= collBoxY +12 && objy < collBoxY+13 ) ) matchY = true;
31.     if ( matchX && matchY ) return true;
32.
33.     //here, we need to consider the collision box, size, and other attributes of the ffc, and calculate X/Y offsets for that, too.
34.
35. }
36.
37. bool DrawTileCollision(lweapon l, int layer, int x, int y, int tile, int blockw, int blockh, int cset, int rx, int ry, int rangle, int flip, bool transparency, int opacity){
38.     int objx = l->X;
39.     int objy = l->Y
40.     int onbx = l->Z; //We should have a separate function with int UseZ, for this.
41.     bool matchX;
42.     bool matchY;
43.     DrawTile(layer, x, y, tile, blockw, blockh, cset, -1, -1, rx, ry, rangle, flip, transparency, opacity);
44.     int collBoxX = x + (blockw*16);
45.     int collBoxY = y + (blockh*16);
46.     if ( ( objx <= collBoxX-4 && objx > collBoxX-5 ) || ( objx >= collBoxX +12 && objx < collBoxX+13 ) ) matchX = true;
47.     if ( ( objy <= collBoxY-4 && objy > collBoxY-5 ) || ( objy >= collBoxY +12 && objy < collBoxY+13 ) ) matchY = true;
48.     if ( matchX && matchY ) return true;
49.
50.     //here, we need to consider the collision box of the object, and calculate X/Y offsets for that, too.
51.
52. }
53.
54. bool DrawTileCollision(eweapon e, int layer, int x, int y, int tile, int blockw, int blockh, int cset, int rx, int ry, int rangle, int flip, bool transparency, int opacity){
55.     int objx = e->X;
56.     int objy = e->Y
57.     int onbx = e->Z; //We should have a separate function with int UseZ, for this.
58.     bool matchX;
59.     bool matchY;
60.     DrawTile(layer, x, y, tile, blockw, blockh, cset, -1, -1, rx, ry, rangle, flip, transparency, opacity);
61.     int collBoxX = x + (blockw*16);
62.     int collBoxY = y + (blockh*16);
63.     if ( ( objx <= collBoxX-4 && objx > collBoxX-5 ) || ( objx >= collBoxX +12 && objx < collBoxX+13 ) ) matchX = true;
64.     if ( ( objy <= collBoxY-4 && objy > collBoxY-5 ) || ( objy >= collBoxY +12 && objy < collBoxY+13 ) ) matchY = true;
65.     if ( matchX && matchY ) return true;
66.
67.     //here, we need to consider the collision box of the object, and calculate X/Y offsets for that, too.
68. }
69.
70. //Draws block of tiles and returns if Link is in Collision with them.
71. bool DrawTileCollision(layer, int x, int y, int tile, int blockw, int blockh, int cset, int rx, int ry, int rangle, int flip, bool transparency, int opacity){
72.     int lx = Link->X; //So that we can modify them to adjust for things, if needed.
74.     int lx = Link->Z; //We should have a separate function with int UseZ, for this.
75.     bool matchX;
76.     bool matchY;
77.     DrawTile(layer, x, y, tile, blockw, blockh, cset, -1, -1, rx, ry, rangle, flip, transparency, opacity);
78.     int collBoxX = x + (blockw*16);
79.     int collBoxY = y + (blockh*16);
80.     if ( ( lx <= collBoxX-4 && lx > collBoxX-5 ) || ( lx >= collBoxX +12 && lx < collBoxX+13 ) ) matchX = true;
81.     if ( ( ly <= collBoxY-4 && ly > collBoxY-5 ) || ( ly >= collBoxY +12 && ly < collBoxY+13 ) ) matchY = true;
82.     if ( matchX && matchY ) return true;
83. }
84.
85. //We need additional args to constrain hit size of box. int CollWidthX and int CollWidthY
86.
87. //DrawCombbo Collision
88.
89. bool DrawComboCollision( int layer, int x, int y, int combo, int w, int h, int cset, int rx, int ry, int rangle, int frame, int flip, bool transparency, int opacity){
90.     int lx = Link->X; //So that we can modify them to adjust for things, if needed.
92.     int lx = Link->Z; //We should have a separate function with int UseZ, for this.
93.     bool matchX;
94.     bool matchY;
95.     DrawCombo(layer, x, y, combo, w, h, cset, -1, -1, rx, ry, rangle, frame, flip, transparency opacity);
96.     int collBoxX = x + (w*16);
97.     int collBoxY = y + (h*16);
98.     if ( ( lx <= collBoxX-4 && lx > collBoxX-5 ) || ( lx >= collBoxX +12 && lx < collBoxX+13 ) ) matchX = true;
99.     if ( ( ly <= collBoxY-4 && ly > collBoxY-5 ) || ( ly >= collBoxY +12 && ly < collBoxY+13 ) ) matchY = true;
100.     if ( matchX && matchY ) return true;
101. }
102.
103.
104. bool DrawComboCollision( int layer, int x, int y, int combo, int w, int h, int cset, int rx, int ry, int rangle, int frame, int flip, bool transparency, int opacity, int collWidthX, int collWidthY){
105.     int lx = Link->X; //So that we can modify them to adjust for things, if needed.
107.     int lx = Link->Z; //We should have a separate function with int UseZ, for this.
108.     bool matchX;
109.     bool matchY;
110.     DrawCombo(layer, x, y, combo, w, h, cset, -1, -1, rx, ry, rangle, frame, flip, transparency opacity);
111.     int collBoxX = x + (w*16) + collWidthX;
112.     int collBoxY = y + (h*16) + collWidthY;
113.     if ( ( lx <= collBoxX-4 && lx > collBoxX-5 ) || ( lx >= collBoxX +12 && lx < collBoxX+13 ) ) matchX = true;
114.     if ( ( ly <= collBoxY-4 && ly > collBoxY-5 ) || ( ly >= collBoxY +12 && ly < collBoxY+13 ) ) matchY = true;
115.     if ( matchX && matchY ) return true;
116. }
117.
118. bool DrawCircularComboCollision( int layer, int x, int y, int combo, int w, int h, int cset, int rx, int ry, int rangle, int frame, int flip, bool transparency, int opacity){
119.     int lx = Link->X; //So that we can modify them to adjust for things, if needed.
121.     int lx = Link->Z; //We should have a separate function with int UseZ, for this.
122.     int cmbX = x+w;
123.     int cmbY = x+h;
124.     int xrad = cmbx / 2; //Use these to gauge distance from the effect.
125.     int yrad = cmbY / 2;
126.
127.     bool matchX;
128.     bool matchY;
129.
130.
131.     DrawCombo(layer, x, y, combo, w, h, cset, -1, -1, rx, ry, rangle, frame, flip, transparency opacity);
132.     int collBoxX = x + (w*16);
133.     int collBoxY = y + (h*16);
134.     //if ( ( lx <= collBoxX-4 && lx > collBoxX-5 ) || ( lx >= collBoxX +12 && lx < collBoxX+13 ) ) matchX = true;
135.     //if ( ( ly <= collBoxY-4 && ly > collBoxY-5 ) || ( ly >= collBoxY +12 && ly < collBoxY+13 ) ) matchY = true;
136.     //if ( matchX && matchY ) return true;