Ok, so I gave it a few runs, tried to add in debug messages to figure out what was going wrong, but have to throw in the towel and see if you guys can spot what I am doing wrong here. Here is the sample code I wrote for the Hate Step effect ( recall - warps a character forward in the direction they are facing x distance; its an SK AA on live ).
Code:
case SE_ShadowStepDirectional:
{
double look_heading = GetHeading();
look_heading /= 256;
look_heading *= 360;
look_heading += 180;
if(look_heading > 360)
look_heading -= 360;
// note: x and y are backwards
// the -8 is just a multiplier to increase the distance I arbitrarily picked, nothing more
double new_x = ( spells[spell_id].base[i] * -8 ) * sin(double(look_heading * 0.017453289 ));
double new_y = ( spells[spell_id].base[i] * -8 ) * cos(double(look_heading * 0.017453289 ));
double new_z = GetZ( );
// try to see if a zone wall is in the way
VERTEX start, end, result;
FACE *triangle = NULL;
start.x = GetX( );
start.y = GetY( );
start.z = GetZ( );
end.x = GetX( ) + new_x;
end.y = GetY( ) + new_y;
end.z = GetZ( );
bool b = zone->zonemap->LineIntersectsZone( start, end, 1.0f, &result, &triangle );
Message(15, "Debug: result is %s: %lf %lf %lf", ( b == true ? "true" : "false" ), result.x, result.y, result.z );
if( b )
{ // result should give us the point we hit
Message(15, "Debug: intersect @ %lf %lf %lf", result.x, result.y, result.z );
new_x = result.x;
new_y = result.y;
}
else
{ // otherwise, set new_* to values we wanted to use
new_x += GetX( );
new_y += GetY( );
Message(15, "Debug: used2 x,y %lf %lf", new_x, new_y );
}
// now lets find the z-axis value
VERTEX org;
org.x = new_x;
org.y = new_y;
org.z = GetZ( );
Message(15, "Debug: old z %lf", org.z );
//new_z = zone->zonemap->FindBestZ( MAP_ROOT_NODE, org, &result, &triangle );
new_z = org.z - zone->zonemap->FindClosestZ( org );
Message(15, "Debug: new z %lf", new_z );
// I have no idea why, but I had to double the GetHeading return value for this function to work for me, hence the *2
CastToClient()->MovePC( zone->GetZoneID(), zone->GetInstanceID(), new_x, new_y, new_z, GetHeading( ) *2, 0, PCStep );
Message(15, "%s %s", GetName(), spells[spell_id].cast_on_other );
Thus far, I still go into / through walls and seem to always get returned a 0 from FindBestZ ( note - I've been testing int he Arena ), either implementation, while the 'real Z' shown by a #loc command can be vastly different, plus or minus.
I can paste in some of the logs too if that helps, but I figured it may be hard to envision in pure numbers when one is in a wall or not...
Anything stand out as to what I am doing wrong? Seems like a rather simple thing to implement but I put no limits as to what I can screw up!
