Raised This Month: $ Target: $400
 0% 

C++ metamod dll into amxx plugin?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 10:32   C++ metamod dll into amxx plugin?
Reply With Quote #1

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)
__________________
+|- KARMA Respectively

HLM is offline
stupok
Veteran Member
Join Date: Feb 2006
Old 06-26-2009 , 11:50   Re: C++ metamod dll into amxx plugin?
Reply With Quote #2

Yes, you can rewrite code from C++ to Pawn. There is no "converter", it must be done manually.
__________________
stupok is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 12:46   Re: C++ metamod dll into amxx plugin?
Reply With Quote #3

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 ;-)
__________________
+|- KARMA Respectively


Last edited by HLM; 06-26-2009 at 13:01.
HLM is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 13:50   Re: C++ metamod dll into amxx plugin?
Reply With Quote #4

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]
__________________

Last edited by Arkshine; 06-26-2009 at 15:26.
Arkshine is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 14:02   Re: C++ metamod dll into amxx plugin?
Reply With Quote #5

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;
}
__________________
+|- KARMA Respectively

HLM is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 14:16   Re: C++ metamod dll into amxx plugin?
Reply With Quote #6

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.
__________________

Last edited by Arkshine; 06-26-2009 at 14:22.
Arkshine is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 14:30   Re: C++ metamod dll into amxx plugin?
Reply With Quote #7

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)
__________________
+|- KARMA Respectively

HLM is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 15:16   Re: C++ metamod dll into amxx plugin?
Reply With Quote #8

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...
__________________
Arkshine is offline
HLM
Senior Member
Join Date: Apr 2008
Location: C:\WINDOWS\System32
Old 06-26-2009 , 15:21   Re: C++ metamod dll into amxx plugin?
Reply With Quote #9

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
__________________
+|- KARMA Respectively

HLM is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 06-26-2009 , 15:24   Re: C++ metamod dll into amxx plugin?
Reply With Quote #10

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;     }
__________________

Last edited by Arkshine; 06-26-2009 at 15:27.
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 15:42.


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