Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2024
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.33 KB | None | 0 0
  1. #define D_ARTS_MAX 128
  2. #define D_ARTS_LINE_SIZE 2048
  3. #define D_ARTS_MAX_OBJECTS 2000
  4. #tryinclude <streamer>
  5. new Float:D_ArtsInfo[D_ARTS_MAX][11];
  6. // 0 = reserved
  7. // 1 = create_type ( 0 = not inited 1 = standart 2 = dynamic )
  8. // 2 = object_type
  9. // 3 = Xpos
  10. // 4 = Ypos
  11. // 5 = Zpos
  12. // 6 = Xrot
  13. // 7 = Yrot
  14. // 8 = Zrot
  15. // 9 = width
  16. // 10 = height
  17.  
  18. new object_count = 0;
  19. new D_ArtsObjects[D_ARTS_MAX][D_ARTS_MAX_OBJECTS];
  20.  
  21. //converted picture representation example
  22. //new ArtObject[buffers used][];
  23. //0th buffer is used to store the misc info
  24. // 0 = width
  25. // 1 = height
  26. // i + 2 = num of sbuffers for the block i
  27.  
  28. stock CreateArt3(ArtObject[][], type, Float:PosX, Float:PosY, Float:PosZ, Float:RotX, Float:RotY, Float:RotZ, Float:DrawDistance = 300.0)
  29. {
  30. return CreateArtInternal3(ArtObject, type, 0, PosX, PosY, PosZ, RotX, RotY, RotZ, -1, -1, -1, 0, DrawDistance);
  31. }
  32.  
  33. #if defined CreateDynamicObject
  34. stock CreateDynamicArt3(ArtObject[][], type, Float:PosX, Float:PosY, Float:PosZ, Float:RotX, Float:RotY, Float:RotZ, worldid = -1, interiorid = -1, playerid = -1, Float:StreamDistance = 200.0, Float:DrawDistance = 300.0 )
  35. {
  36. return CreateArtInternal3(ArtObject, type, 1, PosX, PosY, PosZ, RotX, RotY, RotZ, worldid, interiorid, playerid, StreamDistance, DrawDistance);
  37. }
  38. #endif
  39.  
  40. stock CreateArtInternal3(ArtObject[][], type, dynamic, Float:PosX, Float:PosY, Float:PosZ, Float:RotX, Float:RotY, Float:RotZ, worldid = -1, interiorid = -1, playerid = -1, Float:StreamDistance = 200.0, Float:DrawDistance = 300.0 )
  41. {
  42. new art_id = -1;
  43. for (new i = 0; i < D_ARTS_MAX; i++)
  44. {
  45. if (D_ArtsInfo[i][1] == 0)
  46. {
  47. art_id = i;
  48. break;
  49. }
  50. }
  51. if (art_id < 0 || art_id >= D_ARTS_MAX)
  52. return -1; //no more objects can be created
  53. new width = ArtObject[0][0];
  54. new height = ArtObject[0][1];
  55.  
  56. new Float:ang[3];
  57. ang[0] = RotX;
  58. ang[1] = RotY;
  59. ang[2] = RotZ;
  60. new Float:pos[3];
  61. pos[0] = PosX;
  62. pos[1] = PosY;
  63. pos[2] = PosZ;
  64.  
  65. new internal_type = type;
  66.  
  67. new arrow = 0; new matid;
  68.  
  69. new Float:ws, Float:hs, oid, Float:arx = 0, Float:ary = 0, Float:arz = 0;
  70.  
  71.  
  72.  
  73. if (internal_type == 0)
  74. {
  75. ws = 1.48;
  76. hs = 1.48;
  77. oid = 19168;
  78. matid = 0;
  79. arrow = 0;
  80. } else if (internal_type == 1)
  81. {
  82. ws = 1.48;
  83. hs = 1.48;
  84. oid = 19168;
  85. matid = 1;
  86. arrow = 0;
  87. }
  88. else if (internal_type == 2)
  89. {
  90. ws = 0.42;
  91. hs = 0.42;
  92. oid = 19167;
  93. matid = 1;
  94. arrow = 0;
  95. }
  96. else if (internal_type == 3)
  97. {
  98. ws = 0.42;
  99. hs = 0.42;
  100. oid = 19167;
  101. matid = 0;
  102. arrow = 0;
  103. }
  104. else if (internal_type == 4)
  105. {
  106. ws = 1.98;
  107. hs = 1.98;
  108. oid = 18660;
  109. matid = 0;
  110. arrow = 1;
  111. }
  112. else if (internal_type == 5)
  113. {
  114. ws = 0.995;
  115. hs = 0.995;
  116. oid = 19789;
  117. matid = 0;
  118. arrow = 0;
  119. }
  120. else if (internal_type == 6)
  121. {
  122. ws = 5.875;
  123. hs = 5.075;
  124. oid = 19464;
  125. matid = 0;
  126. arrow = 1;
  127. }
  128. else if (internal_type == 7)
  129. {
  130. ws = 0.51;
  131. hs = 0.51;
  132. oid = 2814;
  133. matid = 0;
  134. arrow = 1;
  135. ary = -94.65;
  136. }
  137. else if (internal_type == 8)
  138. {
  139. ws = 3.18;
  140. hs = 3.48;
  141. oid = 19372;
  142. matid = 0;
  143. arrow = 1;
  144. }
  145. else if (internal_type == 9)
  146. {
  147. ws = 1.48;
  148. hs = 1.48;
  149. oid = 18887;
  150. matid = 0;
  151. arrow = 0;
  152. }
  153.  
  154. //my old magic with transformations
  155. new Float:up[3];
  156. up[0] = floatsin(ang[1], degrees)*floatcos(ang[2], degrees) + floatsin(ang[0], degrees)*floatsin(ang[2], degrees)*floatcos(ang[1], degrees);
  157. up[1] = floatsin(ang[2], degrees)*floatsin(ang[1], degrees) - floatsin(ang[0], degrees)*floatcos(ang[1], degrees)*floatcos(ang[2], degrees);
  158. up[2] = -floatcos(ang[0], degrees)*floatcos(ang[1], degrees);
  159. new Float:right[3];
  160. right[0] = -floatsin(ang[2], degrees)*floatcos(ang[0], degrees);
  161. right[1] = floatcos(ang[0], degrees)*floatcos(ang[2], degrees);
  162. right[2] = -floatsin(ang[0], degrees);
  163. new Float:frwd[3];
  164. frwd[0] = floatcos(ang[1], degrees)*floatcos(ang[2], degrees) - floatsin(ang[0], degrees)*floatsin(ang[2], degrees)*floatsin(ang[1], degrees);
  165. frwd[1] = floatsin(ang[2], degrees)*floatcos(ang[1], degrees) + floatsin(ang[0], degrees)*floatsin(ang[1], degrees)*floatcos(ang[2], degrees);
  166. frwd[2] = floatcos(ang[0], degrees)*floatsin(ang[1], degrees);
  167. new Float:secnd[3];
  168.  
  169.  
  170. if (arrow == 0)
  171. {
  172. secnd = frwd;
  173. }
  174. else
  175. {
  176. secnd = up;
  177. }
  178.  
  179. for(new i = 0; i < width; i++)
  180. for(new j = 0; j < height; j++)
  181. {
  182. new an_i = i, an_j = j, an_height = height, an_width = width;
  183. if (internal_type == 0 || internal_type == 1 || internal_type == 2 || internal_type == 5 || internal_type == 9)
  184. {
  185. an_i = j;
  186. an_j = width - i;
  187. an_height = width;
  188. an_width = height;
  189. }
  190. else if (internal_type == 3)
  191. {
  192. an_i = height - j;
  193. an_j = width - i;
  194. an_height = width;
  195. an_width = height;
  196. }
  197. new Float:start[3];
  198. start[0] = (float(an_i) - float(an_width)/2.0)*ws*right[0] + (float(an_j) - float(an_height)/2.0)*(hs)*secnd[0] + pos[0];
  199. start[1] = (float(an_i) - float(an_width)/2.0)*ws*right[1] + (float(an_j) - float(an_height)/2.0)*(hs)*secnd[1] + pos[1];
  200. start[2] = (float(an_i) - float(an_width)/2.0)*ws*right[2] + (float(an_j) - float(an_height)/2.0)*(hs)*secnd[2] + pos[2];
  201. new creo = -1;
  202. if (dynamic == 0)
  203. {
  204. object_count++;
  205. creo = CreateObject( oid, start[0], start[1], start[2], ang[0] + arx, ang[1] + ary, ang[2] + 180 + arz, DrawDistance);
  206. printf("%d",object_count);
  207. }
  208. else
  209. {
  210. #if defined CreateDynamicObject
  211. creo = CreateDynamicObject( oid, start[0], start[1], start[2], ang[0] + arx, ang[1] + ary, ang[2] + 180 + arz, worldid, interiorid, playerid, StreamDistance, DrawDistance);
  212. #else
  213. #pragma unused worldid, interiorid, playerid, StreamDistance
  214. #endif
  215. }
  216. D_ArtsObjects[art_id][i + width*j] = creo;
  217. new d_temp_buf_string[2048] = "";
  218. new count = ArtObject[0][ (i + width*j) * 2 + 2];
  219. new index = ArtObject[0][ (i + width*j) * 2 + 3];
  220. for (new k = 0; k < count; k++)
  221. strcat(d_temp_buf_string, ArtObject[index + k], 2048);
  222. if (dynamic == 0)
  223. {
  224. SetObjectMaterialText(creo, d_temp_buf_string, matid, 140, "Webdings", 35, 0, 0, 0, 0);
  225. }
  226. else
  227. {
  228. #if defined SetDynamicObjectMaterialText
  229. SetDynamicObjectMaterialText(creo, matid, d_temp_buf_string, 140, "Webdings", 35, 0, 0, 0, 0);
  230. #endif
  231. }
  232. }
  233. D_ArtsInfo[art_id][1] = float(dynamic) + 1;
  234. D_ArtsInfo[art_id][2] = float(internal_type);
  235. D_ArtsInfo[art_id][3] = PosX;
  236. D_ArtsInfo[art_id][4] = PosY;
  237. D_ArtsInfo[art_id][5] = PosZ;
  238. D_ArtsInfo[art_id][6] = RotX;
  239. D_ArtsInfo[art_id][7] = RotY;
  240. D_ArtsInfo[art_id][8] = RotZ;
  241. D_ArtsInfo[art_id][9] = float(width);
  242. D_ArtsInfo[art_id][10] = float(height);
  243. return art_id;
  244. }
  245.  
  246. stock DestroyArt3Internal(ArtID)
  247. {
  248. if (D_ArtsInfo[ArtID][1] < 0.5 || D_ArtsInfo[ArtID][1] > 1.5)
  249. return -1;
  250. new dynamic = D_ArtsInfo[ArtID][1];
  251. if (dynamic == 0)
  252. return -1;
  253. new width = floatround(D_ArtsInfo[ArtID][9] + 0.5);
  254. new height = floatround(D_ArtsInfo[ArtID][10] + 0.5);
  255. for (new i = 0; i < width*height; i++)
  256. {
  257. if (dynamic == 1)
  258. {
  259. DestroyObject(D_ArtsObjects[ArtID][i]);
  260. }
  261. else
  262. {
  263. #if defined DestroyDynamicObject
  264. DestroyDynamicObject(D_ArtsObjects[ArtID][i]);
  265. #endif
  266. }
  267. }
  268. D_ArtsInfo[ArtID][1] = 0;
  269. return 0;
  270. }
  271.  
  272. stock DestroyArt3(ArtID)
  273. {
  274. return DestroyArt3Internal(ArtID);
  275. }
  276.  
  277. stock DestroyDynamicArt3(ArtID)
  278. {
  279. return DestroyArt3Internal(ArtID);
  280. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement