I commented out StartAttack and a bunch of other functions to disable regular turn based combat. Now when someone double clicks someone to attack them that person gets flagged.
I noticed these functions actually flagged the original attacker first to prevent the guy from being targetted by an attack from being flagged criminal.
Why does that happen? If the target is set to automatically fight back against the opponenet where is the function that's flagging him criminal?
Also just wondering if there is an easy way to apply Damage to someone without specifying an attacker. Perhaps a NULL attacker? I'm pretty sure this is what's giving me problems.
Combat stuff
I am not sure in what context you mean to specify damage. I assume you are re-writing the combat code (which I would like to have a look at when you are done).
Via .js we add and subtract damage all the time without an attacker, here is an excerpt from my GM command script.
directly affecting the objects health does not require an attacker, only the target with which you want to decrease or increase the health.
[/code]
Via .js we add and subtract damage all the time without an attacker, here is an excerpt from my GM command script.
Code: Select all
case "HP":
ourObj.health = nVal + ourObj.health;
okMsg( socket );
ourObj.TextMessage("HP: "+ourObj.health);
ourObj.SysMessage( "Health has changed by " + nVal );
break;
directly affecting the objects health does not require an attacker, only the target with which you want to decrease or increase the health.
[/code]
Well I'm talking about the combat code in the source. I'm basically trying to make a real time combat system, where players use an [attack command to make attacks rather than use the turn based system. I can show you when I finish it
Right now theres a nasty bug, which upon further testing I think I've discovered to be a problem with the names.
See, players can attack each other just fine, the concept works, but once they click the person they were attacking to see their name, the shard will crash hard. Not good.
Repsys set to false, I'm no longer using the Damage function to make damage upon the target, argh. Still get probs.
Right now theres a nasty bug, which upon further testing I think I've discovered to be a problem with the names.
See, players can attack each other just fine, the concept works, but once they click the person they were attacking to see their name, the shard will crash hard. Not good.
Repsys set to false, I'm no longer using the Damage function to make damage upon the target, argh. Still get probs.
here's the function I'm using as a test
some of Those conditionals in FindTargetChar are supposed to look different, but forums are bugged
Code: Select all
//0-------------------------------------------------------------------------------0
//| Function - CombatCommandCall( CChar *mChar )
//| Programmer - Saint
//0-------------------------------------------------------------------------------0
//| Purpose - When an [attack is called by a player, this fires
//|
//0-------------------------------------------------------------------------------0
void CHandleCombat::CombatCommandCall( CChar *mChar )
{
// SI16 baseDamage;
Combat->PlaySwingAnimations( mChar );
CChar *targChar = FindTargetChar( mChar );
if(targChar != NULL){
// baseDamage = calcAtt(mChar, false);
//Commented out since I suspect it may have been causing some problem somewhere
SI16 hitpoints = targChar->GetHP();
targChar->SetHP( hitpoints - 2 );
Combat->PlayMissedSoundEffect( targChar ); //temporary
}
}
Code: Select all
//0-------------------------------------------------------------------------------0
//| Function - FindTargetChar( CChar *mChar )
//| Programmer - Saint
//0-------------------------------------------------------------------------------0
//| Purpose -Find's a suitable attack target in mChar's range.
//|
//0-------------------------------------------------------------------------------0
CChar *FindTargetChar( CChar *mChar ) {
CChar *SelectedTarg = mChar->GetTarg();
//Ensure a target is selected
if(SelectedTarg == NULL)
{
return NULL;
}
SI16 sourceX = mChar->GetX();
SI16 sourceY = mChar->GetY();
SI08 sourceZ = mChar->GetZ();
SI08 sourceDir = mChar->GetDir();
UI08 sourceWorld = mChar->WorldNumber();
CChar *FinalTarg = NULL;
SI16 targX = SelectedTarg->GetX();
SI16 targY = SelectedTarg->GetY();
SI08 targZ = SelectedTarg->GetZ();
UI08 targWorld = SelectedTarg->WorldNumber();
//World Check
if(targWorld == sourceWorld)
{
//SpotCheck
if( !((targX == sourceX) && (targY == sourceY)) )
{
//HeightCheck
if( (targZ <sourceZ>= (sourceZ - 15)) )
{
//Fine Coordinate check
if( ((targX <sourceX>= (sourceX - 1))) && ((targY <sourceY>= (sourceY - 1))) )
{
//Validation
if( ValidateAttackVictim( SelectedTarg, *mChar ) )
{
FinalTarg = SelectedTarg;
}
}
}
}
return FinalTarg;
}
-
Maarc
- Developer
- Posts: 576
- Joined: Sat Mar 27, 2004 6:22 am
- Location: Fleet, UK
- Has thanked: 0
- Been thanked: 0
- Contact:
Yeah, some of the condiitionals definitely look wrong. You don't supply the source for ValidateAttackVictim. If it's just a ValidateObject check, you shouldn't need an extra function.
You should change the SetHP call to Damage()
This will do 2 hitpoints of damage from the attacker mChar on the target targChar, and will handle any criminalisation as well. This means the damage tracking gets handled as well. It's not used elsewhere at the moment (though honestly, I thought I had written something?), but the damage tracking would allow for a more complex karma/fame assignment on killing (ie grant the person who damaged you the most, the most karma/fame penalties/bonuses, rather than the final person to land a blow).
As far as calcAtt goes, it should be just fine and dandy. It's used dozens or hundreds of times already in the main combat loop, and exhibits no issues there. Nothing in themain routines should trample over anything like that. Make sure that you validate all your pointers, and don't go trampling around memory. That could be a source of your problems.
You should change the SetHP call to Damage()
Code: Select all
targChar->Damage( 2, mChar, true );
As far as calcAtt goes, it should be just fine and dandy. It's used dozens or hundreds of times already in the main combat loop, and exhibits no issues there. Nothing in themain routines should trample over anything like that. Make sure that you validate all your pointers, and don't go trampling around memory. That could be a source of your problems.