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

DispatchClass


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-08-2019 , 10:35   DispatchClass
Reply With Quote #1

Hello, I wonder if it's possible to "implement" a class on a dummy entity (info_target).

Code:
new szClassName[32], pEdict; copy(szClassName, charsmax(szClassName), "info_target"); pEdict = create_entity(szClassName); if (!pEdict) {     server_print("create_entity: Couldn't create entity ^"%s^"", szClassName); } else {     DispatchClass(pEdict, "CBasePlayerWeapon");     // From there, CBasePlayerWeapon::ItemPostFrame (Ham_Item_PostFrame) for example, would be called in that entity }
__________________









Last edited by CrazY.; 02-08-2019 at 10:36.
CrazY. is offline
E1_531G
Senior Member
Join Date: Dec 2017
Old 02-08-2019 , 12:04   Re: DispatchClass
Reply With Quote #2

I think, internally it remains as "info_target" class. As far as you already have an entity index, it already has some classs.
__________________
My English is A0
E1_531G is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 02-08-2019 , 12:33   Re: DispatchClass
Reply With Quote #3

Why not create an entity that's linked to CBasePlayerWeapon instead of "info_target" in the first place?
__________________
klippy is offline
CrazY.
Veteran Member
Join Date: May 2015
Location: SP, Brazil
Old 02-08-2019 , 12:39   Re: DispatchClass
Reply With Quote #4

I noticed that it inherits CBasePlayerItem/CBasePlayerWeapon members, but not the functions. Anyway, probably this would be useless, I was thinking to "hack" info_target entity and make custom weapons from it.

Somehow it's possible if you remove default CS weapons and work with a amxx "recoded" version of weapons.cpp:

Code:
new m_pActiveItem[MAX_PLAYERS+1]; public client_PostThink(this) {     if (!is_user_alive(this))         return;     if (m_pActiveItem[this] != -1)     {         // Call "fake" post frame (Whatever_PostFrame)         ExecuteForward(ForwardPostFrame, _, m_pActiveItem[this]);     } } public Whatever_PostFrame(this) {     static pPlayer;     pPlayer = get_ent_data_entity(this, "CBasePlayerItem", "m_pPlayer");     if (pev(pPlayer, pev_button) & IN_ATTACK)     {         // Call "fake" primary attack (Whatever_PrimaryAttack)         ExecuteForward(ForwardPrimaryAttack, _, this);     } } public Whatever_PrimaryAttack(this) {     // Do primary attack }

But, many lines would have to be made and probably would be required orpheu or reapi to work with ApplyMultiDamage, AddMultiDamage, FireBullets3, etc. It's a idea to think about, since the only method that developers know and have nowadays it's "override" weapons. I'm not sure what're the good and bad points of my idea. If anyone wants to comment, feel free.
__________________








CrazY. 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 19:46.


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