Willkommen ~Gast!
Registrieren || Einloggen || Hilfe/FAQ || Staff
Probleme mit der Registrierung im Forum? Melde dich unter registerEin Bild.
Autor Beitrag
000
16.07.2002, 19:39
thinktank



Hoi !

Ich will ein Monster erschaffen, dass einfach wirr durchs
Level läuft und sich möglichst _nicht_ vom Spieler einfangen lassen kann.
Vielleicht ist das alles nur Schwachsinn gegen das System mit den Nodes von HL "anzugehen", aber das Monster soll halt unabhängig von Nodes sein.

Hier der Code :
[code]
#define STEP_SIZE 64.0

TraceResult tr;
Vector vecTestVectors[8];
Vector vecForwardTest, vecStepForward, vecStepRight;
Vector vecEnd ,vecStart;
static int lastroute;
int i = 0, routecount = 0;

vecStart = pev->origin + pev->view_ofs;

UTIL_MakeVectors ( pev->angles );
vecStepRight = gpGlobals->v_right * STEP_SIZE;
vecStepForward = gpGlobals->v_forward * STEP_SIZE;
vecStepRight.z = 0;
vecStepForward.z = 0;

vecTestVectors[0] = vecStart + vecStepForward; // Forward
vecTestVectors[1] = vecStart - vecStepForward; // Backward
vecTestVectors[2] = vecStart - vecStepRight; // Left
vecTestVectors[3] = vecStart + vecStepRight; // Right

vecTestVectors[4] = vecTestVectors[3] + vecStepForward; // Upper Right
vecTestVectors[5] = vecTestVectors[2] + vecStepForward; // Upper Left
vecTestVectors[6] = vecTestVectors[3] - vecStepForward; // Down Right
vecTestVectors[7] = vecTestVectors[2] - vecStepForward; // Down Left

vecEnd = vecTestVectors[lastroute];

for(int g=0;g<8;g++)
{

MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_LINE);
WRITE_COORD( vecStart.x );
WRITE_COORD( vecStart.y );
WRITE_COORD( vecStart.z );

WRITE_COORD( vecTestVectors[g].x );
WRITE_COORD( vecTestVectors[g].y );
WRITE_COORD( vecTestVectors[g].z );

WRITE_SHORT(30);

WRITE_BYTE((RANDOM_LONG(5,64)*g)%255); // sinnloses
//Zahlengeswurschtel, das verschiedene Farben rausbringen soll =)
WRITE_BYTE(255);
WRITE_BYTE(255);

MESSAGE_END();
}

UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr);

if (((tr.flFraction != 1.0) && (CheckLocalMove( vecStart, vecEnd, NULL, NULL) == LOCALMOVE_INVALID)) || routecount >= 5) // Last Route doesnt work, try all routes
{
for(i=0;i<8;i++)
{
if (i == lastroute) // skip
continue;

vecEnd = vecTestVectors[i];

ALERT(at_notice, "Testing Route %i ...\n", i);

UTIL_TraceLine( vecStart, vecEnd, dont_ignore_monsters, ignore_glass, ENT(pev)/*pentIgnore*/, &tr);

if(tr.flFraction == 1.0) // We found a new route
{
if (CheckLocalMove( vecStart, vecEnd, NULL, NULL) == LOCALMOVE_VALID)
{
ALERT(at_aiconsole, "Route %i ok\n", i);
break;
}
}

if(i>=7) // We found no way out
{
ALERT(at_aiconsole, "No Routes were ok :(\n");
TaskFail();
break;
}
}

}
else
{
routecount++;
}

if ( MoveToLocation( ACT_RUN, 1, vecEnd ))
{
lastroute = i;
TaskComplete();
}
else
{
ALERT(at_aiconsole, "Couldnt move to route %i :(\n", i);
TaskFail();
}
}
[/code]

Das Monster stoppt jetzt , wenn es gegen eine Wand läuft und meint, die Route 0 sei ok ( also es versucht weiter gegen die Wand zu laufen ).
Was habe ich falsch gemacht ?

edit :
Ich musste leider die Code-Formatierung dem [i] opfern :(

--


Dieser Beitrag wurde am 16.07.2002 um 19:44 von thinktank bearbeitet.
zum Seitenanfang zum Seitenende Profil || Suche