Advertisement
Guest User

vagabon

a guest
Dec 30th, 2013
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.38 KB | None | 0 0
  1. /**
  2. * File: War3Source_Vagabond.sp
  3. * Description: The Vagabond race for SourceCraft.
  4. * Author(s): xDr.HaaaaaaaXx
  5. */
  6.  
  7. #pragma semicolon 1
  8. #include <sourcemod>
  9. #include <sdktools_tempents>
  10. #include <sdktools_functions>
  11. #include <sdktools_tempents_stocks>
  12. #include <sdktools_entinput>
  13. #include <sdktools_sound>
  14.  
  15. #include "W3SIncs/War3Source_Interface"
  16.  
  17. // War3Source stuff
  18. new thisRaceID, SKILL_SPEED, SKILL_SCOUT, SKILL_LOWGRAV, ULT_INVIS_TELE;
  19.  
  20. // Chance/Data Arrays
  21. new col1[4], col2[4], col3[4], col4[4], col5[4], col6[4], col7[4], col8[4], col9[4];
  22. new Float:VagabondGravity[5] = { 1.0, 0.9, 0.8, 0.7, 0.6 };
  23. new Float:VagabondSpeed[5] = { 1.0, 1.1, 1.2, 1.3, 1.4 };
  24. new Float:DamageChanse[5] = { 0.0, 0.20, 0.30, 0.40, 0.50 };
  25. new Float:PushForce[5] = { 0.0, 0.1, 0.2, 0.3, 0.4 };
  26. new Float:UltDelay[5] = { 0.0, 25.0, 24.0, 22.0, 20.0 };
  27.  
  28. new bool:bIsInvisible[MAXPLAYERS];
  29.  
  30. // Sounds
  31. new String:UltOutstr[] = "weapons/physcannon/physcannon_claws_close.wav";
  32. new String:UltInstr[] = "weapons/physcannon/physcannon_claws_open.wav";
  33. new String:spawnsound[] = "ambient/atmosphere/cave_hit2.wav";
  34.  
  35. // Other
  36. new HaloSprite, BeamSprite, SteamSprite;
  37. new m_vecBaseVelocity;
  38.  
  39. public Plugin:myinfo =
  40. {
  41. name = "War3Source Race - Vagabond",
  42. author = "xDr.HaaaaaaaXx",
  43. description = "The Vagabond race for War3Source.",
  44. version = "1.0.0.0",
  45. url = ""
  46. };
  47.  
  48. public OnPluginStart()
  49. {
  50. m_vecBaseVelocity = FindSendPropOffs( "CBasePlayer", "m_vecBaseVelocity" );
  51. col1[3] = 255;
  52. col2[3] = 255;
  53. col3[3] = 255;
  54. col4[3] = 255;
  55. col5[3] = 255;
  56. col6[3] = 255;
  57. col7[3] = 255;
  58. col8[3] = 255;
  59. col9[3] = 255;
  60. }
  61.  
  62. public OnMapStart()
  63. {
  64. HaloSprite = PrecacheModel( "materials/sprites/halo01.vmt" );
  65. BeamSprite = PrecacheModel( "materials/sprites/laser.vmt" );
  66. SteamSprite = PrecacheModel( "sprites/steam1.vmt" );
  67. War3_PrecacheSound( UltInstr );
  68. War3_PrecacheSound( UltOutstr );
  69. War3_PrecacheSound( spawnsound );
  70. }
  71.  
  72. public OnWar3PluginReady()
  73. {
  74. thisRaceID = War3_CreateNewRace( "Vagabond", "vagabond" );
  75.  
  76. SKILL_SPEED = War3_AddRaceSkill( thisRaceID, "Adrenaline", "Speed", false );
  77. SKILL_SCOUT = War3_AddRaceSkill( thisRaceID, "Scout", "Extra Damage", false );
  78. SKILL_LOWGRAV = War3_AddRaceSkill( thisRaceID, "Levitation", "Levitation", false );
  79. ULT_INVIS_TELE = War3_AddRaceSkill( thisRaceID, "Complete Invisibility", "Teleport and become completely invisible when not moving(can't move)", true );
  80.  
  81. W3SkillCooldownOnSpawn( thisRaceID, ULT_INVIS_TELE, 5.0, true);
  82.  
  83. War3_CreateRaceEnd( thisRaceID );
  84. }
  85.  
  86. public InitPassiveSkills( client )
  87. {
  88. if( War3_GetRace( client ) == thisRaceID )
  89. {
  90. War3_SetBuff( client, fMaxSpeed, thisRaceID, VagabondSpeed[War3_GetSkillLevel( client, thisRaceID, SKILL_SPEED )] );
  91. War3_SetBuff( client, fLowGravitySkill, thisRaceID, VagabondGravity[War3_GetSkillLevel( client, thisRaceID, SKILL_LOWGRAV )] );
  92. }
  93. }
  94.  
  95. public OnRaceChanged(client,oldrace,newrace)
  96. {
  97. if( newrace != thisRaceID )
  98. {
  99. War3_WeaponRestrictTo( client, thisRaceID, "" );
  100. W3ResetAllBuffRace( client, thisRaceID );
  101. }
  102. else
  103. {
  104. War3_WeaponRestrictTo( client, thisRaceID, "weapon_knife,weapon_scout" );
  105. if( IsPlayerAlive( client ) )
  106. {
  107. GivePlayerItem( client, "weapon_scout" );
  108. InitPassiveSkills( client );
  109. }
  110. }
  111. }
  112.  
  113. public OnSkillLevelChanged( client, race, skill, newskilllevel )
  114. {
  115. InitPassiveSkills( client );
  116. }
  117.  
  118. public OnWar3EventSpawn( client )
  119. {
  120. StopInvis( client );
  121. new race = War3_GetRace( client );
  122. if( race == thisRaceID )
  123. {
  124. GivePlayerItem( client, "weapon_scout" );
  125. InitPassiveSkills( client );
  126. EmitSoundToAll( spawnsound, client );
  127. }
  128. }
  129.  
  130. public OnWar3EventDeath( victim, attacker )
  131. {
  132. W3ResetAllBuffRace( victim, thisRaceID );
  133. }
  134.  
  135. public OnWar3EventPostHurt( victim, attacker, Float:damage )
  136. {
  137. if( W3GetDamageIsBullet() && ValidPlayer( victim, true ) && ValidPlayer( attacker, true ) && GetClientTeam( victim ) != GetClientTeam( attacker ) )
  138. {
  139. if( War3_GetRace( attacker ) == thisRaceID )
  140. {
  141. new skill_level = War3_GetSkillLevel( attacker, thisRaceID, SKILL_SCOUT );
  142. if( !Hexed( attacker, false ) && GetRandomFloat( 0.0, 1.0 ) <= DamageChanse[skill_level] )
  143. {
  144. new String:wpnstr[32];
  145. GetClientWeapon( attacker, wpnstr, 32 );
  146. if( StrEqual( wpnstr, "weapon_scout" ) )
  147. {
  148. col1[0] = GetRandomInt( 0, 255 );
  149. col1[1] = GetRandomInt( 0, 255 );
  150. col1[2] = GetRandomInt( 0, 255 );
  151.  
  152. col2[0] = GetRandomInt( 0, 255 );
  153. col2[1] = GetRandomInt( 0, 255 );
  154. col2[2] = GetRandomInt( 0, 255 );
  155.  
  156. col3[0] = GetRandomInt( 0, 255 );
  157. col3[1] = GetRandomInt( 0, 255 );
  158. col3[2] = GetRandomInt( 0, 255 );
  159.  
  160. col4[0] = GetRandomInt( 0, 255 );
  161. col4[1] = GetRandomInt( 0, 255 );
  162. col4[2] = GetRandomInt( 0, 255 );
  163.  
  164. col5[0] = GetRandomInt( 0, 255 );
  165. col5[1] = GetRandomInt( 0, 255 );
  166. col5[2] = GetRandomInt( 0, 255 );
  167.  
  168. col6[0] = GetRandomInt( 0, 255 );
  169. col6[1] = GetRandomInt( 0, 255 );
  170. col6[2] = GetRandomInt( 0, 255 );
  171.  
  172. col7[0] = GetRandomInt( 0, 255 );
  173. col7[1] = GetRandomInt( 0, 255 );
  174. col7[2] = GetRandomInt( 0, 255 );
  175.  
  176. col8[0] = GetRandomInt( 0, 255 );
  177. col8[1] = GetRandomInt( 0, 255 );
  178. col8[2] = GetRandomInt( 0, 255 );
  179.  
  180. col9[0] = GetRandomInt( 0, 255 );
  181. col9[1] = GetRandomInt( 0, 255 );
  182. col9[2] = GetRandomInt( 0, 255 );
  183.  
  184. new Float:start_pos[3];
  185. new Float:target_pos[3];
  186.  
  187. GetClientAbsOrigin( attacker, start_pos );
  188. GetClientAbsOrigin( victim, target_pos );
  189.  
  190. target_pos[2] += 40;
  191.  
  192. // 1
  193. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  194. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  195. start_pos[2] += 40;
  196.  
  197. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col1, 40 );
  198. TE_SendToAll();
  199.  
  200. // 2
  201. GetClientAbsOrigin( attacker, start_pos );
  202.  
  203. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  204. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  205. start_pos[2] += 40;
  206.  
  207. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col2, 40 );
  208. TE_SendToAll();
  209.  
  210. // 3
  211. GetClientAbsOrigin( attacker, start_pos );
  212.  
  213. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  214. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  215. start_pos[2] += 40;
  216.  
  217. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col3, 40 );
  218. TE_SendToAll();
  219.  
  220. // 4
  221. GetClientAbsOrigin( attacker, start_pos );
  222.  
  223. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  224. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  225. start_pos[2] += 40;
  226.  
  227. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col4, 40 );
  228. TE_SendToAll();
  229.  
  230. // 5
  231. GetClientAbsOrigin( attacker, start_pos );
  232.  
  233. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  234. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  235. start_pos[2] += 40;
  236.  
  237. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col5, 40 );
  238. TE_SendToAll();
  239.  
  240. // 6
  241. GetClientAbsOrigin( attacker, start_pos );
  242.  
  243. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  244. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  245. start_pos[2] += 40;
  246.  
  247. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col6, 40 );
  248. TE_SendToAll();
  249.  
  250. // 7
  251. GetClientAbsOrigin( attacker, start_pos );
  252.  
  253. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  254. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  255. start_pos[2] += 40;
  256.  
  257. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col7, 40 );
  258. TE_SendToAll();
  259.  
  260. // 8
  261. GetClientAbsOrigin( attacker, start_pos );
  262.  
  263. start_pos[0] += GetRandomFloat( -500.0, 500.0 );
  264. start_pos[1] += GetRandomFloat( -500.0, 500.0 );
  265. start_pos[2] += 40;
  266.  
  267. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col8, 40 );
  268. TE_SendToAll();
  269.  
  270. // 9
  271. GetClientAbsOrigin( attacker, start_pos );
  272.  
  273. start_pos[2] += 40;
  274. target_pos[2] += 5;
  275.  
  276. TE_SetupBeamPoints( start_pos, target_pos, BeamSprite, HaloSprite, 0, 0, 30.0, 10.0, 10.0, 0, 0.0, col9, 40 );
  277. TE_SendToAll();
  278.  
  279. if( !W3HasImmunity( victim, Immunity_Skills ) )
  280. {
  281. War3_DealDamage( victim, damage, attacker, DMG_BULLET, "vagabond_crit" );
  282. W3FlashScreen( victim, RGBA_COLOR_RED );
  283.  
  284. W3PrintSkillDmgHintConsole( victim, attacker, War3_GetWar3DamageDealt(), SKILL_SCOUT );
  285. }
  286. }
  287. }
  288. }
  289. }
  290. }
  291. public OnUltimateCommand( client, race, bool:pressed )
  292. {
  293. new userid = GetClientUserId( client );
  294. if( race == thisRaceID && pressed && userid > 1 && IsPlayerAlive( client ) && !Silenced( client ) )
  295. {
  296. new ult_level = War3_GetSkillLevel( client, race, ULT_INVIS_TELE );
  297. if( ult_level > 0 )
  298. {
  299. if( War3_SkillNotInCooldown( client, thisRaceID, ULT_INVIS_TELE, true ) )
  300. {
  301. if( !bIsInvisible[client] )
  302. {
  303. ToggleInvisibility( client );
  304. TeleportPlayer( client );
  305. War3_CooldownMGR( client, 0.5, thisRaceID, ULT_INVIS_TELE, false, true);
  306. }
  307. else
  308. {
  309. ToggleInvisibility( client );
  310. War3_CooldownMGR( client, UltDelay[ult_level], thisRaceID, ULT_INVIS_TELE, false, true);
  311. }
  312.  
  313. new Float:pos[3];
  314.  
  315. GetClientAbsOrigin( client, pos );
  316.  
  317. pos[2] += 50;
  318.  
  319. TE_SetupGlowSprite( pos, SteamSprite, 1.0, 2.5, 130 );
  320. TE_SendToAll();
  321. }
  322. }
  323. else
  324. {
  325. W3MsgUltNotLeveled( client );
  326. }
  327. }
  328. }
  329.  
  330. stock StopInvis( client )
  331. {
  332. if( bIsInvisible[client] )
  333. {
  334. bIsInvisible[client] = false;
  335. War3_SetBuff( client, bNoMoveMode, thisRaceID, false );
  336. War3_SetBuff( client, fInvisibilitySkill, thisRaceID, 1.0 );
  337. EmitSoundToAll( UltOutstr, client );
  338. GivePlayerItem( client, "weapon_knife,weapon_scout" );
  339. }
  340. }
  341.  
  342. stock StartInvis( client )
  343. {
  344. if ( !bIsInvisible[client] )
  345. {
  346. bIsInvisible[client] = true;
  347. CreateTimer( 1.0, StartStop, client );
  348. War3_SetBuff( client, fInvisibilitySkill, thisRaceID, 0.0 );
  349. EmitSoundToAll( UltInstr, client );
  350. War3_WeaponRestrictTo( client, thisRaceID, "weapon_knife,weapon_scout" );
  351. }
  352. }
  353.  
  354. public Action:StartStop( Handle:timer, any:client )
  355. {
  356. if( ValidPlayer( client, true ) )
  357. {
  358. War3_SetBuff( client, bNoMoveMode, thisRaceID, true );
  359. }
  360. }
  361.  
  362. stock ToggleInvisibility( client )
  363. {
  364. if( bIsInvisible[client] )
  365. {
  366. StopInvis( client );
  367. }
  368. else
  369. {
  370. StartInvis( client );
  371. }
  372. }
  373.  
  374. stock TeleportPlayer( client )
  375. {
  376. if( client > 0 && IsPlayerAlive( client ) )
  377. {
  378. new ult_level = War3_GetSkillLevel( client, thisRaceID, ULT_INVIS_TELE );
  379. new Float:startpos[3];
  380. new Float:endpos[3];
  381. new Float:localvector[3];
  382. new Float:velocity[3];
  383.  
  384. GetClientAbsOrigin( client, startpos );
  385. War3_GetAimEndPoint( client, endpos );
  386.  
  387. localvector[0] = endpos[0] - startpos[0];
  388. localvector[1] = endpos[1] - startpos[1];
  389. localvector[2] = endpos[2] - startpos[2];
  390.  
  391. velocity[0] = localvector[0] * PushForce[ult_level];
  392. velocity[1] = localvector[1] * PushForce[ult_level];
  393. velocity[2] = localvector[2] * PushForce[ult_level];
  394.  
  395. SetEntDataVector( client, m_vecBaseVelocity, velocity, true );
  396. }
  397. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement