当前位置: 首页>>代码示例>>C++>>正文


C++ Die函数代码示例

本文整理汇总了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;
}
开发者ID:1992please,项目名称:Unreal_ShooterGame,代码行数:51,代码来源:BaseCharacter.cpp

示例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;
}
开发者ID:Xash3DLinux,项目名称:xash3dlinux,代码行数:56,代码来源:func_break.cpp

示例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();

	}

}
开发者ID:Tempus35,项目名称:slugs,代码行数:14,代码来源:projectile.cpp

示例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();
}
开发者ID:ukifuku,项目名称:cloudphobia_cpp,代码行数:14,代码来源:Missile.cpp

示例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);
	}
}
开发者ID:Raynaron,项目名称:EpicSurvivalGameSeries,代码行数:14,代码来源:SCharacter.cpp

示例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;
}
开发者ID:me123alsl,项目名称:GreedySnake,代码行数:50,代码来源:greedysnake.c

示例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 */
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:17,代码来源:ide.c

示例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
开发者ID:Dekuben,项目名称:cEx,代码行数:23,代码来源:ex17.c

示例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);
	}
}
开发者ID:Nimgoble,项目名称:NimMod,代码行数:14,代码来源:NimModCharacter.cpp

示例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;
}
开发者ID:horsedrowner,项目名称:MediaKeySimulator,代码行数:23,代码来源:program.cpp

示例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();
	}
}
开发者ID:AlanWills,项目名称:SpinOut_Source,代码行数:15,代码来源:UIObject.cpp

示例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;

  /***************************************************************************/
}
开发者ID:LMKerby,项目名称:SerpentCouplerII,代码行数:50,代码来源:gettemp.c

示例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();
	}
}
开发者ID:RichardRohac,项目名称:hl-amnesia-src,代码行数:15,代码来源:func_break.cpp

示例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;
}
开发者ID:iu-parfunc,项目名称:prof_apps,代码行数:35,代码来源:gsi.c

示例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;
}
开发者ID:montreal91,项目名称:workshop,代码行数:23,代码来源:ex17.c


注:本文中的Die函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。