Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* surface.inc
- *
- * (c) Copyright 2015, Emilijo "Correlli" Lovrich
- *
- * Credits: - Incognito for streamer plugin.
- */
- #define OBJ_DBG_MSG
- new
- g_Count;
- stock CreateObjectSurface(object_model, Float:x_off, Float:y_off, Float:height, Float:x_start, Float:y_start, Float:x_end = 0.0, Float:y_end = 0.0, Float:x_rot = 0.0, Float:y_rot = 0.0, Float:z_rot = 0.0, world = -1, interior = -1, player = -1, Float:d_stream = 200.0, Float:d_draw = 0.0, m_index = 0, txd_model = 0, txd_name[] = "", texture_name[] = "", m_color = 0)
- {
- /*
- * Example (this covers the whole San Andreas map with breakable glass objects (model: 1649)):
- * -3000.0 -> 3000.0 (3000.0 + 3000.0 = 6000.0)
- * x_off = 4.4
- * 6000.0 / 4.4 = 1363.636 ~= 1364
- * y_off = 3.31
- * 6000.0 / 3.31 = 1812.6888 ~= 1813
- * 1364 x 1813 = 2472932 objects in total
- */
- if(!x_end)
- {
- if(x_start < 0.0) x_end = floatabs(x_start);
- else x_end = -x_start;
- }
- if(!y_end)
- {
- if(y_start < 0.0) y_end = floatabs(y_start);
- else y_end = -y_start;
- }
- if(x_start == x_end || y_start == y_end)
- {
- return
- printf("Error at \"CreateObjectSurface\" function for model %i - one of the starting and ending positions (X: %0.2f, Y: %0.2f) is the same.",
- object_model,
- x_start,
- y_start
- )
- ;
- }
- new
- Float:coord[2], bool:calculate[2], loop[2], object;
- if(x_start < 0.0)
- {
- // -3000.0, -4000.0 -> 1000.0
- // -4000.0, -3000.0 -> 1000.0
- if(x_end < 0.0)
- {
- if(x_start > x_end)
- calculate[0] = true;
- coord[0] = floatabs(x_start + floatabs(x_end));
- }
- // -3000.0, 4000.0 -> 7000.0
- else
- coord[0] = floatabs(x_start) + x_end;
- }
- else
- {
- // 3000.0, -4000.0 -> 7000.0
- if(x_end < 0.0)
- {
- calculate[0] = true;
- coord[0] = x_start + floatabs(x_end);
- }
- // 3000.0, 4000.0 -> 1000.0
- // 4000.0, 3000.0 -> 1000.0
- else
- {
- if(x_start > x_end)
- calculate[0] = true;
- coord[0] = floatabs(x_start - x_end);
- }
- }
- if(y_start < 0.0)
- {
- // -3000.0, -4000.0 -> 1000.0
- // -4000.0, -3000.0 -> 1000.0
- if(y_end < 0.0)
- {
- if(y_start > y_end)
- calculate[1] = true;
- coord[1] = floatabs(y_start + floatabs(y_end));
- }
- // -3000.0, 4000.0 -> 7000.0
- else
- coord[1] = floatabs(y_start) + y_end;
- }
- else
- {
- // 3000.0, -4000.0 -> 7000.0
- if(y_end < 0.0)
- {
- calculate[1] = true;
- coord[1] = y_start + floatabs(y_end);
- }
- // 3000.0, 4000.0 -> 1000.0
- // 4000.0, 3000.0 -> 1000.0
- else
- {
- if(y_start > y_end)
- calculate[1] = true;
- coord[1] = floatabs(y_start - y_end);
- }
- }
- loop[0] = floatround(coord[0] / x_off, floatround_ceil);
- loop[1] = floatround(coord[1] / y_off, floatround_ceil);
- g_Count = 0;
- for(new a = 0; a < loop[0]; a++)
- {
- for(new b = 0; b < loop[1]; b++)
- {
- if(calculate[0]) coord[0] = x_start - (x_off * a);
- else coord[0] = x_start + (x_off * a);
- if(calculate[1]) coord[1] = y_start - (y_off * b);
- else coord[1] = y_start + (y_off * b);
- object = CreateDynamicObject(
- object_model,
- coord[0],
- coord[1],
- height,
- x_rot,
- y_rot,
- z_rot,
- world,
- interior,
- player,
- d_stream,
- d_draw
- );
- g_Count++;
- if(txd_model)
- SetDynamicObjectMaterial(object, m_index, txd_model, txd_name, texture_name, m_color);
- }
- }
- #if defined OBJ_DBG_MSG
- printf("Created %i objects at \"CreateObjectSurface\" function for model %i.",
- g_Count,
- object_model
- );
- #endif
- return g_Count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement