Raised This Month: $51 Target: $400
 12% 

Throwable C4 [ V 0.6 ]


Post New Thread Reply   
 
Thread Tools Display Modes
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-04-2014 , 06:24   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #21

"your plugin is basically it auto-activates once you drop c4, with some velocity, right?"

Nope, you are not actually dropping it. It's going to be auto activated when you press IN_ATTACK2 button and NOT when you drop it.
About bomb plant, I understood what I have to do, but for throwing I don't see how to set velocity on the real bomb since you don't drop it, the c4 entity is still attached to player. Also, it's hard to understand in english and to express what I want to say.

I will try to explain better how this works.
1. You presss IN_ATTACK2 button.
2. A fake entity is created, that is the entity which will be throwed.
3. If it doesn't fall in a bombsite, another entity is created which will represent the dropped bomb.
4. If it fall in a bombsite, it will cal ShootSatchelCharge to plant the bomb.

Are you telling me that I should alter the velocity when the a player drop the c4 ?
__________________
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-04-2014 , 07:19   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #22

Originally, when you plant a bomb, once bar time has ended, it calls ShootSatchelCharge() with current player's origin and null velocity, as arguments.

When you hit IN_ATTACk2, instead of creating fake entity, you can just bypass game check and call PrimaryAttack directly, then ShootSatchelCharge will be called (reminder: this function creates the "grenade" entity, the actual bomb), and you should alter velocity on-the-fly when this function is called (third argument). It should do essentially the same, in way way better (since all is handled by game).

About whether bomb is inside bombsite, you have also an easy and lazy way: a player must be already inside a bombsite (there is an offset for that, very easy to detect). But it's ok to calculate like you already do, though you will need to predict next origin instead of hooking touch though (TraceToss ?).

Do you follow me? \o/
__________________

Last edited by Arkshine; 10-04-2014 at 10:29.
Arkshine is offline
GuskiS
Veteran Member
Join Date: Aug 2007
Location: Latvia
Old 10-04-2014 , 16:59   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #23

Why not just check if player who is holding C4 preses SecondaryAttack on C4, add some sort of variable, then force player to drop it normaly, when it lands - check if owner had pressed SecondaryAttack. Is this a bad way?
__________________
Finished mods:
Trouble in Terrorist Town
MurderMod
The Hidden
Cowboys vs Indians
JailBreak Supreme
Survival Madness
GuskiS is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-04-2014 , 17:34   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #24

Not sure to understand what you're proposing.

Don't forget that wthat you're holding is a "weapon_c4", and when you plant the bomb, a new "grenade" entity is created. Dropping would create a "weaponbox" entity. When +attack2 is triggered, you need to make thing like you were going to plant. Just a matter to call PrimaryAttack and bypassing game check.
__________________
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-05-2014 , 04:28   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #25

Arkshine, this time I get it and I'm almost done. I will upload the new version tomorrow.

Edit: Bad news, orpheu is crashing the server when hooking shootsatchelcharge, even when only printing a simple debug message.

Code:
_CGrenade_ShootSatchelCharge = OrpheuGetFunction( "ShootSatchelCharge", "CGrenade" ) OrpheuRegisterHook( _CGrenade_ShootSatchelCharge, "OnShootSatchelCharge", OrpheuHookPre )//if we are only getting the function, nothing is wrong, but when hooking it it's a nightmare

Code:
public  OnShootSatchelCharge( iEnt, iOwner, Float: x, Float: y, Float: z, Float: vx, Float: vy, Float: vz ) {     server_print( "test" )  }

I made vector class like float float float....

Signature:
Code:
{     "name"        : "ShootSatchelCharge",     "class"       : "CGrenade",     "library"     : "mod",     "arguments"   :     [         {             "type" : "entvars_s *"         },         {             "type" : "float"         },            {             "type" : "float"         },            {             "type" : "float"         },            {             "type" : "float"         },            {             "type" : "float"         },         {             "type" : "float"         }     ],     "return" :     {         "type" : "CGrenade *"     },     "identifiers" :     [         {             "os"    : "windows",             "mod"   : "cstrike",             "value" : [0x83,0xEC,0x18,0x53,0x56,0x57,0xFF,"*","*","*","*","*",0x33,0xDB,0x3B,0xC3,0x75,0x04,0x33,0xFF,0xEB,0x06,0x8D,"*","*","*","*","*",0x8B]         },                 {             "os"    : "linux",             "mod"   : "cstrike",             "value" : "ShootSatchelCharge__8CGrenadeP9entvars_sG6VectorT2"         }     ] }

With primaryattack everything is fine, I can simulate bomb planting, but when I try to alter velocity in CGrenade::ShootSatchelCharge it crash the server. I also tried to hook it as pre and use OrpheuSetParam, same result- > crash.
__________________

Last edited by HamletEagle; 10-05-2014 at 06:19.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-05-2014 , 08:22   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #26

Well it's not that surprising Vector doesn't work well when hooking. Orpheu really don't support this.
Do you think you could try with Okapi? It's similar to Orpheu, but it might work better with float float float. (You can use signature/symbol with okapi, you don't have to use treemap, just saying)

Can you send me your current plugin (with all config) ? I want to test something.
__________________

Last edited by Arkshine; 10-05-2014 at 08:29.
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-05-2014 , 12:02   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #27

I tried with okapi, and it seems that I can't do it, okapi it's too confusing. Check you pm's, I send you the plugin+configs.
__________________
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-05-2014 , 14:16   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #28

You can with Okapi, like :

PHP Code:
new const signature[] = {0x83,0xEC,0x18,0x53,0x56,0x57,0xFF,0xDFF,0xDFF,0xDFF,0xDFF,0xDFF,0x33,0xDB,0x3B,0xC3,0x75,0x04,0x33,0xFF,0xEB,0x06,0x8D,0xDFF,0xDFF,0xDFF,0xDFF,0xDFF,0x8B};
new 
address okapi_mod_find_sig(signaturesizeof signature);
okapi_add_hook(okapi_build_function(addressarg_cbasearg_entvarsarg_vecarg_vec), "OnShootSatchelCharge"); 
__________________

Last edited by Arkshine; 10-05-2014 at 14:16.
Arkshine is offline
HamletEagle
AMX Mod X Plugin Approver
Join Date: Sep 2013
Location: Romania
Old 10-06-2014 , 11:42   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #29

Hope that's last question:

Bomb throwing is working perfectly, also I can detect where it lands with touch and as an aditional check by adding a custom value to pev_iuser3.

But c4_plant.wav sound is played even if the bomb is not in a bombsite, I tried to block it with FM_EmitSound. It's strange that the sound is played through this event but it can't be blocked. Do you have any suggestion for this ?

Also, I want to set avelocity on the c4, it's fine, but when it lands, it will be somehow in the ground. I'm thinking to remove the throwed grenade entity on touch and call again CGrenade::ShootSatchelCharge with okapi, so the bomb will be fine on the ground. Do you think it's ok ?
__________________

Last edited by HamletEagle; 10-06-2014 at 11:42.
HamletEagle is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-06-2014 , 17:33   Re: Throwable C4 [ V 0.3 ]
Reply With Quote #30

I was actually thinking too how to deal properly "if bomb is not inside bomb site".
You have probably several ways depending how you want to deal that.
What you're trying to do is wrong because you don't try to deal with game code.

First, what I can say for sure:
  • We can't do stuffs after bomb is going to be planted. Because several stuffs, included bomb creation, have been executed at this point (message, log, offset, and such). You can't just block that.
  • We don't want to create manually a weaponbox in case bomb is not inside a bomb site. Game can do that alone and it's better to let game handles that, just a matter to find the right time to throw an drop weapon_c4.
  • This is kind of awkward to not know when you can actually throw the bomb. Praying that bomb will go inside zone doesn't seem a good idea. This would be probably annoying to throw/grab until it's inside.

From that, I guess you will need to somewhat predict where the bomb will go.
But actually not (\o/), because in the middle in writing some ideas and a lot of thoughts, I figured out it's just pointless to predict. Let me explain why.
  • You would have the solution with TraceToss ; but this native requires an entity, so we can't because we need to know before it's thrown. (You could probably try to do that in pawn, but kind of overkill).
  • You could try to check distance between bomb site origin and player. For example, you know that with info_bomb_target, game will searh player around 250 units, so you could do probably the same and adding some arbritary average extra distance (since you can throw the bomb with velocity and you don't need to be precise). But you still don't know when you can throw, and this could lead to some exploit depending the extra distance you want to add. This doesn't feel right.
  • Probably more solution like you throw a dummy entity, if in bomb site, you delete it and call OnShootSatchelCharge. But it doesn't make sense this way because you redo what does already the game and you need to handle that manually. For compatibility reason and because you won't do exactly like the game, it sucks.

I think he best would be to let the game handles that. Meaning, player has to be inside the bomb site::
  • You know you can either plant or throw because icon is blinking or you have a message from game you have to be on a bomb site. Intuitive.
  • And since you can throw with velocity, this still allows you throw a bit farther out of the bomb zone (of course you should set a reasonable base velocity). New place but not so far.
  • This has the advantage you check easily if you are or not in bomb zone, then you could force a drop if you wanted (one command, no need custom code to handle touch, clean up and such).
  • This simplifies code a lot and you avoid a lot of hassle and unforeseen situation, you keep a better compatibility with others plugins.

I believe it's more fair this way, makes more sense (gameplay speaking, player has to go on bomb site first, keep a minimal proximity and limit any exploit attempt, still give room to plant bomb).
Most likely the best compromise between gameplay/code. Any thought?
__________________

Last edited by Arkshine; 10-07-2014 at 09:20.
Arkshine is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:46.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode