[CSGO] Curving Flash

Release your plugins here!
User avatar
VinciT
Senior Member
Posts: 173
Joined: Thu Dec 18, 2014 2:41 am

[CSGO] Curving Flash

Postby VinciT » Tue Jun 16, 2020 6:28 am

Image
Tired of bouncing flashbangs off walls to get that perfect pop flash? Say no more! With Curving Flash, you'll have the ability to execute the perfect pop flash every time. While holding a flashbang, press the weapon inspect key (F by default) to switch the throwing mode.
Image

Image ImageImage

How to install:

  1. Install Source.Python.
  2. Download the latest release of Curving Flash from the bottom of this post or GitHub.
  3. Extract the files into your game server's root folder (../csgo/).
  4. Add sp plugin load curving_flash to your autoexec file (../csgo/cfg/autoexec.cfg).
  5. Restart your server.
Image

You can see the flashbangs in action in this short video:


Image
Latest release
curving_flash_v1.0.zip
(7.44 KiB) Downloaded 17 times
ImageImageImageImageImage
User avatar
Ayuto
Project Leader
Posts: 2088
Joined: Sat Jul 07, 2012 8:17 am
Location: Germany

Re: [CSGO] Curving Flash

Postby Ayuto » Tue Jun 16, 2020 4:01 pm

Awesome idea and great implementation! I really like the way you program :)
User avatar
VinciT
Senior Member
Posts: 173
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Curving Flash

Postby VinciT » Wed Jun 17, 2020 5:28 am

Thank you Ayuto! That really means a lot to me. :grin:
ImageImageImageImageImage
decompile
Senior Member
Posts: 375
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: [CSGO] Curving Flash

Postby decompile » Wed Jun 17, 2020 8:21 pm

This is awesome. I love the video :D

5 stars, if this was a review
User avatar
VinciT
Senior Member
Posts: 173
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Curving Flash

Postby VinciT » Thu Jun 18, 2020 5:43 am

Thanks! I'm glad you enjoyed the video, it was really fun to make!
ImageImageImageImageImage
User avatar
L'In20Cible
Project Leader
Posts: 1330
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CSGO] Curving Flash

Postby L'In20Cible » Fri Jun 19, 2020 6:23 am

That is indeed a cool idea, well done! :smile:

That said, you know me... here are some points:

  • ../curving_flash.py#L27: That method isn't static, so this should rather be:

    Syntax: Select all

    player.view_angle.get_angle_vectors(None, right, None)


  • ../core/players.py#L54: Since your PlayerCF class makes use of the internal caching, you don't really need that dictionary. It is rather redundant, since the instances are already stored into PlayerCF.cache so you could simply do the following to retrieve cached instances:

    Syntax: Select all

    player = PlayerCF(index)
    player = PlayerCF.from_inthandle(index)


  • ../curving_flash.py#L43: Should not the start be the flash position towards where it is going? Actually, the flash does an S instead of a C as illustrated in the following picture:

    Image

    You can see it first does a curve to reach the player's view vector which looks quite weird to me.

  • ../core/commands.py#L16: Doesn't seem to be used anywhere, so not needed.

  • ../core/commands.py#L23-L26: Slight inaccuracy here, because time() is called twice and might not be the same depending how long what is in-between took to execute. Should rather retrieve it once and assign it to a local variable. Additionally, you should rather do a from time import time, so that the interpreter do not have to dynamically resolve that method from that module every times you call it (avoid unnecessary getattr, etc.).

  • ../core/commands.py#L22: That dictionary is never cleaned up so it will just grow over time to maxplayers which can also cause issues if an index is re-use as it will use the time of the last player, etc. To be honest, this should really be defined into your PlayerCF instances as you retrieve it in there anyways so may as well ditch an extra dictionary.

  • ../core/flashbangs.py#L67: Instead of looking that every think, wouldn't it be better to just externally listen for the bounce event patiently waiting for the engine to let you know? This sure sound more optimized to me.

  • ../core/flashbangs.py#L56: The angle should be None. Setting the same angle is redundant.

  • ../core/flashbangs.py#L73self.base_velocity

  • ../core/listeners.py#L35: Should rather use an entity delay. Otherwise, if a plugin does Entity.create('weapon_flashbang').remove() your callbacks will be working with an invalid index.

  • ../core/listeners.py#L28base_entity.owner_handle

  • ../core/players.py#L10: Why not use translations? I would PR french strings.

  • ../core/players.py#L35-L41: Since you know everything ahead of time except for the indexes, there is absolutely no reason to instantiate that sound for all players. Just globalize it and .play(index) when needed.

  • ../curving_flash.py#L37: I don't thin hard-coding the animation index is a good idea. While this is true for the default model, it can be different for custom ones. You should rather look into the studio package to extract it from its name.

  • ../curving_flash.py#L30: That is certainly a property we could add to the Player/PlayerMixin class (though, as an Entity, rather than BaseEntity). Feel free to make a PR.
User avatar
VinciT
Senior Member
Posts: 173
Joined: Thu Dec 18, 2014 2:41 am

Re: [CSGO] Curving Flash

Postby VinciT » Sat Jun 20, 2020 9:31 am

L'In20Cible wrote:That is indeed a cool idea, well done! :smile:
Thank you!

L'In20Cible wrote:That said, you know me... here are some points:
I would expect nothing less. :grin:

L'In20Cible wrote:../curving_flash.py#L27: That method isn't static, so this should rather be:

Syntax: Select all

player.view_angle.get_angle_vectors(None, right, None)
Oh that's nice.

L'In20Cible wrote:../core/players.py#L54: Since your PlayerCF class makes use of the internal caching, you don't really need that dictionary. It is rather redundant, since the instances are already stored into PlayerCF.cache so you could simply do the following to retrieve cached instances:

Syntax: Select all

player = PlayerCF(index)
player = PlayerCF.from_inthandle(index)
It's like a bad habit. Whenever I start working on a new project, the first thing I do is create dictionaries for players/entities/weapons. I completely forgot about internal caching.

L'In20Cible wrote:../curving_flash.py#L43: Should not the start be the flash position towards where it is going? Actually, the flash does an S instead of a C as illustrated in the following picture:

Image

You can see it first does a curve to reach the player's view vector which looks quite weird to me.
I wouldn't say the trajectory is an S, more like a wider/stretched C. I did this to give the player an easier way to get their pop flash right - by aiming at the corner itself and not away from it. It also gives the flashbang more breathing room when the player is really close or even touching the wall, as can be seen here:



L'In20Cible wrote:[*]../core/commands.py#L16: Doesn't seem to be used anywhere, so not needed.
It is used when the player inspects their weapon, to check if they're holding a flashbang. But now that I've been reminded about internal caching, I guess I could use the Weapon class. Or even better - player.active_weapon.

L'In20Cible wrote:../core/flashbangs.py#L67: Instead of looking that every think, wouldn't it be better to just externally listen for the bounce event patiently waiting for the engine to let you know? This sure sound more optimized to me.
I was trying to avoid using an EntityHook, as the bounce event doesn't provide the index of the projectile. Seeing as _think() will get called a maximum of 5 times per flashbang, I didn't think there would be much of an impact on performance. Although I might hook CFlashbangProjectile::BounceSound() and use that instead.

L'In20Cible wrote:../core/flashbangs.py#L73self.base_velocity
../core/listeners.py#L28base_entity.owner_handle
Another bad habit of mine.

L'In20Cible wrote:../core/listeners.py#L35: Should rather use an entity delay. Otherwise, if a plugin does Entity.create('weapon_flashbang').remove() your callbacks will be working with an invalid index.
I'm checking if the flashbang has an owner before notifying the OnFlashbangCreated listener. If a plugin does the quick create().remove() thing, the flashbang will have an invalid owner inthandle (-1).

L'In20Cible wrote:../core/players.py#L10: Why not use translations? I would PR french strings.
Awesome! I haven't played around with translations yet - guess it's time to do some learning.

L'In20Cible wrote:../curving_flash.py#L37: I don't thin hard-coding the animation index is a good idea. While this is true for the default model, it can be different for custom ones. You should rather look into the studio package to extract it from its name.
Haven't used that package at all, I'll check it out.

L'In20Cible wrote:../curving_flash.py#L30: That is certainly a property we could add to the Player/PlayerMixin class (though, as an Entity, rather than BaseEntity). Feel free to make a PR.
Seeing as I'm beyond rusty with C++, I could add it to the Player class. Although I think it'd be better if someone added it to PlayerMixin instead.

Thank you for the pointers, L'In20Cible. :smile:
ImageImageImageImageImage
User avatar
L'In20Cible
Project Leader
Posts: 1330
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Re: [CSGO] Curving Flash

Postby L'In20Cible » Sat Jun 20, 2020 12:26 pm

VinciT wrote:Seeing as I'm beyond rusty with C++, I could add it to the Player class. Although I think it'd be better if someone added it to PlayerMixin instead.

It would likely be implemented the same as Entity.parent, where EntityMixin.parent_inthandle is implemented on the C++ side and Entity.parent in Python as an Entity instance. So it would be something like Player.view_model that returns an Entity instance from its PlayerMixin.view_model_handle attribute or something like that. I'm sure you can figure that out! :smile: (don't feel pressured tho, no obligation to dig into it if you don't want to :wink:)

Return to “Plugin Releases”

Who is online

Users browsing this forum: No registered users and 2 guests