Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define MAX_PARABOLIC_FIRES 10
- #define MAX_PHYSICS_OBJECTS 10
- enum PhysicsEnum
- {
- PHY@ObjectID@internal_,
- Float:PHY@Distance@internal_,
- PHY@CurrentFire@internal_
- };
- static PHY@Info@internal_[MAX_PHYSICS_OBJECTS][PhysicsEnum];
- static Float:PHY@Pos@internal_[MAX_PHYSICS_OBJECTS][MAX_PARABOLIC_FIRES][7];
- static const Float:Coords[] = {0.133333, 0.250000, 0.349999, 0.433333, 0.500000, 0.566666, 0.649999, 0.750000, /*0.866666*/0.87555, 1.000000};
- static const Float:Heigth_Coords[] = {/*0.592592*/0.532592, 0.759259, 0.888888, 0.962962, 1.000000, 0.962962, 0.888888, 0.759259, /*0.592592*/0.512592, 1.000000};
- static const Float:SpeedPerHeigth[] = {1.00, 1.50, 2.00, 2.50, 3.00, 2.50, 2.00, /*1.50*/1.75, 1.50, /*2.00*/1.25};
- /* Macros */
- #define PHY_FinishAdjust(%1) SetObjectRot(PHY@Info@internal_[%1][PHY@ObjectID@internal_], PHY@Pos@internal_[%1][0][5], 0.0, PHY@Pos@internal_[%1][0][4]); MoveObject(PHY@Info@internal_[%1][PHY@ObjectID@internal_], PHY@Pos@internal_[%1][0][0], PHY@Pos@internal_[%1][0][1], PHY@Pos@internal_[%1][0][2], PHY@Pos@internal_[%1][0][3])
- #define fix_angle(%1) (%1 > 0.0) ? (%1) : (%1 + 360.0)
- #define PHY_GetHeigthAngle(%1,%2) new Float:_PHY@heigthangle = atan2(%1, %2);
- stock Float:PHY_GetDistOfNextPoint(slot, fire)
- {
- switch(fire)
- {
- case 0 .. 8: return VectorSize(PHY@Pos@internal_[slot][fire][0] - PHY@Pos@internal_[slot][fire + 1][0], PHY@Pos@internal_[slot][fire][1] - PHY@Pos@internal_[slot][fire + 1][1], PHY@Pos@internal_[slot][fire][2] - PHY@Pos@internal_[slot][fire + 1][2]);
- case 9: return VectorSize(PHY@Pos@internal_[slot][8][0] - PHY@Pos@internal_[slot][9][0], PHY@Pos@internal_[slot][8][1] - PHY@Pos@internal_[slot][9][1], PHY@Pos@internal_[slot][8][2] - PHY@Pos@internal_[slot][9][2]);
- }
- return 0.0;
- }
- stock MovePhysicObject(objectid, Float:fX, Float:fY, Float:fZ, const Float:speed, const Float:max_heigth)
- {
- new idx = -1;
- for(new i = 0; i < MAX_PHYSICS_OBJECTS; i++)
- {
- if(PHY@Info@internal_[i][PHY@ObjectID@internal_] == -1)
- {
- idx = i;
- PHY@Info@internal_[idx][PHY@ObjectID@internal_] = objectid;
- break;
- }
- }
- if(idx == -1) return -1;
- new Float:Pos[3];
- GetObjectPos(objectid, Pos[0], Pos[1], Pos[2]);
- new const Float:dist = VectorSize(Pos[0] - fX, Pos[1] - fY, Pos[2] - fZ);
- new const Float:angle = (atan2(fY - Pos[1], fX - Pos[0]) + 270.0);
- new const Float:total_heigth = (Pos[2] >= fZ) ? (Pos[2]) : (fZ + max_heigth);
- for(new i = 0; i < 10; i++)
- {
- PHY@Pos@internal_[idx][i][0] = Pos[0] + ((Coords[i] * dist) * floatsin(-angle, degrees)); // Pos X
- PHY@Pos@internal_[idx][i][1] = Pos[1] + ((Coords[i] * dist) * floatcos(-angle, degrees)); // Pos Y
- PHY@Pos@internal_[idx][i][2] = Heigth_Coords[i] * total_heigth; // Pos Z
- PHY@Pos@internal_[idx][i][3] = speed / SpeedPerHeigth[i]; // Speed
- }
- PHY@Pos@internal_[idx][9][2] = fZ;
- PHY@Info@internal_[idx][PHY@Distance@internal_] = dist;
- PHY@Info@internal_[idx][PHY@CurrentFire@internal_] = 0;
- return idx;
- }
- stock PHY_AdjustHeigthAngle(slot, const Float:start_z, const Float:add_rot = 0.0)
- {
- new Float:dist;
- new Float:angle;
- for(new i = 1; i < 9; i++)
- {
- dist = VectorSize(PHY@Pos@internal_[slot][i][0] - PHY@Pos@internal_[slot][i + 1][0], PHY@Pos@internal_[slot][i][1] - PHY@Pos@internal_[slot][i + 1][1], PHY@Pos@internal_[slot][i][2] - PHY@Pos@internal_[slot][i + 1][2]);
- angle = atan2(PHY@Pos@internal_[slot][i + 1][2] - PHY@Pos@internal_[slot][i][2], dist) + add_rot;
- PHY@Pos@internal_[slot][i][5] = fix_angle(angle);
- }
- dist = VectorSize(PHY@Pos@internal_[slot][0][0] - PHY@Pos@internal_[slot][1][0], PHY@Pos@internal_[slot][0][1] - PHY@Pos@internal_[slot][1][1], PHY@Pos@internal_[slot][0][2] - PHY@Pos@internal_[slot][1][2]);
- angle = atan2(PHY@Pos@internal_[slot][0][2] - start_z, dist) + add_rot;
- PHY@Pos@internal_[slot][0][5] = fix_angle(angle);
- dist = VectorSize(PHY@Pos@internal_[slot][8][0] - PHY@Pos@internal_[slot][9][0], PHY@Pos@internal_[slot][8][1] - PHY@Pos@internal_[slot][9][1], PHY@Pos@internal_[slot][8][2] - PHY@Pos@internal_[slot][9][2]);
- angle = atan2(PHY@Pos@internal_[slot][9][2] - PHY@Pos@internal_[slot][8][2], dist) + add_rot;
- PHY@Pos@internal_[slot][9][5] = fix_angle(angle);
- return 1;
- }
- stock PHY_AdjustAngle(slot, const Float:add_angle = 0.0)
- {
- for(new i = 0; i < 9; i++)
- {
- PHY@Pos@internal_[slot][i][4] = (atan2(PHY@Pos@internal_[slot][i + 1][1] - PHY@Pos@internal_[slot][i][1], PHY@Pos@internal_[slot][i + 1][0] - PHY@Pos@internal_[slot][i][0]) + 270.0) + add_angle;
- }
- PHY@Pos@internal_[slot][9][4] = (atan2(PHY@Pos@internal_[slot][9][1] - PHY@Pos@internal_[slot][8][1], PHY@Pos@internal_[slot][9][0] - PHY@Pos@internal_[slot][8][0]) + 270.0) + add_angle;
- return 1;
- }
- stock PHY_AdjustCurve(slot, const Float:value, const Float:rot = 0.0)
- {
- new const Float:angle = atan2(PHY@Pos@internal_[slot][9][1] - PHY@Pos@internal_[slot][0][1], PHY@Pos@internal_[slot][9][0] - PHY@Pos@internal_[slot][0][0]) + 270.0;
- for(new i = 0; i < 10; i++)
- {
- PHY@Pos@internal_[slot][i][0] += (Heigth_Coords[i] * value) * floatsin(-angle + (Heigth_Coords[i] * value), degrees); // Pos X
- PHY@Pos@internal_[slot][i][1] += (Heigth_Coords[i] * value) * floatcos(-angle + (Heigth_Coords[i] * value), degrees); // Pos Y
- PHY@Pos@internal_[slot][i][4] += fix_angle(rot * (i + 1));
- }
- return 1;
- }
- public OnObjectMoved(objectid)
- {
- new slot = PHY_IsPhysics(objectid);
- if(slot != -1)
- {
- if(++PHY@Info@internal_[slot][PHY@CurrentFire@internal_] < 10)
- {
- CallLocalFunction("PHY_OnUpdate", "ddi", objectid, slot, PHY@Info@internal_[slot][PHY@CurrentFire@internal_]);
- return 1;
- }
- CallLocalFunction("PHY_OnFinish", "dd", objectid, slot);
- }
- return 1;
- }
- #if defined _ALS_OnObjectMoved
- #undef OnObjectMoved
- #else
- #define _ALS_OnObjectMoved
- #endif
- #define OnObjectMoved PHY_OnObjectMoved
- forward OnObjectMoved(objectid);
- stock PHY_IsPhysics(objectid)
- {
- for(new i = 0; i < MAX_PHYSICS_OBJECTS; i++)
- {
- if(PHY@Info@internal_[i][PHY@ObjectID@internal_] == objectid) return i;
- }
- return -1;
- }
- stock PHY_Finish(slot, const bool:destroy = true)
- {
- if(slot == -1) return -1;
- if(destroy) DestroyObject(PHY@Info@internal_[slot][PHY@ObjectID@internal_]);
- PHY@Info@internal_[slot][PHY@ObjectID@internal_] = -1;
- PHY@Info@internal_[slot][PHY@CurrentFire@internal_] = 0;
- for(new i = 0; i < 10; i++) PHY@Pos@internal_[slot][i][0] = PHY@Pos@internal_[slot][i][1] = PHY@Pos@internal_[slot][i][2] = PHY@Pos@internal_[slot][i][3] = 0.0;
- return 1;
- }
- forward PHY_OnUpdate(objectid, slot, fire);
- forward PHY_OnFinish(objectid, slot);
- #undef fix_angle
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement