Newbie Spellweaver
- Joined
- Dec 21, 2014
- Messages
- 11
- Reaction score
- 14
Code:
Credit : Desperate (There have been some improvements based on the code provided by Desperate.)
https://forum.ragezone.com/threads/damage-floting.1227246/post-9253385
--
I was asked to upload it on the board, and also got permission from Desperate.
Of course, if use text, it will be much easier to implement, but if use elu, you will be able to use more diverse designs and animations.
I made a little improvement on this. (dmg floating using elu and ani)
Instead, I changed the position data of the elu itself. (It's a little trick. lol)
First of all, please use the attached file's elu.
(To prevent numbers from overlapping)
- We need to figure out how we can do horizontal control to optimize this.
-> Finally solved the horizontal control.
We need your contribution to developing more upgraded codes.
----------------------------------------------------------------------------
Gunz -> ZEffectManager.h
Find
C++:
class ZEffectManager
-> Add inside (protected)
C++:
RMeshMgr* m_pEffectMeshDmg;
RMesh* m_pDamageFloatx[10];
-> Add inside too (public)
C++:
void AddDamageEffect(int Dmg, ZObject* pObj, ZObject* pOwner);
----------------------------------------------------------------------------
Gunz -> ZeffectManager.cpp
Add
C++:
void ZEffectManager::AddDamageEffect(int Dmg, ZObject* pObj, ZObject* pOwner)
{
if (Dmg == 0) return;
class ZEffectDmgfloating : public ZEffectIcon {
public:
ZEffectDmgfloating(RMesh* pMesh, ZObject* pObj)
: ZEffectIcon(pMesh, pObj) {
}
virtual bool Draw(unsigned long int nTime)
{
ZObject* pObj = ZGetObjectManager()->GetObject(m_uid);
ZCharacter* pChar = MDynamicCast(ZCharacter, pObj);
if (pChar) {
if (!pChar->m_bRendered) return true;
if (!pChar->IsVisible()) return true;
if (pObj->m_pVMesh) {
m_Pos = pObj->GetVisualMesh()->GetHeadPosition() + rvector(0, 0, 50); // + rvector(0, 0, height)
RGetDevice()->SetRenderState(D3DRS_ZWRITEENABLE, TRUE);
ZEffectAniMesh::Draw(nTime);
RGetDevice()->SetRenderState(D3DRS_ZWRITEENABLE, FALSE);
return true;
}
}
return false;
}
};
ZEffect* pNew = NULL;
char buffer[32];
sprintf(buffer, "%d", abs(Dmg));
int nCount = (int)strlen(buffer);
float fScale, dist, fPosX;
float dx = pObj->GetPosition().x - pOwner->GetPosition().x;
float dy = pObj->GetPosition().y - pOwner->GetPosition().y;
float dz = pObj->GetPosition().z - pOwner->GetPosition().z;
dist = sqrt(dx * dx + dy * dy + dz * dz);
for (int i = 0; i < nCount; i++)
{
if (nCount == 3)
{
if (i == 0) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
DeleteSameType((ZEffectAniMesh*)pNew);
fPosX = -25; // You can adjust the Horizontal of the elu by changing the fPosX.
} // The default width of the elu provided is 24.
if (i == 1) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
fPosX = 0;
}
if (i == 2) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
fPosX = 25;
}
}
if (nCount == 2)
{
if (i == 0) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
DeleteSameType((ZEffectAniMesh*)pNew);
fPosX = 0;
}
if (i == 1) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
fPosX = 25;
}
}
if (nCount == 1)
{
if (i == 0) {
pNew = new ZEffectDmgfloating(m_pDamageFloatx[buffer[i] - '0'], pObj);
DeleteSameType((ZEffectAniMesh*)pNew);
fPosX = 0;
}
}
fScale = 1.0f + 0.001f * dist; //Adjusting the size by distance
fPosX = fPosX + 0.001f * dist * fPosX; //Adjusting the Letter-spacing by distance
((ZEffectDmgfloating*)pNew)->SetScale(rvector(fScale, fScale, fScale));
((ZEffectDmgfloating*)pNew)->SetwPos(fPosX);
((ZEffectDmgfloating*)pNew)->SetwPosS(true);
Add(pNew);
}
}
Find
C++:
bool ZEffectManager::Create(void)
-> Add inside
C++:
m_pEffectMeshDmg = new RMeshMgr;
if (m_pEffectMeshDmg->LoadXmlList("SFX/dmg/float_damage.xml") == -1) {
mlog("float damage sfx loding error\n");
}
for (int i = 0; i < 10; i++)
{
char meshnamex[256];
sprintf(meshnamex, "dmgx%d", i);
m_pDamageFloatx[i] = m_pEffectMeshDmg->Get(meshnamex);
}
Gunz -> ZCharacter.h
Find
C++:
struct ZCharacterStatus
-> Add inside And on top of 'nScore;'
C++:
float nRoundGivenDamage;
----
nRoundGivenDamage(0),
----------------------------------------------------------------------------
Gunz -> ZGame.h
Find
C++:
void OnPeerShotgun_Damaged(~~);
-> Change (Add `int Repeatcount` at the far end of the factor)
C++:
void OnPeerShotgun_Damaged(ZObject* pOwner, float fShotTime, const rvector& pos, rvector& dir, ZPICKINFO pickinfo, DWORD dwPickPassFlag, rvector& v1, rvector& v2, ZItem* pItem, rvector& BulletMarkNormal, bool& bBulletMark, ZTargetType& nTargetType, bool& bHitEnemy, int Repeatcount);
----------------------------------------------------------------------------
Gunz -> ZGame.cpp
Find
C++:
void ZGame::OnPeerShot_Range_Damaged
-> Add inside (In the part where you calculate the damage)
C++:
ZGetGame()->m_pMyCharacter->GetStatus().CheckCrc();
ZGetGame()->m_pMyCharacter->GetStatus().Ref().nRoundGivenDamage = fActualDamage;
ZGetGame()->m_pMyCharacter->GetStatus().MakeCrc();
-> Add inside too (OnPeerShot_Range_Damaged's end)
C++:
if ((pObject->GetUID() != ZGetMyUID()) && (pOwner->GetUID() == ZGetMyUID()))
{
int nCurrDamage = ZGetGame()->m_pMyCharacter->GetStatus().Ref().nRoundGivenDamage;
ZGetEffectManager()->AddDamageEffect(nCurrDamage, pObject, pOwner);
}
Find
C++:
in the 'void ZGame::OnPeerShot_Shotgun'
OnPeerShotgun_Damaged( pOwnerCharacter, fShotTime, pos, dir, pickinfo, dwPickPassFlag, v1, v2, pItem, BulletMarkNormal, bBulletMark, nTargetType, bHitEnemy);
Change (Add `i` at the far end of the factor)
C++:
OnPeerShotgun_Damaged( pOwnerCharacter, fShotTime, pos, dir, pickinfo, dwPickPassFlag, v1, v2, pItem, BulletMarkNormal, bBulletMark, nTargetType, bHitEnemy, i);
Find
C++:
void ZGame::OnPeerShotgun_Damaged
-> Change (Add `int Repeatcount` at the far end of the factor)
C++:
void ZGame::OnPeerShotgun_Damaged(ZObject* pOwner, float fShotTime, const rvector& pos, rvector& dir, ZPICKINFO pickinfo, DWORD dwPickPassFlag, rvector& v1, rvector& v2, ZItem *pItem, rvector& BulletMarkNormal, bool& bBulletMark, ZTargetType& nTargetType, bool& bHitEnemy, int Repeatcount)
-> Add inside
C++:
//Initialize the variable at the first of the iterations of this function
if (Repeatcount == 0) {
ZGetGame()->m_pMyCharacter->GetStatus().CheckCrc();
ZGetGame()->m_pMyCharacter->GetStatus().Ref().nRoundGivenDamage = 0;
ZGetGame()->m_pMyCharacter->GetStatus().MakeCrc();
}
-> Add inside too (In the part where you calculate the SG damage)
C++:
ZGetGame()->m_pMyCharacter->GetStatus().Ref().nRoundGivenDamage += fActualDamage;
-> Add inside too
C++:
if ((pObject->GetUID() != ZGetMyUID()) && (pOwner->GetUID() == ZGetMyUID()))
{
int nCurrDamage = ZGetGame()->m_pMyCharacter->GetStatus().Ref().nRoundGivenDamage;
ZGetEffectManager()->AddDamageEffect(nCurrDamage, pObject, pOwner);
}
-> Melee
C++:
void ZGame::OnPeerShot_Melee
-> Explosion(rocket, granade)
C++:
void ZGame::OnExplosionGrenade
If you don't want to output when you attack mob, add this to the condition of calling AddDamageEffect.
Verify that the target is npc(mobs).
C++:
!pObject->IsNPC()
----------------------------------------------------------------------------
Gunz -> ZEffectAniMesh.h
Find
C++:
class ZEffectAniMesh : public ZEffect
-> Add inside (protected)
C++:
float m_wPosX;
bool m_wPosS;
-> Add inside too(public)
C++:
void SetwPos(float a);
void SetwPosS(bool b);
----------------------------------------------------------------------------
Gunz -> ZEffectAniMesh.cpp
Find
C++:
void ZEffectAniMesh::SetScale(rvector s)
-> Add Under
C++:
void ZEffectAniMesh::SetwPos(float a)
{
m_wPosX = a;
}
void ZEffectAniMesh::SetwPosS(bool b)
{
m_wPosS = b;
}
Find
C++:
ZEffectAniMesh::ZEffectAniMesh(RMesh* pMesh, const rvector& Pos, rvector& dir)
-> Add inside
C++:
m_wPosS = false;
m_wPosX = 0;
Find
C++:
bool ZEffectAniMesh::Draw(unsigned long int nTime)
-> Find inside
C++:
MakeWorldMatrix(&World, m_Pos, Dir, Up);
-> Add under 'MakeWorldMatrix'
C++:
if (m_wPosS == true)
{
rmatrix _tPosWorld;
D3DXMatrixTranslation(&_tPosWorld, m_wPosX, 0, 0);
World = _tPosWorld * World;
}
SFX.mrs/dmg/float_damage.xml
XML:
<!-- Dmg Floating -->
<AddEffectElu name="dmgx0">
<AddBaseModel name="dmgx0" filename="dmg/ef_exp_num_x0.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x0.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx1">
<AddBaseModel name="dmgx1" filename="dmg/ef_exp_num_x1.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x1.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx2">
<AddBaseModel name="dmgx2" filename="dmg/ef_exp_num_x2.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x2.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx3">
<AddBaseModel name="dmgx3" filename="dmg/ef_exp_num_x3.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x3.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx4">
<AddBaseModel name="dmgx4" filename="dmg/ef_exp_num_x4.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x4.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx5">
<AddBaseModel name="dmgx5" filename="dmg/ef_exp_num_x5.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x5.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx6">
<AddBaseModel name="dmgx6" filename="dmg/ef_exp_num_x6.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x6.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx7">
<AddBaseModel name="dmgx7" filename="dmg/ef_exp_num_x7.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x7.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx8">
<AddBaseModel name="dmgx8" filename="dmg/ef_exp_num_x8.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x8.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
<AddEffectElu name="dmgx9">
<AddBaseModel name="dmgx9" filename="dmg/ef_exp_num_x9.elu" />
<AddAnimation name="play" filename="dmg/ef_exp_num_x9.elu.ani" motion_type="0" motion_loop_type="lastframe" />
</AddEffectElu>
Attachments
You must be registered for see attachments list
Last edited: