本文整理汇总了C++中Die函数的典型用法代码示例。如果您正苦于以下问题:C++ Die函数的具体用法?C++ Die怎么用?C++ Die使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Die函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Die
float ABaseCharacter::TakeDamage(float Damage, struct FDamageEvent const& DamageEvent, class AController* EventInstigator, class AActor* DamageCauser)
{
if (Health > 0.f)
{
/* Modify based based on gametype rules */
//ASGameMode* MyGameMode = Cast<ASGameMode>(GetWorld()->GetAuthGameMode());
//Damage = MyGameMode ? MyGameMode->ModifyDamage(Damage, this, DamageEvent, EventInstigator, DamageCauser) : Damage;
const float ActualDamage = Super::TakeDamage(Damage, DamageEvent, EventInstigator, DamageCauser);
if (ActualDamage > 0.f)
{
Health -= ActualDamage;
if (Health <= 0)
{
bool bCanDie = true;
/* Check the damagetype, always allow dying if the cast fails, otherwise check the property if player can die from damagetype */
if (DamageEvent.DamageTypeClass)
{
UShooterDamageType* DmgType = Cast<UShooterDamageType>(DamageEvent.DamageTypeClass->GetDefaultObject());
bCanDie = (DmgType == nullptr || (DmgType && DmgType->GetCanDieFrom()));
}
if (bCanDie)
{
Die(ActualDamage, DamageEvent, EventInstigator, DamageCauser);
}
else
{
/* Player cannot die from this damage type, set hitpoints to 1.0 */
Health = 1.0f;
}
}
else
{
/* Shorthand for - if x != null pick1 else pick2 */
//APawn* Pawn = EventInstigator ? EventInstigator->GetPawn() : nullptr;
PlayHit(false, ActualDamage, DamageEvent, EventInstigator->GetPawn(), DamageCauser);
}
}
GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, FString::SanitizeFloat(Health));
return ActualDamage;
}
else
{
ApplyPhysicsToTheRagdolledBody(DamageEvent);
}
return 0;
}
示例2: TakeDamage
//=========================================================
// Special takedamage for func_breakable. Allows us to make
// exceptions that are breakable-specific
// bitsDamageType indicates the type of damage sustained ie: DMG_CRUSH
//=========================================================
int CBreakable :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType )
{
Vector vecTemp;
// if Attacker == Inflictor, the attack was a melee or other instant-hit attack.
// (that is, no actual entity projectile was involved in the attack so use the shooter's origin).
if ( pevAttacker == pevInflictor )
{
vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) );
// if a client hit the breakable with a crowbar, and breakable is crowbar-sensitive, break it now.
if ( FBitSet ( pevAttacker->flags, FL_CLIENT ) &&
FBitSet ( pev->spawnflags, SF_BREAK_CROWBAR ) && (bitsDamageType & DMG_CLUB))
flDamage = pev->health;
}
else
// an actual missile was involved.
{
vecTemp = pevInflictor->origin - ( pev->absmin + ( pev->size * 0.5 ) );
}
if (!IsBreakable())
return 0;
// Breakables take double damage from the crowbar
if ( bitsDamageType & DMG_CLUB )
flDamage *= 2;
// Boxes / glass / etc. don't take much poison damage, just the impact of the dart - consider that 10%
if ( bitsDamageType & DMG_POISON )
flDamage *= 0.1;
// this global is still used for glass and other non-monster killables, along with decals.
g_vecAttackDir = vecTemp.Normalize();
// do the damage
pev->health -= flDamage;
if (pev->health <= 0)
{
Killed( pevAttacker, GIB_NORMAL );
Die();
return 0;
}
// Make a shard noise each time func breakable is hit.
// Don't play shard noise if cbreakable actually died.
DamageSound();
return 1;
}
示例3: Die
void Projectile_Mine::OnCollideWithObject(Object* object)
{
if ((!dud) && (armTimer <= 0.0f))
{
// Mines only explode on contact with slugs
if (object->GetType() == ObjectType_Slug)
Die();
}
}
示例4: TMissile
void TMakeMissile::Move()
{
if( Age % ShotInt == 0 ) {
FOwner->Add(new TMissile(FOwner,FOwner->HeroPos.X,FOwner->HeroPos.Y,SetNum,MissileNum));
Inc(MissileNum);
FOwner->Add(new TMissile(FOwner,FOwner->HeroPos.X,FOwner->HeroPos.Y,SetNum,MissileNum));
Inc(MissileNum);
}
if( Age >= (ShotInt*((MaxLock / 2) - 1)) ) {
Die();
}
TOBJ::Move();
}
示例5: Die
void ASCharacter::KilledBy(class APawn* EventInstigator)
{
if (Role == ROLE_Authority && !bIsDying)
{
AController* Killer = nullptr;
if (EventInstigator != nullptr)
{
Killer = EventInstigator->Controller;
LastHitBy = nullptr;
}
Die(Health, FDamageEvent(UDamageType::StaticClass()), Killer, nullptr);
}
}
示例6: main
int main()
{
int parent_x, parent_y;
START:
head = (psnakeHead)malloc(sizeof(snakeHead));
head -> length = 0;
head -> row = 14;
head -> col = 14;
head -> pbody = NULL;
head -> headdirection = RIGHT;
InitSnake(head);
initscr();
raw(); /* close row buffer */
cbreak(); /* put termial to CBREAK mode */
noecho();
curs_set(FALSE); /* set cursor invisible */
keypad(stdscr,TRUE); /* recognise user's function key,F1,F2,...
display some message about title and wall */
signal(SIGALRM, StartAlarm);
getmaxyx(stdscr, parent_y, parent_x);
WINDOW *welwin = newwin(29, parent_x, 0, 0);
WINDOW *lelwin = newwin(7, parent_x, 30, 0);
if (!welwin || !lelwin) {
Die("Unable to allocate window memory\n");
}
Welcome(welwin, 29, parent_x);
int speed = Choice(lelwin);
Set_ticker(speed);
DrawWalls();
StartAlarm();
foodpos = DisplayFood(head);
while(!isfailed && chinput !='q') {
chinput = getch();
ControlSnake(chinput, head);
}
if(isfailed) {
ClearScr(LEFT_EDGE+1, RIGHT_EDGE-1, TOP_ROW+1, BUT_ROW-1); //mark
free(head -> pbody);
free(head);
head = NULL;
}
if(isrestart) {
isfailed = 0;
isrestart = 0; // clear the flag
goto START; // go to the START statement
}
endwin();
return 0;
}
示例7: IDEInit
/*
* IDEInit - set up for communication with the IDE
*/
void IDEInit( void )
{
if( !VxDPresent() ) {
Die( "WDEBUG.386 not present!" );
}
for( ;; ) {
if( VxDLink( EDITOR_LINK_NAME ) == NULL ) {
VxDConnect();
break;
}
TimeSlice();
}
} /* IDEInit */
示例8: DatabaseOpen
struct Connection* DatabaseOpen(const char* filename,
char mode)
{
struct Connection *conn = malloc(sizeof(struct Connection));
if (!conn) Die("Memory Error!", conn);
conn->db = malloc(sizeof(struct Database));
if(!conn->db) Die("Memory Error!", conn);
if(mode == 'c')
{
conn->file = fopen(filename, "w");
}
else
{
conn->file = fopen(filename, "r+");
if(conn->file) DatabaseLoad(conn);
}
if(!conn->file) Die("Failed to open the file!", conn);
return conn;
}//end of function databaseopen
示例9: Die
void ANimModCharacter::KilledBy(APawn* EventInstigator)
{
if (Role == ROLE_Authority && !bIsDying)
{
AController* Killer = NULL;
if (EventInstigator != NULL)
{
Killer = EventInstigator->Controller;
LastHitBy = NULL;
}
Die(Health, FDamageEvent(UDamageType::StaticClass()), Killer, NULL);
}
}
示例10: WinMain
int CALLBACK WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
HOOKPROC hkprcKeyboard;
static HINSTANCE hinstDll;
static HHOOK hhookKeyboard;
hinstDll = LoadLibrary("MediaKeyHook.dll");
if (!hinstDll) Die("LoadLibrary");
hkprcKeyboard = (HOOKPROC)GetProcAddress(hinstDll, "KeyboardProc");
if (!hkprcKeyboard) Die("GetProcAddress");
hhookKeyboard = SetWindowsHookEx(WH_KEYBOARD, hkprcKeyboard, hinstDll, 0);
if (!hhookKeyboard) Die("SetWindowsHookEx");
MSG msg;
while (GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
UnhookWindowsHookEx(hhookKeyboard);
return EXIT_SUCCESS;
}
示例11: assert
//-----------------------------------------------------------------------------------------------------------------------------------
void UIObject::Update(float elapsedSeconds)
{
assert(m_type != UIType::kUnSet);
BaseObject::Update(elapsedSeconds);
m_currentLifeTime += elapsedSeconds;
if (m_currentLifeTime > m_lifeTime)
{
// This UIObject has been alive for longer than its lifetime so it dies
// and will be cleared up by whatever manager is in charge of it
Die();
}
}
示例12: GetTemp
double GetTemp(long mat, long id)
{
double T, f;
/***************************************************************************/
/***** Temperature from interface ******************************************/
/* Reset values */
f = 1.0;
T = -1.0;
/* Get density factor from multi-physics interface */
IFCPoint(mat, &f, &T, id);
/* Check value */
if (T > 0.0)
return T;
/***************************************************************************/
/***** Temperature from material *******************************************/
/* Get Temperature */
if ((mat > VALID_PTR) && (RDB[mat + MATERIAL_TMS_MODE] != TMS_MODE_NONE))
{
/* Use minimum temperature */
T = RDB[mat + MATERIAL_TMS_TMIN];
/* Check with maximum */
if (T != RDB[mat + MATERIAL_TMS_TMAX])
Die(FUNCTION_NAME, "Error in temperature (%s) %E %E",
GetText(mat + MATERIAL_PTR_NAME),
RDB[mat + MATERIAL_TMS_TMAX], T);
}
else
T = 0.0;
/* Return value */
return T;
/***************************************************************************/
}
示例13: UTIL_MakeVectors
// Break when triggered
void CBreakable::BreakUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
// for a respawnable entity, ON means someone wants it to respawn- but this one's solid already.
if (m_iRespawnTime && useType == USE_ON)
return;
if ( IsBreakable() )
{
pev->angles.y = m_angle;
UTIL_MakeVectors(pev->angles);
g_vecAttackDir = gpGlobals->v_forward;
Die();
}
}
示例14: GSIWriteHeader
/* Function: GSIWriteHeader()
* Date: SRE, Wed Aug 5 10:36:02 1998 [St. Louis]
*
* Purpose: Write the first record to an open GSI file:
* "GSI" <nfiles> <nkeys>
*
* Args: fp - open file to write to.
* nfiles - number of files indexed
* nkeys - number of keys indexed
*
* Returns: void
*/
void
GSIWriteHeader(FILE *fp, int nfiles, long nkeys)
{
char key[GSI_KEYSIZE];
sqd_uint16 f1;
sqd_uint32 f2;
/* beware potential range errors!
*/
if (nfiles > SQD_UINT16_MAX) Die("GSI: nfiles out of range");
if (nkeys > SQD_UINT32_MAX) Die("GSI: nkeys out of range");
f1 = (sqd_uint16) nfiles;
f2 = (sqd_uint32) nkeys;
f1 = sre_hton16(f1);
f2 = sre_hton32(f2);
strcpy(key, "GSI");
if (fwrite(key, 1, GSI_KEYSIZE, fp) < GSI_KEYSIZE) PANIC;
if (fwrite(&f1, 2, 1, fp) < 1) PANIC;
if (fwrite(&f2, 4, 1, fp) < 1) PANIC;
return;
}
示例15: OpenDatabase
struct Connection*
OpenDatabase( const char* filename, char mode ) {
struct Connection *conn = malloc( sizeof( struct Connection ) );
if ( !conn ) {
Die( "Memory error" );
}
conn->db = malloc( sizeof( struct Database ) );
if ( !conn->db ) {
Die( "Memory error." );
}
if ( mode == 'c' ) {
conn->file = fopen( filename, "w" );
} else {
conn->file = fopen( filename, "r+" );
if ( conn->file ) {
LoadDatabase( conn );
}
}
if ( !conn->file ) {
Die( "Failed to open the file." );
}
return conn;
}