I'm trying to improve the fistfighting code. This is what I currently have:<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> if( CheckAttribute(weapon, "fist" ) && enemy.chr_ai.group != LAI_GROUP_PLAYER )
// PB: New weapons attribute, exclusively for your fists
{
int rank = makeint(attack.rank)
int punch = rand (rank) + rank;
// Calculates the strength of your punch; character's rank increases damage
LAi_ApplyCharacterDamage(enemy, punch);
// Applies damage to enemy
LAi_CheckKillCharacter(enemy);
// Checks if this has killed the character
if(rand(100)< punch +10) // ccc added +10
// Checks if punch knocks enemy out; character's rank increases chance
{
LAi_SetPoorTypeNoGroup(enemy); // makes initial target collapse or cover
enemy.stuntime = locTmpTime; // stores the time of this, for reawakening
enemy.stuntime.dialog.filename = enemy.dialog.filename; // saves original dialog
enemy.dialog.filename = "stunned_dialog.c"; // assigns "stunned" dialog during stuntime
if(enemy.sex == "man") {PlaySound("OBJECTSVoicesdeadmaledead1.wav")} // groan
else{PlaySound("OBJECTSVoicesdeadfemaledead_wom2.wav")}
Log_SetStringToLog("WHACK! You knocked out your opponent!");
float u, v, w; // coordinates for effects
GetCharacterPos(enemy, &u, &v, &w); // determines position of initial target
CreateParticleSystem("stars" , u, v+1, w, 0.0, 0.0, 0.0, sti(20) );
// displays the "stars" particle effect on the victim
}
else
{
LAi_group_Attack(attack, enemy); // makes victim and associates attack you
}
}<!--c2--></div><!--ec2-->This seems to work quite fine. It does damage to the enemy between your rank and twice your rank. It also has the ability to knock your opponent out. I even managed to get rid of the applying damage twice problem by adding<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--> if(!CheckAttribute(weapon, "fist" ) ) // PB: Fists will only do damage once with one hit
{LAi_ApplyCharacterAttackDamage(attack, enemy, attackDmg, hitDmg);}<!--c2--></div><!--ec2-->However: I would like it if the knocking out code wouldn't run if you just killed your enemy, but I don't know how to say "if(enemy isn't dead)" in code. I tried "if(!LAi_CheckKillCharacter(enemy))", but that just caused the game to run quite slowly, while not doing what it's supposed to at all. <img src="http://www.piratesahoy.com/forum/style_emoticons/<#EMO_DIR#>/ohmy.gif" style="vertical-align:middle" emoid="
" border="0" alt="ohmy.gif" />