[Include] L_S-A-M : Lordz's Surface to Air Missile system!
#1

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,
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.
Natives of this include:
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);
Small explanation for each function:
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.
*/
NOTE : Don't set below 20 while using following missiles, it may look crappy and also may create some issues.

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
SAM_POWER_LOW does a normal explosion, SAM_POWER_NORMAL too does that. From SAM_POWER_HIGH, it goes a bit more advanced and SAM_POWER_BEST does the max powered explosion (Not just 1 explosion)

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
Making the S-A-M friendly to assigned players:
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;
}
Restricting certain vehicles:

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;
}
Here, I've restricted Hunter, Hydra, Seasparrow and Tanker usage on the area I've created the S-A-M.

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™.
Reply
#2

Good job as always, +rep for ma Lordzieee
Reply
#3

Looks nice, good job!
You should indent the examples though
Reply
#4

Nice!
Reply
#5

Very impressive. We couldn't wait less from you, Lordz, always awesome.
I'll be testing it for some projects of mine, thank you.
Reply
#6

You fuckin cool LordZ, i love how missiles follow the players in GTA SA, hope you added it in next version

* Jake Hero throws reputation at Lord Z
* Auto Success (Due it is non-RP lmao)

- This include is fuckin unique.
Reply
#7

Thanks everyone! ^_^
@_Jake_, On the beta of this include's release, it had the following system. But due to some performance problems and sync, I've postponed it for the next version so that I can optimize it and make it much clear.
Reply
#8

this makes me remember this: https://sampforum.blast.hk/showthread.php?tid=115695


Nice work, very cool this.
Reply
#9

Quote:
Originally Posted by PT
Посмотреть сообщение
this makes me remember this: https://sampforum.blast.hk/showthread.php?tid=115695


Nice work, very cool this.
Yeah, I've already mentioned in my main post that after creating this one, I came to know that there had been a S-A-M release already however I find that as a discontinued project now. I'll bring much changes to this one especially in this one especially in trying to do the following missiles in a better way!
Reply
#10

This is effin' awesome. Though, I have my own scripted S-A-M system but this is very nice. Keep up the good job! +Rep for you man !
Reply
#11

Quote:
Originally Posted by iBeast
Посмотреть сообщение
This is effin' awesome. Though, I have my own scripted S-A-M system but this is very nice. Keep up the good job! +Rep for you man !
Thanks! :- )

v1.2 update!
I've added following missiles system. It works fine when I've tested, but I'd like to know it from others too in case if they're testing. Also, each SAM's missile radar icon's color can be now set.

Further information in regarding the include and update can be found on the main topic, please refer it. :- )
Reply
#12

I've included a video, thanks to GamingJoker for creating the whole video. There's two main scenes, first on a base which belongs to the gang RD. So if a non RD member gets in, the missiles will be fired. And on the second main scene, the missiles are fired only to restricted vehicles in case if it's occupied by a driver. <The video was taken with the 1st version of the include, so there's no following missiles included in it. However, I'll post a video of following missiles soon enough.>

Once again, I'd like to remind you all to use #define FILTERSCRIPT in case if it's a filterscript. I spent many hours in knowing what mistake I've done, but then realized that I forgot to keep that define on my filterscript while using my own include. -_-

There was a small mistake on the Pastebin code I've given, the links are updated too!
Reply
#13

The indentation off of pastebin is all fucked up you should know actually just checked and also fucked up on solidfiles as well whats up with that Lordz? It's a pain in the ass to try and read this code.

Another couple of things, why bother using this LordzSAMTimer() if using the streamer ? Dynamic areas make a lot more sense.

You create dynamic objects but don't use the MoveDynamicObject() function I would recommend removing dynamic objects completely since you use an acceleration type of function when moving the object the streamer is too slow to keep up with frames.
Reply
#14

Quote:
Originally Posted by [uL]Pottus
Посмотреть сообщение
The indentation off of pastebin is all fucked up you should know actually just checked and also fucked up on solidfiles as well whats up with that Lordz? It's a pain in the ass to try and read this code.

Another couple of things, why bother using this LordzSAMTimer() if using the streamer ? Dynamic areas make a lot more sense.

You create dynamic objects but don't use the MoveDynamicObject() function I would recommend removing dynamic objects completely since you use an acceleration type of function when moving the object the streamer is too slow to keep up with frames.
1) About Indentation : Hah, I always got that problem while coding. I've been used to my own style, I'll do it in an Allman style with good indentation when I'm free.

2) About the timer : I've kept a define called USE_STREAMER. If it's defined, it'll use Dynamic object just for the S-A-M launcher. Thanks for reminding me about the DynamicAreas, when I'm updating the code, I'll add the dynamic area code if required.

3) Missiles are the only ones which are moving in this code and nope, I haven't used DynamicObjects on those missiles.
Reply
#15

Ahh I see that makes sense I probably overlooked it and thought it was the actual missile instead of the S-A-M launcher
Reply
#16

I used his include to prove some things in my GM COD, did not see any mistake in the programming. (Though of all forms I will continue proving it to see if I find some failure).

Really brilliant Lordz, would kiss it if it was near me , but unfortunately it it is not.

Sorry my bad english and regards .
Reply
#17

Great job,Lordz!
Well done bro,I like this system alot..
Reply
#18

Nice Work Lordz!
Btw Joka you can't +rep :\
+rep is for big cluckers
Reply
#19

Good job buddy, but I knew this was good even before you started working at it :P
Good luck with further releases, Lordz
Reply
#20

Thanks everyone! :- )
@Pottus, Ah yeah, it do happen.
@EnzoMetlc, well in case if you find any troubles from the include, please let me know about it.
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)