Raised This Month: $32 Target: $400
 8% 

Generic Bomb Plant


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 04-27-2010 , 00:02   Generic Bomb Plant
Reply With Quote #1

Hallo.

So, I've gone around and asked multiple people if they've ever seen a method of doing this, and some of the most experienced people I know have said no. So, on to the question;

As the title says, I'm looking to generically plant a bomb. By this, I mean setting a planted bomb in the site, but not forcing a user to actually do it himself, rather force a bomb plant event. At the round start, I've been trying to work on some things with getting the bomb planted right away, but the ways I've come up with are fairly impractical and wouldn't be very user-friendly.

What I currently have, is editing the spawns to create one terrorist spawn directly inside the bomb site, transfer the bomb to that player, set pev_buttons | IN_ATTACK, and then transfer the player back to the spawn right after he planted the bomb. This, however, as I said earlier, would be fairly irritating and not user-friendly.

All suggestions are welcome. Be it efficient or not, I'd simply like a way to force the bomb to be planted. Thanks in advance.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-27-2010 , 04:42   Re: Generic Bomb Plant
Reply With Quote #2

Look at PrimaryAttack there : http://cs-sdk.googlecode.com/svn/trunk/wpn_c4.cpp
I guess that you have to force Ham_Weapon_PrimaryAttack on some weapon_c4, set it's m_pPlayer and all other needed offsets sur as m_bStartedArming on true, players flags onground, player mapzone on bombsite, set player origin (temporarily as all other vars) where you want the bomb to be planted, etc..., just read the code.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
Old 04-27-2010, 04:43
Arkshine
This message has been deleted by Arkshine. Reason: nvm
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2010 , 04:46   Re: Generic Bomb Plant
Reply With Quote #3

He doesn't need to execute all the code, if he wants somehow to fake such event without player, there is just to call ShootSatchelCharge(), some events, setting some offsets, that's all. With Orpheu it's easy to do it.
__________________
Arkshine is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 04-27-2010 , 05:30   Re: Generic Bomb Plant
Reply With Quote #4

I don't use orpheu, so my answer wasn't taking it in account.
Anyway, i failed so far, i think you missed something in the decompiled code.

This should be close to what you have to do.

PHP Code:
#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

#define VERSION "0.0.1"

// #define MAX_PLAYERS 32

// new g_iMaxPlayers
// #define IsPlayer(%1)    ( 1 <= %1 <= g_iMaxPlayers )

/*
Offsets
weapon_grenade

    96  - m_bIsC4
    97  - m_bStartDefuse ?
    98  - ?
    99  - m_flDefuseCountDown
    100 - m_flC4Blow
    101 - m_flNextFreqInterval
    102 - m_flNextBeep
    103 - m_flNextFreq
    104 - m_sBeepName
    105 - m_fAttenu
    106 - m_flNextBlink
    107 - ?
    108 - m_bJustBlew
    111 - m_pentCurBombTarget
    112 - m_SGSmoke
    114 - m_bLightSmoke
    115 - m_usEvent ?

    +5
    
weapon_c4 :

    78 : m_bStartedArming
    79 : m_bBombPlacedAnimation
    80 : m_fArmedTime
*/

#define XTRA_OFS_WEAPONS            4
#define m_pPlayer                41
#define m_flNextPrimaryAttack        46
#define m_bStartedArming            78
#define m_bBombPlacedAnimation    79
#define m_fArmedTime            80

#define XTRA_OFS_PLAYERS            5
#define m_iMapZone                235
#define m_rgAmmo_c4                390

const IN_BOMB_ZONE = (1<<1)

public 
plugin_init()
{
    
register_plugin("Plant Bomb"VERSION"ConnorMcLeod")

    
register_clcmd("say /plant""Plant_A_Bomb")
}

public 
Plant_A_Bombid )
{
    new 
Float:vecOrigin[3]
    
pev(idpev_originvecOrigin)
    
BombPlant(idvecOrigin)

    return 
PLUGIN_HANDLED
}

BombPlant(idFloat:vecOrigin[3])
{
    static 
iszWeaponC4
    
if( !iszWeaponC4 )
    {
        
iszWeaponC4 engfunc(EngFunc_AllocString"weapon_c4")
    }
    new 
iC4 engfunc(EngFunc_CreateNamedEntityiszWeaponC4)

    
ExecuteHam(Ham_SpawniC4)

    
set_pdata_int(idm_rgAmmo_c41XTRA_OFS_PLAYERS)
    new 
iRealFlags pev(idpev_flags)
    
set_pev(idpev_flagsiRealFlags FL_ONGROUND)
    new 
iRealMapZone get_pdata_int(idm_iMapZoneXTRA_OFS_PLAYERS)
    
set_pdata_int(idm_iMapZoneiRealMapZone IN_BOMB_ZONEXTRA_OFS_PLAYERS)
    new 
Float:vecRealOrigin[3]
    
pev(idpev_originvecRealOrigin)
    
set_pev(idpev_originvecOrigin)

    
set_pdata_cbase(iC4m_pPlayeridXTRA_OFS_WEAPONS)
    
set_pdata_int(iC4m_bStartedArmingtrueXTRA_OFS_WEAPONS)

    
set_pdata_float(iC4m_fArmedTimeget_gametime() - 0.01XTRA_OFS_WEAPONS)
//    set_pdata_int(iC4, m_bBombPlacedAnimation, true, XTRA_OFS_WEAPONS)
//    set_pdata_float(iC4, m_flNextPrimaryAttack, -1.0, XTRA_OFS_WEAPONS)

    
ExecuteHam(Ham_Weapon_PrimaryAttackiC4)

    
set_pev(idpev_flagsiRealFlags)
    
set_pdata_int(idm_iMapZoneiRealMapZoneXTRA_OFS_PLAYERS)
    
set_pev(idpev_originvecRealOrigin)

__________________
- tired and retired -

- my plugins -
ConnorMcLeod is offline
wrecked_
Veteran Member
Join Date: Jan 2010
Location: New York (GMT-5)
Old 04-27-2010 , 06:55   Re: Generic Bomb Plant
Reply With Quote #5

Thanks for the help, guys! Arkshine, I'll be PMing you when I get home about that Orpheu thing. Connor, I'll be sure to use your method and let you know if I find anything that could be causing it to not work.
__________________
[ Paid Requests ]
DO NOT PM ME ABOUT BLOCKMAKER
NO PRIVATE SUPPORT
wrecked_ is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2010 , 07:16   Re: Generic Bomb Plant
Reply With Quote #6

All you need is to execute ShootSatchelCharge(). You can plant as many bomb you want, where you want, whatever the team and can be defused without problem.
Here an example :

Code:
    #include <amxmodx>     #include <orpheu>     #include <fakemeta>         public plugin_init ()     {         register_clcmd( "say /plant", "ClientCommand_PlantABomb" );     }         public ClientCommand_PlantABomb ( const player )     {         new Float:origin[ 3 ];         pev( player, pev_origin, origin );         // the first param should be the weapon_c4 entity, but it's not used so we put a random entity (not null) it doesn't matter.         new bomb = ShootSatchelCharge( player, player, origin );                 // fix, because for some reason it fails to set properly the origin in the function. :/         engfunc( EngFunc_SetOrigin, bomb, origin );     }         stock ShootSatchelCharge ( const c4, const owner, const Float:startOrigin[], const Float:angles[] = { 0.0, 0.0, 0.0 } )     {         static OrpheuFunction:handleFuncShootSatchelCharge;         if ( !handleFuncShootSatchelCharge )         {             handleFuncShootSatchelCharge = OrpheuGetFunction( "ShootSatchelCharge", "CGrenade" );         }                 return OrpheuCall( handleFuncShootSatchelCharge, c4, owner, startOrigin, angles );     }

After, you may want to add another thing like hiding the timer and showing the bomb on the terrorist team :

Code:
        static msgBombDrop;                 if ( msgBombDrop ||( msgBombDrop = get_user_msgid ( "BombDrop" ) ) )         {                #define write_coord_f(%0)  ( engfunc( EngFunc_WriteCoord, %0 ) )                         message_begin( MSG_ALL, msgBombDrop );             write_coord_f( origin[ 0 ] );             write_coord_f( origin[ 1 ] );             write_coord_f( origin[ 2 ] );             write_byte( 1 );             message_end();         }

Or telling director message something important has happened :

Code:
        message_begin( MSG_SPEC, SVC_DIRECTOR );         write_byte( 9 );            write_byte( DRC_CMD_EVENT );         write_short( player );         write_short( 0 );         write_long( 11 | DRC_FLAG_FACEPLAYER );          message_end();

Adding the default cs message :

Code:
client_print( 0, print_center, "#Cstrike_TitlesTXT_Bomb_Planted" );

etc.

Here the sig for CGrenade::ShootSatchelCharge() ; create a file named ShootSatchelCharge in fucntions/CGrenade/ with :
Code:
{
    "name"        : "ShootSatchelCharge",
    "class"       : "CGrenade",
    "library"     : "mod",
    "arguments"   :
    [
        {
            "type" : "entvars_s *"
        },
        {
            "type" : "Vector"
        },
        {
            "type" : "Vector"
        }
    ],
    "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"
        }
    ]
}
__________________

Last edited by Arkshine; 04-27-2010 at 07:27.
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-27-2010 , 08:17   Re: Generic Bomb Plant
Reply With Quote #7

wow, why so hard ways
i have tried it once before (wanted to make force round end, failed at defuse part)

Code:
//  "detonatedelay"      Delay before bomb explode (Putting 'detonatedelay' to 0 would force it to mp_c4timer value.) //  "detonatetarget"  Triggered when bomb is detonated. //  "defusetarget"        Triggered when bomb is defused. PlantABomb( ) {     new iEntity = create_entity( "weapon_c4" );         if( !iEntity )         return;         DispatchKeyValue( iEntity, "detonatedelay", "15" );     DispatchSpawn( iEntity );         force_use( iEntity, iEntity ); // This plants it }
__________________
xPaw is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 04-27-2010 , 09:12   Re: Generic Bomb Plant
Reply With Quote #8

Hard way ? You have just to call one function. It's a more direct way without having to execute unnecessary code. All is depending what wrecked_ needs exactly anyway.
__________________
Arkshine is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 04-27-2010 , 09:40   Re: Generic Bomb Plant
Reply With Quote #9

Quote:
Originally Posted by Arkshine View Post
Hard way ? You have just to call one function. It's a more direct way without having to execute unnecessary code. All is depending what wrecked_ needs exactly anyway.
Meant connor's way, haven't payed attention on yours
__________________
xPaw is offline
Old 11-09-2017, 14:10
suhdude
This message has been deleted by suhdude.
GoldNux
Senior Member
Join Date: Mar 2018
Old 11-24-2022 , 00:29   Re: Generic Bomb Plant
Reply With Quote #10

Quote:
Originally Posted by Arkshine View Post
All you need is to execute ShootSatchelCharge(). You can plant as many bomb you want, where you want, whatever the team and can be defused without problem.
Here an example:
I run a 1.6 server with steamcmd on a debian vm.
After installing orpheu and adding it to modules.ini I created a directory called "CGrenade" in functions like you said. Then I created a file without any file ending in mobaxterm and added the signature.
I made sure that the names are correct and no spaces are in them.

But I still get this:
[ORPHEU] Function "CGrenade::ShootSatchelCharge" not found

I'm not sure what I'm doing wrong here, have any idea?
__________________
Try my version of de_dust2, I think it's great and you should check it out!
https://gamebanana.com/mods/83731
GoldNux is offline
Reply


Thread Tools
Display Modes

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 08:42.


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