01.01.2014, 13:43
(
Последний раз редактировалось Lordzy; 28.06.2014 в 15:59.
Причина: Links updated
)
L_SAM - Lordz's Surface to Air Missile System
Now suppports following missiles!
+ SAM objects won't explode when damaged
Version : v1.3 <Stable>
Happy new year everyone,Now suppports following missiles!
+ SAM objects won't explode when damaged
Version : v1.3 <Stable>
I was just playing GTA SA three days back and when I went to Area 51, I saw those S-A-M launchers attacking when I'm getting into the restricted zone. That gave me an idea in creating a S-A-M system for SA-MP too which would do the same as those do. I did it yesterday and then came to know that there had been an include related to this released already. :/ However, I'm releasing what I've done. I don't know which would be better as I've not tested that. Anyway, this, is my own codes and ideas.
S-A-M : Surface to Air Missiles
S-A-M (Surface to Air Missiles) is a type of system which locks on the enemy targets and launches a missile. If you want to experience it on GTA SA, I suggest you to get to Restricted Zone on GTA SA. I've thought to create a missile launcher following system, however after creating it, it had some performance problems which made me pissed off. I wanted to get this released today, so I've changed my mind in coding that right now. I'll add it on the next version of this include. (Never mind, there's the following missile system on the version 1.2 of this include!)
This works in such a way that you've to specify the range of detection and the missiles would hit the player in case if the player is at that zone. Speed of the missiles can be set. Also, this include supports different kind of explosion rates. There are 4 types of explosions, starting from ID : 0 - 3. As higher the power is set, explosion and it's force increases it's power. The script also shows the missiles being fired on the radar. Even though I've started the work yesterday, I've just used the free time I got, so it was created quickly. In case if you find any bugs, please feel free to tell me.
This include now supports following missiles after the v1.2 release and also supports setting colors for each SAM's missile. (Colors being viewed on the radar)
v1.3 has been released, the include supports smoke effects on Missiles which can be easily turned off if you undefine L_SAMUSE_SMOKES on the script. Callbacks such as "OnSAMMissileLaunch" and "OnSAMMissileHitPlayer" has been done. The first one gets called when a missile gets launched to player and the other one when it hits the player. Also, a new system has been introduced which creates a following range limit. If the missile is following player for being on the restricted area, if the followlimit is kept to true, when the player is out of the area range specified, the missile will destroy itself.
Three new functions have been added too. Check out the change logs for further information.
Changelogs
Код:
ChangeLogs: v1.3 (09-01-2014) + The current S-A-M model won't get destructed! + This include no longer uses Streamer as it's use is very less for further things coming. So, it doesn't use Streamer function anymore. + The missiles now set it's facing position according to the player's position. + Added smoke effects on missiles. You can disable it by removing : #define L_SAMUSE_SMOKES from the include. + Added callback called "OnSAMMissileLaunch" which is called when a SAM launches a missile on player. + Added callback called "OnSAMMissileHitPlayer" which is called when a SAM missile hits the player. (Player must be connected) + Added a new parameter called "bool:followlimit" on CreateSAM. It creates limitations for the following range according to the area range specified. It's set to false as default so it follows the player everywhere until it hits the player, if not set to true. + Added function called "IsMissileFollowingLimited" which returns true in case if the following missiles got range limit, else false. + Added function called "DestroySAMMissile" which destroys the missile if player is being chased by any missiles. + Added function called "IsSAMMissileChasing" which return true in case if the player is being chased by a missile. False if not. v1.2 (02/01/2014) + The following missile system has been done! Parameter is at the end of CreateSAM. Set it to true to allow the SAM to target lock players. + Added a function called IsSAMMissilesFollowing which returns true in case if SAM got following missiles, false if not. + Missiles can now have colors specified on radar. It's per-sam colors. + Added two functions called GetSAMMissileColor and SetSAMMissileColor v1.0 (01/01/2014) Initial release.
pawn Код:
native CreateSAM(Float:X, Float:Y, Float:Z, Float:rX=0.0, Float:rY=0.0, Float:rZ=0.0, Float:DrawDistance=200.0, Float:Range=300.0, Speed=80, Power=SAM_POWER_NORMAL, bool:follow=false, bool:followlimit=false);
native IsSAMMissilesFollowing(samid);
native DestroySAM(samid);
native AvoidSAMAttacksOnPlayer(playerid, samid);
native EnableSAMAttacksOnPlayer(playerid, samid);
native ToggleNoSAMAttacksOnPlayer(playerid, samid, bool:noattack);
native SetSAMMissileSpeed(samid, speed);
native SetSAMMissilePower(samid, Power);
native SetSAMMissileColor(samid, color);
native GetSAMMissileSpeed(samid);
native GetSAMMissilePower(samid);
native GetSAMObjectID(samid);
native GetSAMMissileColor(samid);
native IsMissileFollowingLimited(samid);
native DestroySAMMissile(playerid);
native IsSAMMissileChasing(playerid);
pawn Код:
native CreateSAM(Float:X, Float:Y, Float:Z, Float:rX=0.0, Float:rY=0.0, Float:rZ=0.0, Float:DrawDistance=200.0, Float:Range=300.0, Speed=80, Power=SAM_POWER_NORMAL, bool:follow=false, bool:followlimit=false);
/*
Creates a SAM launcher on the specified X,Y,Z coordinates with rotations specified. DrawDistance of the SAM object can also be set.
Range means the area range where SAM detects from it's X,Y,Z points.
Speed means the speed of the missiles being fired.
Power means the power of explosion.
Follow means whether the missiles should follow or not. Set it to true to get those missiles to follow.
followlimit means whether to limit the following missile range. Once if the player is out of range and if a following missile was there, it'd get destroyed.
*/
pawn Код:
native IsSAMMissilesFollowing(samid);
//Returns true if the SAM specified got following missiles, else false.
native DestroySAM(samid);
//Destroys the created SAM.
native AvoidSAMAttacksOnPlayer(playerid, samid);
//The specified SAM will stop attacking the specified player id.
native EnableSAMAttacksOnPlayer(playerid, samid);
//Opposed law of the above function, it will start attacking!
native ToggleNoSAMAttacksOnPlayer(playerid, samid, bool:noattack);
//If set to true, the specified SAM won't attack the specified playerid.
//If false, it will.
native SetSAMMissileSpeed(samid, speed);
//Sets the missile's speed for the specified SAM.
native SetSAMMissilePower(samid, power);
//Sets the missile's power for the specified SAM (Explosion Power).
native SetSAMMissileColor(samid, color);
//Sets the missile's radar icon color for the specified SAM
native GetSAMMissileSpeed(samid);
//Returns the missile speed of the specified SAM.
native GetSAMMissilePower(samid);
//Returns the missile's power of the specified SAM.
native GetSAMMissileColor(samid);
//Returns the missile's radar color of the specified SAM.
native GetSAMObjectID(samid);
//Returns the objectid (not model) of the SAM created.
native IsMissileFollowingLimited(samid);
//Returns true in case if followlimit is set to true, false if not.
native DestroySAMMissile(playerid);
//Destorys a missile which is launched on the player, returns 0 if there wasn't any missiles launched on player.
native IsSAMMissileChasing(playerid);
//Returns true if the playerid is being chased by a missile, false if not.
Explosion types:
pawn Код:
#define SAM_POWER_LOW 0
#define SAM_POWER_NORMAL 1
#define SAM_POWER_HIGH 2
#define SAM_POWER_BEST 3
Streamer isn't being used on v1.3
NOTE : If you want the SAM launcher object to be a streamer object, define this before including:
pawn Код:
#define USE_STREAMER
The include allows you to assign players who won't be getting attacks from the S-A-M, however if those people are near when the missiles explode, they'll get damaged and may even cause to death.
pawn Код:
new xb_base_SAM;
public OnFilterScriptInit()
{
xb_base_SAM = CreateSAM(...);
return 1;
}
public OnPlayerConnect(playerid)
{
new Lname[MAX_PLAYER_NAME];
GetPlayerName(playerid, Lname, sizeof(Lname));
if(!strfind(Lname, "[xB]")) ToggleNoSAMAttacksOnPlayer(playerid, xb_base_SAM, true); //Players with xB tag won't get attacked.
return 1;
}
You can also restrict the vehicle usage on certain areas using the S-A-M missile system. I had plans to make it more easily, but as I've said, I had some troubles and so I postponed those to the next update of this include. For now, you can create a timer and detect if player is on such vehicle ids or models, if so, enable the SAM attacks on player. If not, disable the SAM attacks on player. An example code:
pawn Код:
forward FINDAIRONSPAWN();
public FINDAIRONSPAWN()
{
for(new i; i< GetMaxPlayers(); i++)
{
if(!IsPlayerConnected(i)) continue;
if(!IsPlayerInRangeOfPoint(i,300.0,-1572.1666,705.5132,49.7188)) continue;
if(GetPlayerState(i) == 2)
{
if(GetVehicleModel(GetPlayerVehicleID(i)) == 520 || GetVehicleModel(GetPlayerVehicleID(i)) == 425 ||
GetVehicleModel(GetPlayerVehicleID(i)) == 447 || GetVehicleModel(GetPlayerVehicleID(i)) == 432) ToggleNoSAMAttacksOnPlayer(i, spawnsam, false);
else ToggleNoSAMAttacksOnPlayer(i, spawnsam, true);
}
else ToggleNoSAMAttacksOnPlayer(i, spawnsam, true);
}
return 1;
}
Another example, Restricted Area 51 which is created as a Filterscript. Check out that to know the common usage well.
Credits
Incognito for Streamer which was used on v1 and 1.2 versions.
RyDeR` for SetObjectFaceCoords3D function.
To the person who created the function called randomEx.
GamingJoker for the video.
SA-MP Team for SA-MP and it's natives.
Lordz™ for the rest of the include.
And all the players who have helped me in testing this include.
Download
More updates are coming up and so this project has been moved to GitHub.
https://github.com/Lordzy/L-SAM
Version 1.3
SolidFiles : http://www.solidfiles.com/d/85f421a480/
PasteBin : http://pastebin.com/nJEUZKvQ
Version 1.2
SolidFiles <NEW> http://www.solidfiles.com/d/de837c88f7/ - Fixed the error popping out in case if you use AvoidSAMAttacksOnPlayer or EnableSAMAttacksOnPlayer.
SolidFiles : http://www.solidfiles.com/d/c1d8366d83/
PasteBin : http://pastebin.com/htAVUdbn
Version 1
SolidFiles : http://www.solidfiles.com/d/117ba966bb/
PasteBin : http://pastebin.com/5iFNKBU8
Pictures/Video
The video is done by GamingJoker. Thanks to him :- )
[ame]http://www.youtube.com/watch?v=MMyN6uSXfSA[/ame]
NOTES
• As I've specified earlier, the include may or may not have bugs. Feel free to test it and in case if you've found, I'll be really thankful.
• I've spent some time at night, I really don't know why some variables have been declared. I hope I may optimize it well on the next version.
• In case if documentation is required for this, let me know it, I'll be doing it soon.
• An easy system for restricting vehicles will be done on the next update.
• YOU MUST DEFINE #define FILTERSCRIPT before including this in case if you're using it as an include!
And once again, happy new year!
Regards,
Lordz™.