AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   C++ metamod dll into amxx plugin? (https://forums.alliedmods.net/showthread.php?t=95708)

HLM 06-26-2009 10:32

C++ metamod dll into amxx plugin?
 
I have the source of a metamod dll with alot of neat features, is there a way to convert that code to use one specific thing as a amxx plugin?

(the plugin is tfc tech, the technology is sticky pipebombs)

stupok 06-26-2009 11:50

Re: C++ metamod dll into amxx plugin?
 
Yes, you can rewrite code from C++ to Pawn. There is no "converter", it must be done manually.

HLM 06-26-2009 12:46

Re: C++ metamod dll into amxx plugin?
 
If I just leave a few snippets from tfc tech (C++), can someone port some features to pawn?

PHP Code:

bool CTech::pfnTouch(edict_t *pentTouchededict_t *pentOther)
{
    
// sticky pipes
    
if((pentTouched->v.movetype != MOVETYPE_NONE) && pentTouched->v.classname && !strcmp(STRING(pentTouched->v.classname), "tf_gl_pipebomb") && pentTouched->v.owner && PlayerHasTech(TECH_STICKY_PIPESpentTouched->v.owner))
    {
        if(
pentOther->v.classname && (!strcmp(STRING(pentOther->v.classname), "worldspawn") || !strcmp(STRING(pentOther->v.classname), "func_wall")))
        {
            
pentTouched->v.movetype MOVETYPE_NONE;
            
pentTouched->v.origin pentTouched->v.origin - (pentTouched->v.velocity.Normalize() * 4); // move out
            
pentTouched->v.velocity Vector(000);
            
pentTouched->v.avelocity Vector(000);
            
UTIL_Sparks(pentTouched->v.origin);

        }
        
// stick to players
        
if(pentOther->v.classname && !strcmp(STRING(pentOther->v.classname), "player") && pentOther->v.deadflag == DEAD_NO)
        {
            
pentTouched->v.movetype MOVETYPE_FOLLOW;
            
pentTouched->v.aiment pentOther;
            
pentTouched->v.velocity Vector(000);
            
pentTouched->v.avelocity Vector(000);
            
UTIL_Sparks(pentTouched->v.origin);
            
//pentTouched->v.owner = pentOther;
        
}
    } 

sticky pipebombs.. I THINK this is everything you need for that.. if you need the FULL sourcefile, just say so, I would greatly appreciate someone to drop by and look at this please ;-)

Arkshine 06-26-2009 13:50

Re: C++ metamod dll into amxx plugin?
 
A full and not tested example would be something like :
Though I don't know about PlayerHasTech(). There is probably one native for that.

[Edit : see #10]

HLM 06-26-2009 14:02

Re: C++ metamod dll into amxx plugin?
 
PHP Code:

bool CTech::PlayerHasTech(int index1int index2edict_t *pPlayer

that?

Code:

bool CTech::PlayerHasTech(int index1, int index2, edict_t *pPlayer)
{
        bool bRet;
        if(pPlayer && !pPlayer->free && (ENTINDEX(pPlayer) > 0 && ENTINDEX(pPlayer) <= gpGlobals->maxClients) && (pPlayer->v.team > 0) && (pPlayer->v.team <= MAX_TEAMS))
        {
                bRet = bGotTech[index1][index2][pPlayer->v.team-1];
        }
        else
        {
                bRet = false;
        }

        return bRet;
}


Arkshine 06-26-2009 14:16

Re: C++ metamod dll into amxx plugin?
 
I don't know much about TFC, but a pipebomb is a weapon already existing in TFC ? If so and If I understand by default you throw it on the ground but with this code, it can be stickied on the wall or a player, right ? I have to search a native to check if you use this weapon so.

HLM 06-26-2009 14:30

Re: C++ metamod dll into amxx plugin?
 
yes, the pipebomb is an ammo, from the piplauncher (cant remember the name) only [under normal circumstances] available to the class TFC_PC_DEMOMAN normally the pipebomb would continue moving around until it finally settled, with this mod it would stick to whatever it lands on (player or wall)

Arkshine 06-26-2009 15:16

Re: C++ metamod dll into amxx plugin?
 
Ok I tried my code ( not update here yet ) It works for the player part, now it doesn't work with worldspawn/wall. I'm checking...

HLM 06-26-2009 15:21

Re: C++ metamod dll into amxx plugin?
 
ahh, your amazing arkshine :) you should TOTALLY submit this as a new plugin, I KNOW im not the only person who could use this as a standalone plugin :)
your a hero arkshine

Arkshine 06-26-2009 15:24

Re: C++ metamod dll into amxx plugin?
 
Here. Tested and it works as expected :

Code:
    #include <amxmodx>     #include <engine>     #include <fakemeta>     #include <hamsandwich>         const MAX_CLIENTS = 32;     new bool:gHasPipeLauncher[ MAX_CLIENTS + 1 char ];         enum _:Coord_e { Float:x, Float:y, Float:z };         #define VectorMS(%1,%2,%3,%4)     ( %4[ x ] = %1[ x ] - %2 * %3[ x ], %4[ y ] = %1[ y ] - %2 * %3[ y ], %4[ z ] = %1[ z ] - %2 * %3[ z ] )     #define VectorLength(%1)          ( floatsqroot ( %1[ x ] * %1[ x ] + %1[ y ] * %1[ y ] + %1[ z ] * %1[ z ] ) )         #define message_begin_f(%1,%2,%3) ( engfunc ( EngFunc_MessageBegin, %1, %2, %3 ) )     #define write_coord_f(%1)         ( engfunc ( EngFunc_WriteCoord, %1 ) )         #define PlayerHasTech(%1)         ( is_user_alive( %1 ) && gHasPipeLauncher{ %1 } )         public plugin_init ()     {         register_plugin( "Sticky PipeBombs", "1.0.0", "Arkshine" );             register_touch( "tf_gl_pipebomb", "worldspawn", "CTech_TouchWorld" );         register_touch( "tf_gl_pipebomb", "func_wall",  "CTech_TouchWorld" );         register_touch( "tf_gl_pipebomb", "player"   ,  "CTech_TouchPlayer" );                 RegisterHam( Ham_Item_Deploy , "tf_weapon_pl", "CTech_DeployWeapon", 1 );         RegisterHam( Ham_Item_Holster, "tf_weapon_pl", "CTech_HolsterWeapon", 1 );     }     public client_disconnect( Player )     {         gHasPipeLauncher{ Player } = false;     }         public CTech_TouchWorld ( const PipeBomb, const Other )     {         if ( pev_valid( PipeBomb ) && pev( PipeBomb, pev_movetype ) != MOVETYPE_NONE && PlayerHasTech( pev( PipeBomb, pev_owner ) ) )         {             static Float:Velocity[ Coord_e ];             static Float:Origin  [ Coord_e ];                         pev( PipeBomb, pev_origin, Origin );             pev( PipeBomb, pev_velocity, Velocity );                         VectorNormalize( Velocity );             VectorMS( Origin, 4.0, Velocity, Origin );                     set_pev( PipeBomb, pev_movetype, MOVETYPE_NONE );             set_pev( PipeBomb, pev_origin, Origin );             set_pev( PipeBomb, pev_velocity , Float:{ 0.0, 0.0, 0.0 } );             set_pev( PipeBomb, pev_avelocity, Float:{ 0.0, 0.0, 0.0 } );                         FX_Sparks( Origin );         }     }         public CTech_TouchPlayer ( const PipeBomb, const Other )     {         if ( pev_valid( PipeBomb ) && is_user_alive( Other ) )         {             static Float:Origin[ Coord_e ];             pev( PipeBomb, pev_origin, Origin );                         set_pev( PipeBomb, pev_movetype, MOVETYPE_FOLLOW );             set_pev( PipeBomb, pev_aiment, Other );             set_pev( PipeBomb, pev_origin, Origin );             set_pev( PipeBomb, pev_velocity , Float:{ 0.0, 0.0, 0.0 } );             set_pev( PipeBomb, pev_avelocity, Float:{ 0.0, 0.0, 0.0 } );                         FX_Sparks( Origin );         }     }         public CTech_DeployWeapon ( const PipeLauncher )     {         gHasPipeLauncher{ pev( PipeLauncher, pev_owner ) } = true;     }         public CTech_HolsterWeapon ( const PipeLauncher )     {         gHasPipeLauncher{ pev( PipeLauncher, pev_owner ) } = false;     }         FX_Sparks ( const Float:Origin[ Coord_e ] )     {         message_begin_f( MSG_PVS, SVC_TEMPENTITY, Origin, 0 );         write_byte( TE_SPARKS );         write_coord_f( Origin[ x ] );         write_coord_f( Origin[ y ] );         write_coord_f( Origin[ z ] );         message_end ();     }         VectorNormalize ( Float:Source[ Coord_e ] )     {         new Float:Invlen = 1.0 / VectorLength( Source );         Source[ x ] *= Invlen         Source[ y ] *= Invlen;         Source[ z ] *= Invlen;     }


All times are GMT -4. The time now is 15:42.

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