You are viewing our Forum Archives. To view or take place in current topics click here.
[Release] Mw2 Tu8 ShootFx Code
Posted:

[Release] Mw2 Tu8 ShootFx CodePosted:

Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
I have decided to release shoot fx enjoy.

bullettrace (for people that done already have it)

VOID (__cdecl *AngleVectors)(PFLOAT Angles, PFLOAT Forward, PFLOAT Right, PFLOAT Up) = (VOID (__cdecl *)(PFLOAT, PFLOAT, PFLOAT, PFLOAT))0x8228EDC0;
enum TraceHitType
{
   TRACE_HITTYPE_NONE = 0,
   TRACE_HITTYPE_ENTITY = 1,
   TRACE_HITTYPE_DYNENT_MODEL = 2,
   TRACE_HITTYPE_DYNENT_BRUSH = 3,
};
struct trace_t
{
   FLOAT Fraction;
   FLOAT Normal[3];
   DWORD SurfaceFlags;
   DWORD Contents;
   PCHAR Material;
   TraceHitType HitType;
   UINT16 HitId;
   UINT16 ModelIndex;
   UINT16 PartName;
   UINT16 PartGroup;
   bool AllSolid;
   bool StartSolid;
   bool Walkable;
};
struct BulletTrace
{
   TraceHitType HitType;
   DWORD Entity;
   UINT16 EntityIndex;
   FLOAT Origin[3];
};
VOID AnglesToForward(PFLOAT Angles, PFLOAT ForwardOut)
{
   AngleVectors(Angles, ForwardOut, NULL, NULL);
}
VOID GetBulletTrace(BulletTrace *BT, INT Client, PFLOAT Start, PFLOAT End)
{
   trace_t Trace;
   G_LocationalTrace(&Trace, Start, End, Client, 0x806831, NULL);
   for(INT i = 0; i < 3; i++) { BT->Origin[i] = (((End[i] - Start[i]) * Trace.Fraction) + Start[i]); }
   UINT16 EntityIndex = Trace_GetEntityHitId(&Trace) & 0xFFFF;
   if(EntityIndex < 0x7FE) { BT->EntityIndex = EntityIndex; }

   // Fill BulletTrace struct with some value from the trace_t struct
   BT->HitType = Trace.HitType;
   BT->Entity = gentity((INT)EntityIndex);
}


PlayFx code:

int (*G_TempEntity)(float*origin,int Event) = (int(_cdecl*)(float*,int))0x8220EE88;

int PlayFX(float* origin,int FxID)
{
   int Ent = G_TempEntity(origin,0x53);
   *(int*)(Ent + 0xA0) = FxID;
   *(float*)(Ent + 0x138) = 0;
   *(float*)(Ent + 0x13C) = 0;
   *(float*)(Ent + 0x140) = 270;
   return Ent;
}


ShootFx code:

VOID ShootFX(INT Client)
{
   FLOAT PlayerAngles[3] = { *(FLOAT*)(gentity(Client) + 0x48), *(FLOAT*)(gentity(Client) + 0x4C), *(FLOAT*)(gentity(Client) + 0x50) };
   FLOAT Forward[3]; AnglesToForward(PlayerAngles, Forward);
   FLOAT Start[3]; G_GetPlayerViewOrigin(playerState(Client), Start);
   FLOAT End[3] = { Forward[0] * 100000, Forward[1] * 100000, Forward[2] * 100000 };
   BulletTrace Trace;
   GetBulletTrace(&Trace,Client,Start,End);
   PCHAR MapName = Dvar_GetString("ui_mapname");
   if(strstr(MapName, "mp_afghan")) { PlayFX(Trace.Origin,11); }
   else if(strstr(MapName, "mp_derail")) { PlayFX(Trace.Origin,98); }
   else if(strstr(MapName, "mp_estate")) { PlayFX(Trace.Origin,97); }
   else if(strstr(MapName, "mp_favela")) { PlayFX(Trace.Origin,103); }
   else if(strstr(MapName, "mp_highrise")) { PlayFX(Trace.Origin,10); }
   else if(strstr(MapName, "mp_invasion")) { PlayFX(Trace.Origin,104); }
   else if(strstr(MapName, "mp_checkpoint")) { PlayFX(Trace.Origin,90); }
   else if(strstr(MapName, "mp_quarry")) { PlayFX(Trace.Origin,71); }
   else if(strstr(MapName, "mp_rundown")) { PlayFX(Trace.Origin,99); }
   else if(strstr(MapName, "mp_rust")) { PlayFX(Trace.Origin,62); }
   else if(strstr(MapName, "mp_boneyard")) { PlayFX(Trace.Origin,105); }
   else if(strstr(MapName, "mp_nightshift")) { PlayFX(Trace.Origin,96); }
   else if(strstr(MapName, "mp_subbase")) { PlayFX(Trace.Origin,82); }
   else if(strstr(MapName, "mp_terminal")) { PlayFX(Trace.Origin,9); }
   else if(strstr(MapName, "mp_underpass")) { PlayFX(Trace.Origin,113); }
   else if(strstr(MapName, "mp_brecourt")) { PlayFX(Trace.Origin,61); }
}


Or (Thanks Se7ensinsJtag) :


VOID ShootFX(INT Client)
{
    FLOAT PlayerAngles[3] = { *(FLOAT*)(gentity(Client) + 0x48), *(FLOAT*)(gentity(Client) + 0x4C), *(FLOAT*)(gentity(Client) + 0x50) };
    FLOAT Forward[3]; AnglesToForward(PlayerAngles, Forward);
    FLOAT Start[3]; G_GetPlayerViewOrigin(playerState(Client), Start);
    FLOAT End[3] = { Forward[0] * 100000, Forward[1] * 100000, Forward[2] * 100000 };
    BulletTrace Trace;
    GetBulletTrace(&Trace,Client,Start,End);
    PlayFX(Trace.Origin, G_EffectIndex("props/barrelexp"));
}


call it like:

ShootFX(Client);


Example:
[ Register or Signin to view external links. ]

Credit to james for bullettrace.
Credit to Gol2den for his forge source.


Last edited by Nissan ; edited 4 times in total
#2. Posted:
Taxi
  • Christmas!
Status: Offline
Joined: Oct 17, 201113Year Member
Posts: 2,296
Reputation Power: 198
Status: Offline
Joined: Oct 17, 201113Year Member
Posts: 2,296
Reputation Power: 198
Nice release bro



+ Reppy


Cheers.
#3. Posted:
USTA
  • Christmas!
Status: Offline
Joined: Mar 14, 201410Year Member
Posts: 344
Reputation Power: 22
Status: Offline
Joined: Mar 14, 201410Year Member
Posts: 344
Reputation Power: 22
This was released a while ago, but thanks anyway
#4. Posted:
IDA
  • Powerhouse
Status: Offline
Joined: Sep 21, 201311Year Member
Posts: 454
Reputation Power: 26
Status: Offline
Joined: Sep 21, 201311Year Member
Posts: 454
Reputation Power: 26
Nice one remember you telling me this on Skype like ages ago, nice
#5. Posted:
ISIS
  • Resident Elite
Status: Offline
Joined: Sep 11, 201410Year Member
Posts: 268
Reputation Power: 14
Status: Offline
Joined: Sep 11, 201410Year Member
Posts: 268
Reputation Power: 14
Lol this is a really bad way of doing it just saying.
#6. Posted:
Kicked
  • V5 Launch
Status: Offline
Joined: Jul 10, 201212Year Member
Posts: 154
Reputation Power: 9
Status: Offline
Joined: Jul 10, 201212Year Member
Posts: 154
Reputation Power: 9
Nice release. Thank you for sharing.
#7. Posted:
Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
AnimeHypedUp wrote Lol this is a really bad way of doing it just saying.

it might be a bad way of doing it but its still a way / only way that is released that i could find/
#8. Posted:
ISIS
  • Resident Elite
Status: Offline
Joined: Sep 11, 201410Year Member
Posts: 268
Reputation Power: 14
Status: Offline
Joined: Sep 11, 201410Year Member
Posts: 268
Reputation Power: 14
Orbs wrote
AnimeHypedUp wrote Lol this is a really bad way of doing it just saying.

it might be a bad way of doing it but its still a way / only way that is released that i could find/
Why aren't you using G_EffectIndex for the effects rather than using all those if statements?
#9. Posted:
Nissan
  • Ultra Gifter
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
Status: Offline
Joined: Sep 20, 201212Year Member
Posts: 2,136
Reputation Power: 312
AnimeHypedUp wrote
Orbs wrote
AnimeHypedUp wrote Lol this is a really bad way of doing it just saying.

it might be a bad way of doing it but its still a way / only way that is released that i could find/
Why aren't you using G_EffectIndex for the effects rather than using all those if statements?

i didn't think about using it :/ its on the post now though
#10. Posted:
XeSao
  • New Member
Status: Offline
Joined: Aug 13, 201410Year Member
Posts: 8
Reputation Power: 0
Status: Offline
Joined: Aug 13, 201410Year Member
Posts: 8
Reputation Power: 0
Orbs wrote
AnimeHypedUp wrote
Orbs wrote
AnimeHypedUp wrote Lol this is a really bad way of doing it just saying.

it might be a bad way of doing it but its still a way / only way that is released that i could find/
Why aren't you using G_EffectIndex for the effects rather than using all those if statements?

i didn't think about using it :/ its on the post now though


You should use G_EffectIndex as it is much easier then finding the id's for all of the effects.

I actually wrote a ShootFx function yesterday.

It's pretty short
If you want you can use it.

void shootEffect(int client, char *effect)
{
   playFX(effect, GetCursorPosition(client));
}


then for GetCursorPosition:
float *GetCursorPosition(int client)
{
   BulletTraceType Type;
   bulletTrace(&Type, getTagOrigin(client, "tag_eye"), vector_scale(anglesToForward(getPlayerAngles(client)), 1000000), client, 0);
   return Type.position;
}

Im using my own bulletTrace but you can use yours as both should work

if you dont have vector_scale:
float *vector_scale(float *vec, float scale)
{
   float out[3];
   for(int i = 0;i < 3;i++)
      out[i] = (vec[i] * scale);
   return out;
}


and anglesToForward
void (*AngleVectors)(const float *angles, float *forward, float *right, float *up) =
   (void(*)(const float *, float *, float *, float *))0x8228EDC0;
float *anglesToForward(float *angles)
{
   float forward[3];
   AngleVectors(angles, forward, 0, 0);
   return forward;
}


and if you dont have getPlayerAngles:
float *getPlayerAngles(int client)
{
   return (float *)(playerState(client) + 0x10C);
}


Everything worked when i tested it yesterday
So have fun with it
Jump to:
You are viewing our Forum Archives. To view or take place in current topics click here.