SA-MP Forums Archive
[Include] Missile Launcher - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+---- Forum: Includes (https://sampforum.blast.hk/forumdisplay.php?fid=83)
+---- Thread: [Include] Missile Launcher (/showthread.php?tid=608018)

Pages: 1 2


Missile Launcher - AbyssMorgan - 26.05.2016

Hi I would like to present include for Missile Launcher.

Video:
1. Sniper Missile
2. Vehicle Missile (MapAndreas Version)
3. Vehicle Missile (ColAndreas Update)
4. Marica Mortar V1
5. Heavy Marica Mortar
6. Missile Launcher Aim Player
7. Congreve Rocket
8. Marica Mortar V2
9. New Vehicle Missile
10. Flares

Functions:
PHP Code:
Missile::Launch(type,Float:detection_range,Float:explode_radius,Float:speed,Float:x,Float:y,Float:z,worldid,interiorid,playerid,
Float:streamdistance,missile_object,Float:tx,Float:ty,Float:tz,byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM,
bool:remote=false,remote_count=MAX_MISSILE_REMOTE_TARGET,remote_height=1.0,Float:arc_roll=0.0,Float:damage=-1.0,
Float:vehicle_damage=-1.0);
type explosion type //https://sampwiki.blast.hk/wiki/Explosion_List
Float:detection_range detection range player/vehicle
Float
:explode_radius the explosion range (the same as in CreateExplosion)
Float:speed projectile speed
Float
:xFloat:yFloat:Starting position
worldid
interioridplayeridFloat:streamdistance the same as in CreateDynamicObject
missile_object
MISSILE_OBJECT_NORMAL MISSILE_OBJECT_BIG MISSILE_OBJECT_HYDRA MISSILE_OBJECT_BOMB MISSILE_OBJECT_BOMB_STATIC MISSILE_OBJECT_FLARE
Float
:txFloat:tyFloat:tz Target position
byplayerid 
selected player will be immune to detection range
teamid 
player team will be immune to detection range
remote 
enable remote targeting (for Vehicle Missile Mortar)
remote_count number of remote targeting 1 32
remote_height 
arc height
arc_roll 
rotation Y axis
Float
:damage player damage on explosion created
Float
:vehicle_damage vehicle damage on explosion created
Rotation
Auto!
MissileLaunchAimPlayer(targetid,type,Float:detection_range,Float:explode_radius,Float:speed,Float:x,Float:y,Float:z,
worldid,interiorid,playerid,Float:streamdistance,missile_object,Float:tx,Float:ty,Float:tz,
byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM,Float:damage=-1.0,Float:vehicle_damage=-1.0);
MissileRemoteTarget(mobid,Float:tx,Float:ty,Float:tz,Float:speed 0.0); 
Missile::Destroy(mobid);
mobid id returned by Missile::Launch
Missile
::StopAimPlayer(mobid);
Missile::GetExplodeVisibility();
Missile::SetExplodeVisibility(Float:explode_stream);
Missile::DisableAllAim(playerid); 
Callbacks:
PHP Code:
OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid,byplayerid);
types:
MISSILE_DESTROY_TYPE_TARGET  //When rocket reaches its destination (always killerid=INVALID_PLAYER_ID)
MISSILE_DESTROY_TYPE_DETECT  //When rocket has been destroyed by detection range
MISSILE_DESTROY_TYPE_KILL    //When rocket has been destroyed by player
OnMissileDetectPlayer(playerid,killerid); //called when a player is within range of detection range
OnMissileRequestLaunch(Float:x,Float:y,Float:z,playerid,targetid); 
Example Code:
PHP Code:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ){
    if(
weaponid == 34){
        new 
Float:xFloat:yFloat:z,
            
Float:txFloat:tyFloat:tz,
            
Float:rxFloat:rz,
            
vwintFloat:dist;
        
GetPlayerPos(playerid,x,y,z);
        
GetRotationFor2Point3D(x,y,z,fX,fY,fZ,rx,rz);
        
dist GetDistanceBetweenPoints3D(x,y,z,fX,fY,fZ);
        
vw GetPlayerVirtualWorld(playerid);
        
int GetPlayerInterior(playerid);
        
GetPointInFront3D(x,y,z,rx,rz,4.0,tx,ty,tz);
        
Missile::Launch(MISSILE_TYPE_EXPLODE_HUGE,4.0,25.0,35.0,tx,ty,tz,vw,int,-1,300.0,MISSILE_OBJECT_HYDRA,fX,fY,fZ,playerid,.damage=100.0,.vehicle_damage=1000.0);
        
GetPointInFront3D(x,y,z,rx,rz,3.0,tx,ty,tz);
        
Missile::Launch(MISSILE_TYPE_EXPLODE_HUGE,4.0,25.0,35.0,tx,ty,tz+3.0,vw,int,-1,300.0,MISSILE_OBJECT_HYDRA,fX,fY,fZ+3.0,playerid,.damage=100.0,.vehicle_damage=1000.0);
        
Missile::Launch(MISSILE_TYPE_EXPLODE_HUGE,4.0,25.0,35.0,tx,ty,tz-3.0,vw,int,-1,300.0,MISSILE_OBJECT_HYDRA,fX,fY,fZ-3.0,playerid,.damage=100.0,.vehicle_damage=1000.0);
        
GetPointInFront3D(tx,ty,tz,rx,rz+90.0,3.0,x,y,z);
        
GetPointInFront3D(x,y,z,rx,rz,dist,fX,fY,fZ);
        
Missile::Launch(MISSILE_TYPE_EXPLODE_HUGE,4.0,25.0,35.0,x,y,z,vw,int,-1,300.0,MISSILE_OBJECT_HYDRA,fX,fY,fZ,playerid,.damage=100.0,.vehicle_damage=1000.0);
        
GetPointInFront3D(tx,ty,tz,rx,rz-90.0,3.0,x,y,z);
        
GetPointInFront3D(x,y,z,rx,rz,dist,fX,fY,fZ);
        
Missile::Launch(MISSILE_TYPE_EXPLODE_HUGE,4.0,25.0,35.0,x,y,z,vw,int,-1,300.0,MISSILE_OBJECT_HYDRA,fX,fY,fZ,playerid,.damage=100.0,.vehicle_damage=1000.0);
    }
    return 
1;

Bullet example:
PHP Code:
Missile::Launch(MISSILE_TYPE_EXPLODE_NONE,1.0,1.0,20.0,Float:x,Float:y,Float:z,worldid,interiorid,playerid,Float:streamdistance,MISSILE_OBJECT_BULLET,Float:tx,Float:ty,Float:tz,byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM,.damage=5.0,.vehicle_damage=25.0); 
How to check is player kill by missile (this is not required if you using custom missile damage):
PHP Code:
enums:
last_missile_shot
last_missile_player
public OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid,byplayerid){
    if(
type == MISSILE_DESTROY_TYPE_DETECT && killerid != INVALID_PLAYER_ID){
        
PlayerInfo[killerid][last_missile_shot] = GetTickCount();
        
PlayerInfo[killerid][last_missile_player] = byplayerid;
    }
    return 
1;
}
public 
OnMissileDetectPlayer(playerid,killerid){
    if(
killerid != INVALID_PLAYER_ID){
        
PlayerInfo[playerid][last_missile_shot] = GetTickCount();
        
PlayerInfo[playerid][last_missile_player] = killerid;
    }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason){
    if(
PlayerInfo[playerid][last_missile_player] != INVALID_PLAYER_ID && reason 46 && playerid != killerid){
        if(
GetTickCount()-PlayerInfo[playerid][last_missile_shot] < 2000){
            
killerid PlayerInfo[playerid][last_missile_player];
            
reason 51;
        }
    }
    
    
//your code
    
return 1;

Download:
Missile.inc
3DTryg.inc Thread
ColAndreas Plugin

See also Vehicle Missile Launcher


Non-Registered Users:
Bug Report



Re: Missile Launcher - Ivan_Ino - 26.05.2016

Good work.. I made this before long time for my server, xD
rep+ for 3DTryg and all this aswell


Re: Missile Launcher - Amunra - 27.05.2016

Wow.. Amazing ...
I Like your Job Man ...


Re: Missile Launcher - AbyssMorgan - 16.06.2016

Update 1.2:
Added additional parameters:

Code:
MissileLaunch(type,Float:detection_range,Float:explode_radius,Float:speed,Float:x,Float:y,Float:z,
worldid,interiorid,playerid,Float:streamdistance,missile_object,
Float:tx,Float:ty,Float:tz,byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM); 

byplayerid - selected player will be immune to detection range
teamid - player team will be immune to detection range



Re: Missile Launcher - AbyssMorgan - 18.06.2016

Update v1.3:

Added callback:
PHP Code:
OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid); 
Fix auto rotation for MISSILE_OBJECT_HYDRA


Re: Missile Launcher - AbyssMorgan - 19.06.2016

Update v1.4:
- Added extended functions:
PHP Code:
Float:GetMissileExplodeVisibility();
SetMissileExplodeVisibility(Float:explode_stream); 
- Added version number


Re: Missile Launcher - AbyssMorgan - 22.06.2016

Update v1.5B:
- Added callback:
PHP Code:
OnMissileDetectPlayer(playerid,killerid); 
- Fixed exploding rockets by passengers when they were fired from a vehicle @VehicleMissile.inc


Re: Missile Launcher - AbyssMorgan - 23.06.2016

Update v1.6:
- Again fix rotation for MISSILE_OBJECT_HYDRA
- Fixed identification missile between scripts
- Changed value INVALID_MISSILE_ID from -1 to 0


Re: Missile Launcher - AbyssMorgan - 16.07.2016

Update v1.6.4

- Added new params for MissileLaunch
Code:
MissileLaunch(type,Float:detection_range,Float:explode_radius,Float:speed,Float:x,Float:y,Float:z,worldid,interiorid,playerid,
Float:streamdistance,missile_object,Float:tx,Float:ty,Float:tz,byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM,
bool:remote=false,remote_count=MAX_MISSILE_REMOTE_TARGET,remote_height=1.0);
- Added function:
PHP Code:
MissileRemoteTarget(mobid,Float:tx,Float:ty,Float:tz,Float:speed 0.0); 
- Added Definitions:
PHP Code:
MAX_MISSILE_REMOTE_TARGET 
- Timers removed, replaced OnDynamicObjectMoved


Re: Missile Launcher - Freaksken - 16.07.2016

Not anything I would use, but good job nonetheless!


Re: Missile Launcher - SyS - 16.07.2016

nice one


Re: Missile Launcher - AbyssMorgan - 05.08.2016

Update v1.6.6:

- Fixed a random detection player who shoots. (Thank you for reporting @Slotomic)


Re: Missile Launcher - Jensenn - 10.08.2016

awesome


Re: Missile Launcher - AbyssMorgan - 24.11.2016

Update v1.7.0:

- Added functions:
PHP код:
MissileLaunchAimPlayer(targetid,type,Float:detection_range,Float:explode_radius,Float:speed,Float:x,Float:y,Float:z,worldid,interiorid,playerid,Float:streamdistance,missile_object,Float:tx,Float:ty,Float:tz,byplayerid=INVALID_PLAYER_ID,teamid=ANY_TEAM);
bool:MissileStopAimPlayer(mobid); 
Video:
https://www.youtube.com/watch?v=bS6jnEebJR4


Re: Missile Launcher - AbyssMorgan - 11.02.2017

Issues:
- Idle players don't see missile projectiles.
PHP код:
//Fix
public OnPlayerConnect(playerid){
    
Streamer_ToggleIdleUpdate(playerid,1);
    
    return 
1;

Components:
Missile.inc
VehicleMissile.inc
VehicleMissileCol.inc


Re: Missile Launcher - X337 - 11.02.2017

Thanks for the include.
Is there any way to detect, if a player just killed a player / destroyed a vehicle with a missile?


Re: Missile Launcher - AbyssMorgan - 11.02.2017

SAMP Synchronization is still suck, maybe this code working:
PHP код:
public OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid){
    
Tryg3DForeach(i){
        if(
IsPlayerInRangeOfPoint(i,5.0,x,y,z)){
            new 
Float:hp;
            
GetPlayerHealth(killerid,hp);
            if(
hp <= 0.0){
                
//bla bla bla
            
}
        }
    }
    
    return 
1;




Re: Missile Launcher - Lordzy - 11.02.2017

Quote:
Originally Posted by AbyssMorgan
Посмотреть сообщение
SAMP Synchronization is still suck, maybe this code working:
PHP код:
public OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid){
    
Tryg3DForeach(i){
        if(
IsPlayerInRangeOfPoint(i,5.0,x,y,z)){
            new 
Float:hp;
            
GetPlayerHealth(killerid,hp);
            if(
hp <= 0.0){
                
//bla bla bla
            
}
        }
    }
    
    return 
1;

A better way would be to set a boolean variable true upon missile hitting the player. Reset the boolean in case if the player has inflicted damage by something else. Under OnPlayerDeath, if the boolean variable is true, it can be concluded that player's death was caused by the missile explosion.


Re: Missile Launcher - AbyssMorgan - 14.02.2017

Update v1.8.0:

- Updated callback:
Код:
OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid,byplayerid);
How to check is player kill by missile:
PHP код:
enums:
last_missile_shot
last_missile_player
public OnMissileDestroy(mobid,Float:x,Float:y,Float:z,type,killerid,byplayerid){
    if(
type == MISSILE_DESTROY_TYPE_DETECT && killerid != INVALID_PLAYER_ID){
        
PlayerInfo[killerid][last_missile_shot] = GetTickCount();
        
PlayerInfo[killerid][last_missile_player] = byplayerid;
    }
    return 
1;
}
public 
OnMissileDetectPlayer(playerid,killerid){
    if(
killerid != INVALID_PLAYER_ID){
        
PlayerInfo[playerid][last_missile_shot] = GetTickCount();
        
PlayerInfo[playerid][last_missile_player] = killerid;
    }
    return 
1;
}
public 
OnPlayerDeath(playeridkilleridreason){
    if(
PlayerInfo[playerid][last_missile_player] != INVALID_PLAYER_ID && reason 46 && playerid != killerid){
        if(
GetTickCount()-PlayerInfo[playerid][last_missile_shot] < 2000){
            
killerid PlayerInfo[playerid][last_missile_player];
            
reason 51;
        }
    }
    
    
//your code
    
return 1;




Re: Missile Launcher - AbyssMorgan - 26.03.2017

Update v1.8.1:

- Remove useless Timer after missile destroy