Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <a_samp>
- #include <zcmd>
- #include <streamer>
- #include <YSI\y_hooks>
- #include <YSI\y_iterate>
- #define MAX_FIRE_WORKS 100
- #define MAX_SHOTS 500
- #define SHOT_TYPE_ISOHEDRON 0
- #define SHOT_TYPE_SPHERE 1
- static GenerateIsohedron(Float:radius, Float:Points[12][3])
- {
- Points[0][0] = 0.000, Points[0][1] = 1.000*radius, Points[0][2] = 0.000,
- Points[1][0] = 0.894*radius, Points[1][1] = 0.447*radius, Points[1][2] = 0.000,
- Points[2][0] = 0.276*radius, Points[2][1] = 0.447*radius, Points[2][2] = 0.851*radius,
- Points[3][0] = -0.724*radius, Points[3][1] = 0.447*radius, Points[3][2] = 0.526*radius,
- Points[4][0] = -0.724*radius, Points[4][1] = 0.447*radius, Points[4][2] = -0.526*radius,
- Points[5][0] = 0.276*radius, Points[5][1] = 0.447*radius, Points[5][2] = -0.851*radius,
- Points[6][0] = 0.724*radius, Points[6][1] = -0.447*radius, Points[6][2] = 0.526*radius,
- Points[7][0] = -0.276*radius, Points[7][1] = -0.447*radius, Points[7][2] = 0.851*radius,
- Points[8][0] = -0.894*radius, Points[8][1] = -0.447*radius, Points[8][2] = 0.000,
- Points[9][0] = -0.276*radius, Points[9][1] = -0.447*radius, Points[9][2] = -0.851*radius,
- Points[10][0]= 0.724*radius, Points[10][1]= -0.447*radius, Points[10][2]= -0.526*radius,
- Points[11][0]= 0.000, Points[11][1]= -1.000*radius, Points[11][2]= 0.000;
- }
- static GenerateSphere(Float:radius, Float:Points[36][3])
- {
- Points[0][0] = 0.433883*radius, Points[0][1] = 0.900968*radius, Points[0][2] = 0.000000;
- Points[1][0] = 0.216941*radius, Points[1][1] = 0.900968*radius, Points[1][2] = 0.375754*radius;
- Points[2][0] = -0.216941*radius, Points[2][1] = 0.900968*radius, Points[2][2] = 0.375754*radius;
- Points[3][0] = -0.433883*radius, Points[3][1] = 0.900968*radius, Points[3][2] = -0.000000*radius;
- Points[4][0] = -0.216941*radius, Points[4][1] = 0.900968*radius, Points[4][2] = -0.375754*radius;
- Points[5][0] = 0.216941*radius, Points[5][1] = 0.900968*radius, Points[5][2] = -0.375754*radius;
- Points[6][0] = 0.781831*radius, Points[6][1] = 0.623489*radius, Points[6][2] = 0.000000*radius;
- Points[7][0] = 0.390915*radius, Points[7][1] = 0.623489*radius, Points[7][2] = 0.677085*radius;
- Points[8][0] = -0.390915*radius, Points[8][1] = 0.623489*radius, Points[8][2] = 0.677085*radius;
- Points[9][0] = -0.781831*radius, Points[9][1] = 0.623489*radius, Points[9][2] = 0.000000;
- Points[10][0] = -0.390915*radius, Points[10][1] = 0.623489*radius, Points[10][2] = -0.677085*radius;
- Points[11][0] = 0.390915*radius, Points[11][1] = 0.623489*radius, Points[11][2] = -0.677085*radius;
- Points[12][0] = 0.974927*radius, Points[12][1] = 0.222520*radius, Points[12][2] = 0.000000*radius;
- Points[13][0] = 0.487463*radius, Points[13][1] = 0.222520*radius, Points[13][2] = 0.844312*radius;
- Points[14][0] = -0.487464*radius, Points[14][1] = 0.222520*radius, Points[14][2] = 0.844312*radius;
- Points[15][0] = -0.974927*radius, Points[15][1] = 0.222520*radius, Points[15][2] = 0.000000;
- Points[16][0] = -0.487463*radius, Points[16][1] = 0.222520*radius, Points[16][2] = -0.844312*radius;
- Points[17][0] = 0.487463*radius, Points[17][1] = 0.222520*radius, Points[17][2] = -0.844312*radius;
- Points[18][0] = 0.974927*radius, Points[18][1] = -0.222520*radius, Points[18][2] = 0.000000;
- Points[19][0] = 0.487463*radius, Points[19][1] = -0.222520*radius, Points[19][2] = 0.844312*radius;
- Points[20][0] = -0.487464*radius, Points[20][1] = -0.222520*radius, Points[20][2] = 0.844312*radius;
- Points[21][0] = -0.974927*radius, Points[21][1] = -0.222520*radius, Points[21][2] = 0.000000;
- Points[22][0] = -0.487463*radius, Points[22][1] = -0.222520*radius, Points[22][2] = -0.844312*radius;
- Points[23][0] = 0.487463*radius, Points[23][1] = -0.222520*radius, Points[23][2] = -0.844312*radius;
- Points[24][0] = 0.781831*radius, Points[24][1] = -0.623489*radius, Points[24][2] = 0.000000;
- Points[25][0] = 0.390915*radius, Points[25][1] = -0.623489*radius, Points[25][2] = 0.677085*radius;
- Points[26][0] = -0.390915*radius, Points[26][1] = -0.623489*radius, Points[26][2] = 0.677085*radius;
- Points[27][0] = -0.781831*radius, Points[27][1] = -0.623489*radius, Points[27][2] = 0.000000;
- Points[28][0] = -0.390915*radius, Points[28][1] = -0.623489*radius, Points[28][2] = -0.677085*radius;
- Points[29][0] = 0.390915*radius, Points[29][1] = -0.623489*radius, Points[29][2] = -0.677085*radius;
- Points[30][0] = 0.433883*radius, Points[30][1] = -0.900968*radius, Points[30][2] = 0.000000;
- Points[31][0] = 0.216941*radius, Points[31][1] = -0.900968*radius, Points[31][2] = 0.375754*radius;
- Points[32][0] = -0.216941*radius, Points[32][1] = -0.900968*radius, Points[32][2] = 0.375754*radius;
- Points[33][0] = -0.433883*radius, Points[33][1] = -0.900968*radius, Points[33][2] = 0.000000;
- Points[34][0] = -0.216941*radius, Points[34][1] = -0.900968*radius, Points[34][2] = -0.375754*radius;
- Points[35][0] = 0.216941*radius, Points[35][1] = -0.900968*radius, Points[35][2] = -0.375754*radius;
- }
- enum FIREWORKINFO
- {
- bool:FireWorkInUse,
- FireWorkObject,
- Float:FireWorkPosX,
- Float:FireWorkPosY,
- Float:FireWorkPosZ,
- Float:FireWorkHeight,
- }
- enum SHOTINFO
- {
- FireWorkRef,
- ShotObjectID,
- ShotType,
- ShotObject,
- Float:Shotoffx,
- Float:Shotoffy,
- Float:Shotoffz,
- }
- static ShotObjects[6] = { 19290, 19291, 19292, 19293, 19294, 19295 };
- static FireWorkShots[MAX_SHOTS][SHOTINFO];
- static FireWorkData[MAX_FIRE_WORKS][FIREWORKINFO];
- public OnFilterScriptInit()
- {
- for(new i = 0; i < MAX_SHOTS; i++) FireWorkShots[i][FireWorkRef] = -1;
- return 1;
- }
- // Create a firework
- static CreateFireWork(Float:x, Float:y, Float:z, Float:height, shottimes)
- {
- for(new i = 0; i < MAX_FIRE_WORKS; i++)
- {
- if(FireWorkData[i][FireWorkInUse] == false)
- {
- FireWorkData[i][FireWorkObject] = CreateDynamicObject(2868, x, y, z, 0.0, 0.0, 0.0);
- FireWorkData[i][FireWorkPosX] = x;
- FireWorkData[i][FireWorkPosY] = y;
- FireWorkData[i][FireWorkPosZ] = z;
- FireWorkData[i][FireWorkHeight] = height;
- foreach(new j : Player) Streamer_Update(j);
- for(new j = 1; j < shottimes; j++)
- {
- new type = random(2);
- SetTimerEx("LaunchFireWork", 1000*j, false, "ii", i, type);
- }
- SetTimerEx("ClearFireWork", 1000*shottimes, false, "i", i);
- FireWorkData[i][FireWorkInUse] = true;
- return i;
- }
- }
- return -1;
- }
- forward ClearFireWork(index);
- public ClearFireWork(index)
- {
- DestroyDynamicObject(FireWorkData[index][FireWorkObject]);
- FireWorkData[index][FireWorkInUse] = false;
- return 1;
- }
- forward LaunchFireWork(index, type);
- public LaunchFireWork(index, type)
- {
- for(new i = 0; i < MAX_SHOTS; i++)
- {
- if(FireWorkShots[i][FireWorkRef] == -1)
- {
- FireWorkShots[i][ShotObject] = ShotObjects[random(6)];
- FireWorkShots[i][ShotObjectID] = CreateDynamicObject(FireWorkShots[i][ShotObject], FireWorkData[index][FireWorkPosX], FireWorkData[index][FireWorkPosY], FireWorkData[index][FireWorkPosZ], 0.0, 0.0, 0.0);
- FireWorkShots[i][FireWorkRef] = index;
- FireWorkShots[i][ShotType] = type;
- if(random(2) == 1) FireWorkShots[i][Shotoffx] = -(float(random(2000)) / 100.0);
- else FireWorkShots[i][Shotoffx] = float(random(2000)) / 100.0;
- if(random(2) == 1) FireWorkShots[i][Shotoffy] = -(float(random(2000)) / 100.0);
- else FireWorkShots[i][Shotoffy] = float(random(2000)) / 100.0;
- if(random(2) == 1) FireWorkShots[i][Shotoffz] = -(float(random(1000)) / 100.0);
- else FireWorkShots[i][Shotoffz] = float(random(300)) / 100.0;
- MoveDynamicObject(FireWorkShots[i][ShotObjectID],
- FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy],
- FireWorkData[index][FireWorkPosZ]+FireWorkData[index][FireWorkHeight]+FireWorkShots[i][Shotoffz], 50.0);
- foreach(new j : Player) Streamer_Update(j);
- return 1;
- }
- }
- return 1;
- }
- hook OnDynamicObjectMoved(objectid)
- {
- for(new i = 0; i < MAX_SHOTS; i++)
- {
- if(FireWorkShots[i][ShotObjectID] == objectid)
- {
- DestroyDynamicObject(FireWorkShots[i][ShotObjectID]);
- new index = FireWorkShots[i][FireWorkRef];
- FireWorkShots[i][FireWorkRef] = -1;
- FireWorkShots[i][ShotObjectID] = -1;
- new tmpobj;
- switch(FireWorkShots[i][ShotType])
- {
- case SHOT_TYPE_ISOHEDRON:
- {
- new Float:IsoPoints[12][3];
- GenerateIsohedron(10.0, IsoPoints);
- for(new j = 0; j < 12; j++)
- {
- tmpobj = CreateDynamicObject(FireWorkShots[i][ShotObject],
- FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy],
- FireWorkData[index][FireWorkPosZ]+FireWorkData[index][FireWorkHeight]+FireWorkShots[i][Shotoffz],
- 0.0, 0.0, 0.0);
- MoveDynamicObject(tmpobj,
- FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx]+IsoPoints[j][0],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy]+IsoPoints[j][1],
- FireWorkData[index][FireWorkPosZ]+FireWorkShots[i][Shotoffx]+FireWorkData[index][FireWorkHeight]+IsoPoints[j][2]-5.0, 10.0);
- SetTimerEx("DestroyFireWorkShot", 1500, false, "j", tmpobj);
- }
- foreach(new j : Player) Streamer_Update(j);
- CreateExplosion(FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy],
- FireWorkData[index][FireWorkPosZ]+FireWorkShots[i][Shotoffz]+FireWorkData[index][FireWorkHeight],
- 12, 1.0);
- return 1;
- }
- case SHOT_TYPE_SPHERE:
- {
- new Float:SpherePoints[36][3];
- GenerateSphere(10.0, SpherePoints);
- for(new j = 0; j < 36; j++)
- {
- tmpobj = CreateDynamicObject(FireWorkShots[i][ShotObject],
- FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy],
- FireWorkData[index][FireWorkPosZ]+FireWorkData[index][FireWorkHeight]+FireWorkShots[i][Shotoffz],
- 0.0, 0.0, 0.0);
- MoveDynamicObject(tmpobj,
- FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx]+SpherePoints[j][0],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy]+SpherePoints[j][1],
- FireWorkData[index][FireWorkPosZ]+FireWorkShots[i][Shotoffx]+FireWorkData[index][FireWorkHeight]+SpherePoints[j][2]-5.0, 10.0);
- SetTimerEx("DestroyFireWorkShot", 1500, false, "j", tmpobj);
- }
- foreach(new j : Player) Streamer_Update(j);
- CreateExplosion(FireWorkData[index][FireWorkPosX]+FireWorkShots[i][Shotoffx],
- FireWorkData[index][FireWorkPosY]+FireWorkShots[i][Shotoffy],
- FireWorkData[index][FireWorkPosZ]+FireWorkShots[i][Shotoffz]+FireWorkData[index][FireWorkHeight],
- 8, 1.0);
- return 1;
- }
- }
- }
- }
- return 1;
- }
- forward DestroyFireWorkShot(id);
- public DestroyFireWorkShot(id)
- {
- DestroyDynamicObject(id);
- return 1;
- }
- CMD:firework(playerid, arg[])
- {
- new Float:x, Float:y, Float:z, Float:FacingA;
- GetPlayerFacingAngle(playerid, FacingA);
- x = (x + 1.0 * floatsin(-FacingA,degrees));
- y = (y + 1.0 * floatcos(-FacingA,degrees));
- CreateFireWork(x, y, z-1.0, 40.0, 100);
- return 1;
- }
- enum XYZ {
- bool:Used,
- Float:xpos,
- Float:ypos,
- Float:zpos,
- }
- //----------------------------------------------------------------------------
- /*
- // Generates sphere meshes
- new Sphere[1000][XYZ];
- #define DEGS_TO_RAD 0.01745329251
- stock GenerateSphereMesh(Float:radius, nLatitude, nLongitude, Float:Sphere[][3])
- {
- new p, s;
- new Float:x, Float:y, Float:z, Float:out;
- new nPitch = nLongitude + 1;
- new Float:pitchInc = (180 / float(nPitch)) * DEGS_TO_RAD;
- new Float:rotInc = (360 / float(nLatitude)) * DEGS_TO_RAD;
- new numVertices = numVertices+2;
- new count;
- for(p=1; p<nPitch; p++)
- {
- out = radius * floatsin(float(p) * pitchInc);
- out = floatabs(out);
- y = radius * floatcos(float(p) * pitchInc);
- for(s=0; s<nLatitude; s++)
- {
- x = out * floatcos(float(s) * rotInc);
- z = out * floatsin(float(s) * rotInc);
- numVertices++;
- Sphere[count][0] = x;
- Sphere[count][1] = y;
- Sphere[count][2] = z;
- count++;
- }
- }
- }
- */
- //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment