• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[C++] Adding Conditions to Melee

Otfan125

Well-Known Member
Joined
Mar 1, 2008
Messages
169
Solutions
1
Reaction score
55
Location
Thais
Hey everyone, I'm trying to implement a melee system that applies different conditions (stun, bleeding, critical, etc.) during combat.

Is there a way to do this through source edit? I've been editing weapon.cpp with a lot of success so far, though adding conditions has not been so straight forward to me.
I know there is a way to do this, which is by creating a .lua script in data/weapons and apply it to every melee item there is, though, I wish to circumvent this and attempt to do it through the c++ sources... Any pointers?

Thanks! :)
 
Solution
this is really close to what I was looking for... Instead of healing, I was looking to deal damage to the target over time, with a BLEEDING condition:

For testing, this is what I have:
C++:
    Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
    condition->setParam(CONDITION_PARAM_PERIODICDAMAGE, 100);
    player->addCondition(condition);

It should add the bleeding condition to the player (though, could easily be changed to target->addCondition). It seems to be working but not dealing any damage...
Post automatically merged:

so this seems to do what I'm looking for:

C++:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_REGENERATION, -1, 0)...
A clear example to add a basic condition in the sources is the following:
Code:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_REGENERATION, -1, 0);
condition->setParam(CONDITION_PARAM_HEALTHTICKS, 1000);
condition->setParam(CONDITION_PARAM_HEALTHGAIN, 100);
player->addCondition(condition);
health regeneration condition, every second increases current health from 100 by 100
this condition is infinite and never ends. until the player disconnects or dies
for this condition to expire after 10 seconds, simply change the -1 to 10000

For Damage:
Code:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
condition->addDamage(10, 1000, -100)
player->addCondition(condition);
 
Last edited:
A clear example to add a basic condition in the sources is the following:
Code:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_REGENERATION, -1, 0);
condition->setParam(CONDITION_PARAM_HEALTHTICKS, 1000);
condition->setParam(CONDITION_PARAM_HEALTHGAIN, 100);
player->addCondition(condition);
health regeneration condition, every second increases current health from 100 by 100
this condition is infinite and never ends. until the player disconnects or dies
for this condition to expire after 10 seconds, simply change the -1 to 10000
this is really close to what I was looking for... Instead of healing, I was looking to deal damage to the target over time, with a BLEEDING condition:

For testing, this is what I have:
C++:
    Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
    condition->setParam(CONDITION_PARAM_PERIODICDAMAGE, 100);
    player->addCondition(condition);

It should add the bleeding condition to the player (though, could easily be changed to target->addCondition). It seems to be working but not dealing any damage...
Post automatically merged:

so this seems to do what I'm looking for:

C++:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_REGENERATION, -1, 0);
    condition->setParam(CONDITION_PARAM_HEALTHTICKS, 1000);
    condition->setParam(CONDITION_PARAM_HEALTHGAIN, -1000);
    target->addCondition(condition);

Though, obviously, there has to be a better way of doing this. For one, it doesn't show the "health" lost during the regeneration, it just performs it but doesn't show any effect.
 
Last edited:
this is really close to what I was looking for... Instead of healing, I was looking to deal damage to the target over time, with a BLEEDING condition:

For testing, this is what I have:
C++:
    Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
    condition->setParam(CONDITION_PARAM_PERIODICDAMAGE, 100);
    player->addCondition(condition);

It should add the bleeding condition to the player (though, could easily be changed to target->addCondition). It seems to be working but not dealing any damage...
Post automatically merged:

so this seems to do what I'm looking for:

C++:
Condition* condition = Condition::createCondition(CONDITIONID_DEFAULT, CONDITION_REGENERATION, -1, 0);
    condition->setParam(CONDITION_PARAM_HEALTHTICKS, 1000);
    condition->setParam(CONDITION_PARAM_HEALTHGAIN, -1000);
    target->addCondition(condition);

Though, obviously, there has to be a better way of doing this. For one, it doesn't show the "health" lost during the regeneration, it just performs it but doesn't show any effect.

check again
 
Solution
check again

This doesn't seem to work because Condition has no function "addDamage", though ConditionDamage does has that function. Replacing Condition with ConditionDamage:

C++:
ConditionDamage condition = ConditionDamage(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
condition.addDamage(10, 1000, -100);
player->addCondition(condition);

doesn't quite work, because for player->addCondition(condition), condition has to be of type Condition and not ConditionDamage
Code:
no suitable conversion function from "ConditionDamage" to "Condition *" exists

Unless, of course, I try to implement the add damage function into condition... I'll try that right now
Post automatically merged:

TFS 1.3 by the way
Post automatically merged:

Interesting enough, doing this does seem to have an effect:

C++:
ConditionDamage condition = ConditionDamage(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
condition.addDamage(10, 1000, -100);
condition.startCondition(player);

Though the only thing hat happens is the "blocking" effect to appear on the player.

EDIT:
It seems to be working now ! Though, it doesn't look like it is repeating:

C++:
ConditionDamage condition = ConditionDamage(CONDITIONID_DEFAULT, CONDITION_BLEEDING, -1, 0);
Condition.addDamage(10, 1000, -100);
condition.executeCondition(player, 1000);

By the way, I have this piece of code under
Code:
void Weapon::internalUseWeapon
so that everytime the player hits a target, the condition is applied. Though, ugh, the bleeding effect does not persist, and only damages the player every time he hits.
 
Last edited:
Idk why I can't edit my first post, but, this is what I managed so far:

C++:
        Condition* condition = Condition::createCondition(CONDITIONID_COMBAT, CONDITION_BLEEDING, 3000, 0);
        condition->setParam(CONDITION_PARAM_PERIODICDAMAGE, -bleedingDamage);
        condition->setParam(CONDITION_PARAM_TICKINTERVAL, 1000);
        condition->setParam(CONDITION_PARAM_FORCEUPDATE, true);
        target->addCondition(condition);

Its able to apply the Bleeding effect, but only once.. I don't know how to make it repeat for like, say, 5 seconds

EDIT:
Made it work,:

C++:
Condition* condition = Condition::createCondition(CONDITIONID_COMBAT, CONDITION_BLEEDING, 0, 0);
condition->setParam(CONDITION_PARAM_TICKS, 2000);
condition->setParam(CONDITION_PARAM_TICKINTERVAL, 1000);
condition->setParam(CONDITION_PARAM_PERIODICDAMAGE, -bleedingDamage);


thanks @Sarah Wesker
 
Last edited:
Back
Top