Looking for some more equivalents...

Please post any questions about developing your plugin here. Please use the search function before posting!
Omega_K2
Senior Member
Posts: 227
Joined: Sat Jul 07, 2012 3:05 am
Location: Europe
Contact:

Looking for some more equivalents...

Postby Omega_K2 » Fri Jan 11, 2013 9:34 pm

1. es_fire (es.fire/es_xfire)
2. eventscripts_language (i.e. server language setting)

[3. Possibly some good ideas for "damage" replacement (i.e. something else besides creating a point_hurt entity and using it to damage players)]





P.S.: It's really about time that the docs go back up, I spend so much time searching for stuff in the source code of the cpp and py files :(
Libraries: k2tools
Plugins (any): GSRPG (soon) | Pretty Status List | MySQLAds (soon)
Plugins (game-specific): None atm

If you happen to find a bug or need help, either post in the release threads or contact me in IRC gamesurge.net:6667 / #sourcepython
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Jan 14, 2013 12:11 am

Adding a server language will be easy enough. I will do that shortly.

As far as damage is concerned, I "think" we should be able to create a TakeDamageInfo instance by calling CTakeDamageInfo.Init dynamically and using that as an argument to pass to CBaseCombatCharacter.OnTakeDamage. However, my attempts at this, so far, have not yielded much success.

Satoon
User avatar
L'In20Cible
Project Leader
Posts: 1533
Joined: Sat Jul 14, 2012 9:29 pm
Location: Québec

Postby L'In20Cible » Mon Jan 14, 2013 1:03 am

Hey guys,

This is actually easy to to restructure a CTakeDamageInfo object. As you can see, there's no virtual functions so you won't have to sigscan for the constructor as you doesn't have to set the dispatch table. All you have to do is to restructure the members:

Syntax: Select all

Vector			m_vecDamageForce;
Vector m_vecDamagePosition;
Vector m_vecReportedPosition; // Position players are told damage is coming from
EHANDLE m_hInflictor;
EHANDLE m_hAttacker;
EHANDLE m_hWeapon;
float m_flDamage;
float m_flMaxDamage;
float m_flBaseDamage; // The damage amount before skill leve adjustments are made. Used to get uniform damage forces.
int m_bitsDamageType;
int m_iDamageCustom;
int m_iDamageStats;
int m_iAmmoType; // AmmoType of the weapon used to cause this damage, if any
float m_flRadius;

// CS:GO
int m_iDamagedOtherPlayers;
int m_iObjectsPenetrated;
uint32 m_uiBulletID;
uint8 m_uiRecoilIndex;
According to that your memory need to looks like:

Syntax: Select all

0   m_vecDamageForce.x
4 m_vecDamageForce.y
8 m_vecDamageForce.z
12 m_vecDamagePosition.x
16 m_vecDamagePosition.y
20 m_vecDamagePosition.z
24 m_vecReportedPosition.x
28 m_vecReportedPosition.y
32 m_vecReportedPosition.z
36 m_hInflictor
40 m_hAttacker
44 m_hWeapon
48 m_flDamage
52 m_flMaxDamage
56 m_flBaseDamage
60 m_bitsDamageType
64 m_iDamageCustom
68 m_iDamageStats
72 m_iAmmoType
76 m_flRadius
80 m_iDamagedOtherPlayers
84 m_iObjectsPenetrated
88 m_uiBulletID
92 m_uiRecoilIndex
Where you need to allocate a pointer of 96 bytes (even tho uint8 is 1 byte long it need to be aligned so m_uiRecoilIndex is from 92 to 96). Also, note that OnTakeDamage is actually a "callback" and should not be called directly ? you need to call CBaseEntity::TakeDamage which will take care to call the proper callback for you (depending of the given entity by using the power of its dispatch table :) ). So, something like this should works:

Syntax: Select all

# Allocate our pointer...
damageinfo = Binutils.AllocateMemory(96)

# Set m_flDamage...
Binutils.SetLocInt(damageinfo + 48, 100)

# Call CBaseEntity::TakeDamage(<entity pointer>, damageinfo)

# [IMPORTANT] Free the memory used...
Binutils.DeallocatePointer(damageinfo)
NOTE: This is only based on the code, I didn't test anything, will do as soon as I can if nobody got that to work.

Good luck,

L'In20Cible
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Mon Jan 14, 2013 5:52 pm

I did not want to derail this thread entirely, so I started another specific to the damage idea:
http://www.sourcepython.com/showthread.php?255

Satoon

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 20 guests