Upload
angelika-leifer
View
123
Download
3
Embed Size (px)
Citation preview
Projektgruppe KIMAS – Half-Life 1/26
UNIVERSITY OF
PADERBORN
Projektgruppe KIMAS
Half-Life
18.06.2003
Lars Tegeler
Projektgruppe KIMAS – Half-Life 2/26
UNIVERSITY OF
PADERBORNÜberblick
Half-Life
Die Half-Life Welt
Programmstruktur
Modifikationen
Bot´s
Projektgruppe KIMAS – Half-Life 3/26
UNIVERSITY OF
PADERBORNHalf-Life
1997 von Valve Software entwickelt von Sierra On-Line vertrieben
Modifikation der Quake Engine basiert auf Quake 1 mit Teile von Quake 2 und eigenen Erweiterungen
„Einige“ der Verantwortlichen z.B. Gabe Newell kamen von Microsoft ;-)
Projektgruppe KIMAS – Half-Life 4/26
UNIVERSITY OF
PADERBORNHalf-Life
Skeletal Animation System Rendering (16-bit color, colored lighting) Monster AI Decal System Real-Time DSP
DLL´s Direct X
Single/Multiplayer-Sourcen frei verfügbar Binaries der Engine nur unter Microsoft Windows
Projektgruppe KIMAS – Half-Life 5/26
UNIVERSITY OF
PADERBORNÜberblick
Half-Life
Die Half-Life Welt
Programmstruktur
Modifikationen
Bot´s
Projektgruppe KIMAS – Half-Life 6/26
UNIVERSITY OF
PADERBORNHalf-Life Welt
Die Half-Life Welt besteht aus zwei Artenvon Objekten:
1. Solids(Wände, Decken, ..., ohne Funktion)
2. Entities • Point-based ( statisch, aber auch Monster )• Brush-based ( dynamisch )
Projektgruppe KIMAS – Half-Life 7/26
UNIVERSITY OF
PADERBORNHalf-Life Welt
Gleicher Aufbau wie in Quake:
Vektoren (für Richtungen, etc.)
Maps(Positionierung der Solids und Entities, werden im Editor erzeugt und nach .bsp kompiliert)
Binary Space Partitioning(schnelle Datenstruktur für Echtzeitrender-systeme)
Kolisionserkennung(über Bounding-Boxes, an Achsen ausgerichtet, werden nicht gedreht)
Projektgruppe KIMAS – Half-Life 8/26
UNIVERSITY OF
PADERBORNHalf-Life Welt
Skeletal Animation System
Knochen werden bewegt Polygon-Netze um die
Knochen werden durch die Bewegung verformt
Berechung der Modelle zur Laufzeit
Größere Flexibilität wesentlich höhere Anzahl
von Polygonen (6000+)
Projektgruppe KIMAS – Half-Life 9/26
UNIVERSITY OF
PADERBORNÜberblick
Half-Life
Die Half-Life Welt
Programmstruktur
Modifikationen
Bot´s
Projektgruppe KIMAS – Half-Life 10/26
UNIVERSITY OF
PADERBORNProgrammstruktur
Code in C++
Server - hl.dll (bzw. mp.dll)Steuern der Entities (Monster, Waffen, ...)
Client - cl_dll.dllEnthält das gesamte UserInterface
DLL (Dynamic Link Library)Ermöglicht einem Prozess eine Funktion zu benutzen die nicht zu seinem Ausführbaren Code gehört
Projektgruppe KIMAS – Half-Life 11/26
UNIVERSITY OF
PADERBORNProgrammstruktur
Engine(Half-Life Game Executable)
Server(hl.dll /mp.dll)
Client-UI(cl_dll.dll)
GiveFnptrsToDll()
GetEntityAPI()
GameDLLInit()
Interaktionschema:
Projektgruppe KIMAS – Half-Life 12/26
UNIVERSITY OF
PADERBORNProgrammstruktur
Klassendiagramme
Server:http://www-math.upb.de/~tegeler/kimas/server_class_diagram.png
Client:http://www-math.upb.de/~tegeler/kimas/client_class_diagram.png
VererbungAlle Objekte stammen von CBaseEntity ab
(zu finden in cbase.cpp)
Projektgruppe KIMAS – Half-Life 13/26
UNIVERSITY OF
PADERBORNÜberblick
Half-Life
Die Half-Life Welt
Programmstruktur
Modifikationen
Bot´s
Projektgruppe KIMAS – Half-Life 14/26
UNIVERSITY OF
PADERBORNModifikationen
Modifikationen (Mod´s) sind Änderungen amSpielablauf, z.B. an:
Waffen, Monstern, GUI, Regeln, ...
Der wohl bekanntesteHalf-Life Mod´s:
Counter-Strike
Projektgruppe KIMAS – Half-Life 15/26
UNIVERSITY OF
PADERBORNModifikationen
Was benötigt man um aktuelle Half-LifeMod´s zu erstellen?
C++ Compiler (der DLL´s erstellen kann die mit den von Microsoft Visual C++ kompatibel sind, z.B. MingW32, MSVC++ 6.0, ...)
SDK 2.3 (Standart oder Full)
Half-Life 1.1.1.0
Projektgruppe KIMAS – Half-Life 16/26
UNIVERSITY OF
PADERBORNModifikationen
Geschwindigkeit der RPG:
DropXP:
Rpg.cpp (in FollowThink):...pev->velocity=pev->velocity*10; ...
Player.cpp (in DropPlayerItem):...CWeaponBox *pWeaponBox = (CWeaponBox *)CBaseEntity::Create( ..., Koordinaten , ...); ...
Projektgruppe KIMAS – Half-Life 17/26
UNIVERSITY OF
PADERBORNÜberblick
Half-Life
Die Half-Life Welt
Programmstruktur
Modifikationen
Bot´s
Projektgruppe KIMAS – Half-Life 18/26
UNIVERSITY OF
PADERBORNBot´s
Half-Life bietet keine Schnittstelle für Bot´sDeshalb Implementierung durch:
Einbettung des Bot´s in ein Mod
DLL´s ausnutzen, und eine Bot.dll zwischen die Engine und dem Server (hl.dll) zu mogeln
Projektgruppe KIMAS – Half-Life 19/26
UNIVERSITY OF
PADERBORNBot´s
Engine(Half-Life Game Executable)
Server(hl.dll /mp.dll)
Client-UI(cl_dll.dll)
GiveFnptrsToDll()
GetEntityAPI()
GameDLLInit()
Bot(bot.dll)
Interaktionschema:
Projektgruppe KIMAS – Half-Life 20/26
UNIVERSITY OF
PADERBORNBot´s
Der Bot wird mit FakeClient als virtueller Spieler erzeugt, zählt also als Spieler: Bot erzeugen
Bot steuern
BotEnt=g_engfuncs.pfnCreateFakeClient(“Bot“);...ClientConnect( BotEnt, “BotName“, “127.0.0.1“, ptr);ClientPutInServer( BotEnt);
...pfnRunPlayerMove( BotEnt , BlickRichtung, VorG, RechtsG,
HochG, Taste, Impuls, Dauer); ...
Projektgruppe KIMAS – Half-Life 21/26
UNIVERSITY OF
PADERBORNBot´s
Sicht des Bot´s am Beispiel-Code
for (i =1; i <=gpGlobals->maxClients; i++){ edict_t *pPlayer = INDEXENT(i); vec2LOS = ( pPlayer->v.origin – pEdict->v.origin).Make2D(); ... flDot = Dotproduct ( vec2LOS, gpGlobals->v.forward.Make2D() ); if ( flDot > 0.50 ) { //im Sichtfeld
UTIL_TraceLine{ ...} //Line zum Ziel
} else { ...} //ausserhalb des Sichtfelds}
Projektgruppe KIMAS – Half-Life 22/26
UNIVERSITY OF
PADERBORNBot´s
aus den Engine-Headerdatein(common\com_model.h):
es können also nur 32 Bots erzeugt werden! (bei Quake gab es keine genaue aussage)
und 900 Entities insgesamt (ca. genau soviele wie in Quake)
#define MAX_CLIENTS 32#define MAX_EDICTS 900
Projektgruppe KIMAS – Half-Life 23/26
UNIVERSITY OF
PADERBORNBot´s
Und wenn „32“ Agenten nicht genug sind?
Bot als eignende Entity programmierenKeine weitern Einschränkungengrößer Programmieraufwand
Bot als Monster programmierenevtl. Einschränkung durch das erben von
CMonster ca. genau so viel wie bei üblichen Bot
implementationen
Projektgruppe KIMAS – Half-Life 24/26
UNIVERSITY OF
PADERBORNBot´s
Unserer KimasBot:
Projektgruppe KIMAS – Half-Life 25/26
UNIVERSITY OF
PADERBORNGegenüberstellung
Funktion Quake Half-Life
Bot´s (max) ??? 32
Entities (max) 1024 900
OpenGL * *
Direct X *
Skeletal Animation System *
Rendering 8-bit 16-bit
Colored lighting *
Decal System *
Real-Time DSP *
Maps als BSP * *
Datenstruktur (Bewegung, Richtung, ...) Vektor Vektor
Ausführbare Dateien QuakeVM DLL
Kollisionserkennung Bounding-Boxes Bounding-Boxes
Projektgruppe KIMAS – Half-Life 26/26
UNIVERSITY OF
PADERBORNWeitere Informationen
Half-Life FAQ von Steve Cook:http://www.planethalflife.com/hlsdk2/sdk2_articles.htm
Half-Life programming:http://www.planethalflife.com/hlprogramming/tutorials.asp
Gamedesign and programming resources:http://www.resourcecode.de
Botman´s Homepage:
http://www.planethalflife.com/botman/
Projektgruppe KIMAS – Half-Life 27/26
UNIVERSITY OF
PADERBORNKommentare im Source Code ;-)
TOP3
3: // this is the most hacked, evil, bastardized thing I've ever seen.
2: // this is not a hack or temporary fix, this is how things should be.
1: // Huh?