|
Title: Human Alliance Post by: Anthony Iacono on December 01, 2009, 10:47:32 PM Hey,
Just thought I'd post Human since its pretty much done. Changes may occur between now and release (teleport tweaks.) Code: /** * File: War3Source_HumanAlliance.sp * Description: The Human Alliance race for War3Source. * Author(s): Anthony Iacono */ #pragma semicolon 1 #include <sourcemod> #include "War3Source/War3Source_Interface" #include <sdktools> #include <sdktools_functions> #include <sdktools_tempents> #include <sdktools_tempents_stocks> new raceID; new iTeleportCount[65]; new bool:bCanTeleport[65]; new Handle:MaxTeleportCvar; new Handle:TeleportCooldownCvar; // Effects new BeamSprite,HaloSprite; public Plugin:myinfo = { name = "War3Source Race - Human Alliance", author = "PimpinJuice", description = "The Human Alliance race for War3Source.", version = "1.0.0.0", url = "http://pimpinjuice.net/" }; public OnPluginStart() { HookEvent("player_spawn",PlayerSpawnEvent); HookEvent("player_hurt",PlayerHurtEvent); MaxTeleportCvar=CreateConVar("war3_human_teleport_max","3","Max amount of teleports per round, 0 for unlimited"); TeleportCooldownCvar=CreateConVar("war3_human_teleport_cooldown","15.0","Cooldown between teleports"); } public OnWar3PluginReady() { raceID=War3_CreateRace("Human Alliance", "human", "You are now part of the Human Alliance.", "You will be part of the Human Alliance when you die or respawn.", "Invisibility", "Makes you partially invisible, \n62% visibility - 37% visibility.", "Devotion Aura", "Gives you additional 15-50 health each round.", "Bash", "Have a 15-32% chance to render an \nenemy immobile for 1 second.", "Teleport", "Allows you to teleport to where you \naim, 60-105 feet being the range."); } public OnMapStart() { BeamSprite=PrecacheModel("materials/sprites/lgtning.vmt"); HaloSprite=PrecacheModel("materials/sprites/halo01.vmt"); } public OnWar3PlayerAuthed(client) { } public OnRaceSelected(client,oldrace,race) { if(race!=raceID) { War3_SetMinAlpha(client,255); // if we aren't their race anymore we shouldn't be controlling their alpha } } public OnUltimateCommand(client,race,bool:pressed) { new userid=GetClientUserId(client); if(race==raceID && pressed && userid>1 && IsPlayerAlive(client)) { new ult_level=War3_GetSkillLevel(client,race,3); if(ult_level>0) { new max_teles=GetConVarInt(MaxTeleportCvar); if(max_teles<0) max_teles=0; new Float:cooldown=GetConVarFloat(TeleportCooldownCvar); if(cooldown<0.0) cooldown=0.0; if(!bCanTeleport[client]) { War3_ChatMessage(client,"You can not teleport so quickly, cooldown time is %.1f seconds.",cooldown); } else { if(!max_teles || iTeleportCount[client]<max_teles) { new Float:dist=0.0; switch(ult_level) { case 1: dist=600.0; case 2: dist=800.0; case 3: dist=1000.0; case 4: dist=1200.0; } new Float:out[3]; if(TeleportPlayerView(client,dist,out)) { bCanTeleport[client]=false; iTeleportCount[client]+=1; War3_ChatMessage(client,"You teleported!"); CreateTimer(cooldown,AllowTeleport,userid); } else { War3_ChatMessage(client,"Sorry, you can't teleport there."); } } else { War3_ChatMessage(client,"You can only teleport %d times per round.",max_teles); } } } } } public Action:AllowTeleport(Handle:timer,any:userid) { new client=GetClientOfUserId(userid); if(client>0) { bCanTeleport[client]=true; } } public OnSkillLevelChanged(client,race,skill,oldskilllevel,newskilllevel) { if(race==raceID&&skill==0&&newskilllevel>=0&&War3_GetRace(client)==raceID) { new alpha; switch(newskilllevel) { case 0: alpha=255; case 1: alpha=158; case 2: alpha=137; case 3: alpha=115; case 4: alpha=94; } if(newskilllevel>0) War3_ChatMessage(client,"You fade %s into the backdrop.",(newskilllevel==1)?"slightly":(newskilllevel==2)?"well":(newskilllevel==3)?"greatly":"dramatically"); War3_SetMinAlpha(client,alpha); } } // Events public PlayerSpawnEvent(Handle:event,const String:name[],bool:dontBroadcast) { new userid=GetEventInt(event,"userid"); new client=GetClientOfUserId(userid); if(client>0) { // Teleport reset bCanTeleport[client]=true; iTeleportCount[client]=0; new race=War3_GetRace(client); if(race==raceID) { new skill_devo=War3_GetSkillLevel(client,race,1); if(skill_devo) { // Devotion Aura new hpadd; switch(skill_devo) { case 1: hpadd=15; case 2: hpadd=26; case 3: hpadd=38; case 4: hpadd=50; } War3_ChatMessage(client,"Your devotion aura activates."); new Float:vec[3]; GetClientAbsOrigin(client,vec); vec[2]+=25.0; new ringColor[4]={0,0,0,0}; new team=GetClientTeam(client); if(team==2) { ringColor={255,0,0,255}; } else if(team==3) { ringColor={0,0,255,255}; } TE_SetupBeamRingPoint(vec,40.0,10.0,BeamSprite,HaloSprite,0,15,1.0,15.0,0.0,ringColor,10,0); TE_SendToAll(); SetEntityHealth(client,GetClientHealth(client)+hpadd); } new skill_invis=War3_GetSkillLevel(client,race,0); new alpha; switch(skill_invis) { case 0: alpha=255; case 1: alpha=158; case 2: alpha=137; case 3: alpha=115; case 4: alpha=94; } if(skill_invis>0) War3_ChatMessage(client,"You fade %s into the backdrop.",(skill_invis==1)?"slightly":(skill_invis==2)?"well":(skill_invis==3)?"greatly":"dramatically"); War3_SetMinAlpha(client,alpha); } } } public PlayerHurtEvent(Handle:event,const String:name[],bool:dontBroadcast) { new userid=GetEventInt(event,"userid"); new attacker_userid=GetEventInt(event,"attacker"); if(userid&&attacker_userid&&userid!=attacker_userid) { new index=GetClientOfUserId(userid); new attacker_index=GetClientOfUserId(attacker_userid); if(index>0&&attacker_index>0) { new race=War3_GetRace(attacker_index); if(race==raceID) { new skill_bash=War3_GetSkillLevel(attacker_index,race,2); if(skill_bash) { // Bash new percent; switch(skill_bash) { case 1: percent=15; case 2: percent=21; case 3: percent=27; case 4: percent=32; } if(GetRandomInt(1,100)<=percent) { War3_ChatMessage(index,"You have been bashed frozen!"); War3_ChatMessage(attacker_index,"You just bashed your enemy frozen!"); SetEntityMoveType(index,MOVETYPE_NONE); CreateTimer(1.0,UnfreezePlayer,userid); } } } } } } // Misc stuff public Action:UnfreezePlayer(Handle:timer,any:userid) { new client=GetClientOfUserId(userid); if(client>0) { War3_ChatMessage(client,"You are free'd from the bashing!"); SetEntityMoveType(client,MOVETYPE_WALK); } } // Teleport Stuff // By: stinkyfax // Much thanks, this would be a nightmare without him. new ClientTracer; bool:TeleportPlayerView(client,Float:distance,Float:end[3]) { if(client>0) { if(IsPlayerAlive(client)) { new Float:angle[3]; GetClientEyeAngles(client,angle); new Float:endpos[3]; new Float:startpos[3]; GetClientEyePosition(client,startpos); new Float:dir[3]; GetAngleVectors(angle, dir, NULL_VECTOR, NULL_VECTOR); ScaleVector(dir, distance); AddVectors(startpos, dir, endpos); ClientTracer=client; TR_TraceRayFilter(startpos,endpos,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter); TR_GetEndPosition(endpos); distance=(GetVectorDistance(startpos,endpos)-55.0); endpos[1]=(startpos[1]+(distance*Sine(DegToRad(angle[1])))); endpos[0]=(startpos[0]+(distance*Cosine(DegToRad(angle[1])))); if(!CheckPlayerBox(endpos,startpos,client)) return false; TeleportEntity(client,endpos,NULL_VECTOR,NULL_VECTOR); end=endpos; return true; } } return false; } public bool:AimTargetFilter(entity,mask) { return !(entity==ClientTracer); } bool:CheckPlayerBox(Float:bottom[3],Float:start[3],client) { new Float:edge[3][8]; //point A edge[2][0]=bottom[2]; edge[0][0]=bottom[0]+12.5; edge[1][0]=bottom[1]+12.5; //point B edge[2][1]=edge[2][0]; edge[0][1]=edge[0][0]+25.0; edge[1][1]=edge[1][0]; //point C edge[2][2]=edge[2][1]; edge[0][2]=edge[0][1]; edge[1][2]=edge[1][1]+25.0; //point D edge[2][3]=edge[2][2]; edge[0][3]=edge[0][2]-25.0; edge[1][3]=edge[1][2]; //other buttons for(new i=0;i<4;i++) { for(new x=0;x<2;x++) { edge[x][i+4]=edge[x][i]; } edge[2][i+4]=edge[2][i]+67.0; } for(new i=0;i<4;i++) { decl Float:point[3]; point[0]=edge[0][i]; point[1]=edge[1][i]; point[2]=edge[2][i]; decl Float:endpoint[3]; endpoint[0]=edge[0][i+4]; endpoint[1]=edge[1][i+4]; endpoint[2]=edge[2][i+4]; TR_TraceRayFilter(point,endpoint,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter); if(TR_DidHit()) { return false; } } for(new i=0;i<7;i++) { decl Float:point[3]; point[0]=edge[0][i]; point[1]=edge[1][i]; point[2]=edge[2][i]; decl Float:endpoint[3]; endpoint[0]=edge[0][i+1]; endpoint[1]=edge[1][i+1]; endpoint[2]=edge[2][i+1]; TR_TraceRayFilter(point,endpoint,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter); if(TR_DidHit()) { return false; } } new Float:top[3]; top=bottom; top[2]+=90; ClientTracer=client; TR_TraceRayFilter(top,bottom,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter); new bool:temp; temp=TR_DidHit(); if(temp) { return false; } ClientTracer=client; TR_TraceRayFilter(start,top,MASK_PLAYERSOLID,RayType_EndPoint,AimTargetFilter); temp=TR_DidHit(); if(temp) { return false; } return true; } Big thanks to stinkyfax for Teleport math! Cheers Title: Re: Human Alliance Post by: Martin Texno on December 02, 2009, 12:33:28 AM We can always learn something new about new races, Great race !
|