1 (edited by Ikaron 2012-03-24 14:27:39)

Topic: [Solved] [Help] Disable grenade-damage for owner?

Like the title says, I need to disable explosion damage for the owner of that explosion. How can you do that? Probably in GameServer, but where is that class? (Sry, C++ noob smile)

Solve:
character.cpp:

Changed

if(From == m_pPlayer->GetCID())
    Dmg = max(1, Dmg/2);

to

if(From == m_pPlayer->GetCID())
    Dmg = 0;

in TakeDamage()

2

Re: [Solved] [Help] Disable grenade-damage for owner?

Explosion-Damage is calculated in CGameContext::CreateExplosion, and taken in CCharacter::TakeDamage.

Ikaron wrote:

(Sry, C++ noob)

You shouldn't write mods without good C++ knowledge :\

3

Re: [Solved] [Help] Disable grenade-damage for owner?

Thank you kindly!
Yes, I know I shouldn't, but I have over 1 year of java experience.. Therefore, I know OOP andI am good at it, but sometimes c++ is a bit different, that's when I need help smile

4

Re: [Solved] [Help] Disable grenade-damage for owner?

Ikaron wrote:

sometimes c++ is a bit different, that's when I need help

The only thing both languages have in common is that they are OOP-langs tongue

But your welcome, feel free to ask further questions about the teeworlds code, when you need help smile

5

Re: [Solved] [Help] Disable grenade-damage for owner?

Ikaron wrote:

Like the title says, I need to disable explosion damage for the owner of that explosion. How can you do that? Probably in GameServer, but where is that class? (Sry, C++ noob smile)


Search for file:
src/game/server/entities/character.cpp

Search for the function:
TakeDamage()

Search for block:

        // m_pPlayer only inflicts half damage on self
        if(From == m_pPlayer->GetCID())
                Dmg = max(1, Dmg/2);

And make it look like this:

        // Disable owner damage ... for whatever reason :P
        if(From == m_pPlayer->GetCID())
                return false;

Greetings,
Mo(2)

6

Re: [Solved] [Help] Disable grenade-damage for owner?

Mo2 wrote:

Search for block:

        // m_pPlayer only inflicts half damage on self
        if(From == m_pPlayer->GetCID())
                Dmg = max(1, Dmg/2);

And make it look like this:

        // Disable owner damage ... for whatever reason :P
        if(From == m_pPlayer->GetCID())
                return false;

Greetings,
Mo(2)

Thank you smile
Now, I wanted the push of the explosion, so I just used Dmg = 0; instead of return false; smile

7

Re: [Solved] [Help] Disable grenade-damage for owner?

Slayer *gV* wrote:

You shouldn't write mods without good C++ knowledge :\

I don't agree. Learning by doing is hard to beat. For sure you can even try to learn C++ with coding "hello worlds" like crazy (and get bored and leave soon) - or via coding some grey conservative accounting software for office (and get bored way faster). Playing bad mods is not mandatory at all. So as long they would not interrupt the normal TW community it's ok IMHO (and interrupting can be done easy with good C++ knowledge as well for example if you think more then 16 clients would be a good idea).