Hello there.
I have these lines of code in my W_FireWeapon function.
My purpose is to play one set of frame macros if the player aims at something with 1 and 39 hitpoints and another macro if he aims at something without health.
My limited brain capacity is not able to wrap around what i have to do. The lines below have the effect that the macros are played at seemingly random patterns.
else if (self.weapon2 & IT3_CHAINSAW) //if the chainsaw is equipped
{
if ((trace_ent.health > 0) && (trace_ent.health < 40)) //and my trace entity has 1-39 health
{
player_Chainsaw1(); //saw forward through it, as long as the mouse button is pressed (coded in player.qc)
}
else //if trace entity is above 39 or below 1 health
{
r = random();
if (r <= 0.5)
{player_ChainSwing1();} //swing horizontal if r is smaller than 0.5
else
{player_ChainSwingB1();} //or vertical if not
self.attack_finished = time + 0.7; //end attack after 0.7 seconds
}
}
I looked at how other functions and mods do similar checks, but somehow their solutions do not work in this case.
I also tried :
if ((trace_inopen != 1) || ((trace_ent.health > 1) && (trace_ent.health < 41)))
if ((trace_ent.solid == SOLID_SLIDEBOX) && ((trace_ent.health > 1) && (trace_ent.health < 41)))
Doesn't work
Well, i'm outdumbed by my brain.
Can any of yours help me?
That would be really nice.
I have these lines of code in my W_FireWeapon function.
My purpose is to play one set of frame macros if the player aims at something with 1 and 39 hitpoints and another macro if he aims at something without health.
My limited brain capacity is not able to wrap around what i have to do. The lines below have the effect that the macros are played at seemingly random patterns.
else if (self.weapon2 & IT3_CHAINSAW) //if the chainsaw is equipped
{
if ((trace_ent.health > 0) && (trace_ent.health < 40)) //and my trace entity has 1-39 health
{
player_Chainsaw1(); //saw forward through it, as long as the mouse button is pressed (coded in player.qc)
}
else //if trace entity is above 39 or below 1 health
{
r = random();
if (r <= 0.5)
{player_ChainSwing1();} //swing horizontal if r is smaller than 0.5
else
{player_ChainSwingB1();} //or vertical if not
self.attack_finished = time + 0.7; //end attack after 0.7 seconds
}
}
I looked at how other functions and mods do similar checks, but somehow their solutions do not work in this case.
I also tried :
if ((trace_inopen != 1) || ((trace_ent.health > 1) && (trace_ent.health < 41)))
if ((trace_ent.solid == SOLID_SLIDEBOX) && ((trace_ent.health > 1) && (trace_ent.health < 41)))
Doesn't work
Well, i'm outdumbed by my brain.
Can any of yours help me?
That would be really nice.
Comment