Beispiel #1
0
func FxLifeStop(object target, proplist effect, int reason, bool temporary)
{
	if(temporary)
		return;
	
	var prt = {
		Size = 15,
		Alpha = PV_Linear(255, 0),
		Rotation = PV_Step(15, PV_Random(0, 360)),
		ForceY = GetGravity()
	};
	CreateParticle("SawbladePrt", 0, 0, PV_Random(-35, 35), PV_Random(-35, 5), 40, prt, 6);
	
	var prt2 =	{
		Size = PV_Linear(2, 0),
	    ForceY = GetGravity(),
		Stretch = PV_Speed(1000, 500),
		Rotation = PV_Direction(),
	    R = 255,
	    G = PV_Linear(128,32),
	    B = PV_Random(0, 128, 2),
	    Alpha = PV_Random(255,0,3),
		BlitMode = GFX_BLIT_Additive,
	};
	
	CreateParticle("Flash", 0, 0, PV_Random(-35, 35), PV_Random(-35, 5), 70, prt2, 20);
	
	Sound("sawblade_destroyed", false, 50);
	RemoveObject();
}
PreferredSize TBTextField::OnCalculatePreferredContentSize(const SizeConstraints &constraints)
{
	PreferredSize ps;
	if (m_cached_text_width == UPDATE_TEXT_WIDTH_CACHE)
		m_cached_text_width = m_text.GetWidth(this);
	ps.pref_w = m_cached_text_width;
	ps.pref_h = ps.min_h = m_text.GetHeight(this);
	// If gravity pull both up and down, use default max_h (grow as much as possible).
	// Otherwise it makes sense to only accept one line height.
	if (!((GetGravity() & WIDGET_GRAVITY_TOP) && (GetGravity() & WIDGET_GRAVITY_BOTTOM)))
		ps.max_h = ps.pref_h;
	if (!m_squeezable)
		ps.min_w = ps.pref_w;
	return ps;
}
Beispiel #3
0
void Physics::Serialize(Properties* prop)
{
	Subsystem::Serialize(prop);

	vec3 grav {0.0f};

	if(prop->mode == Properties::Mode::Output)
		grav = GetGravity();

	prop->Value("gravity", &grav);

	if(prop->mode == Properties::Mode::Input)
		SetGravity(grav);

	auto add_pt_func = [](GravPoint& gp, Properties* prop)
	{
		prop->Value("name", &gp.name);
		prop->Value("force", &gp.force);
	};
	prop->ValueArray<GravPoint>("gravityPoint", gravityPoints, add_pt_func);

/*	Properties* gravPts = prop->Child("gravityPoints", "");
	if(gravPts)
	{
		for(auto& pgpt : gravPts->children)
		{
			GravPoint* gpt = new GravPoint;
			pgpt->Value("name", gpt->name);
			pgpt->Value("force", gpt->force);
			gravityPoints.push_back(*gpt);
		}
	}*/
}
void CEmiter::Initialize(CEntity *pen)
{
  em_vG=GetGravity(pen);
  em_bInitialized=TRUE;
  em_tmStart=_pTimer->CurrentTick();
  em_iGlobal=0;
}
void CCharacterController::PlayerFall(btCollisionWorld* pCollisionWorld, btScalar dt)
{
	Vector vecCurrentVelocity = m_hEntity->GetLocalVelocity();
	vecCurrentVelocity += ToTVector(GetGravity()) * dt;
	m_hEntity->SetLocalVelocity(vecCurrentVelocity);

	btVector3 vecVelocity = ToBTVector(vecCurrentVelocity);

	if (m_vecMoveVelocity.length2())
	{
		btVector3 vecAllowedMoveVelocity = PerpendicularComponent(m_vecMoveVelocity, GetUpVector());
		if (vecAllowedMoveVelocity.dot(vecVelocity) < 0)
			vecVelocity = PerpendicularComponent(vecVelocity, vecAllowedMoveVelocity.normalized());

		vecVelocity += vecAllowedMoveVelocity * dt;
	}

	if (vecVelocity.length2() > m_flMaxSpeed*m_flMaxSpeed)
		vecVelocity = vecVelocity.normalized() * m_flMaxSpeed;

	if (vecVelocity.length2() < 0.001f)
		return;

	btTransform mWorld;
	mWorld = m_pGhostObject->getWorldTransform();

	btVector3 vecOriginalPosition = mWorld.getOrigin();

	StepForwardAndStrafe(pCollisionWorld, vecVelocity * dt);
}
Beispiel #6
0
func FxParticlesStop(object target, proplist effect, int reason, bool temporary)
{
	if(temporary)
		return;

	SetSolidMask();
	
	var props = 
	{
		Size = PV_Linear(4, 0),
	    ForceY = GetGravity(),
		Stretch = PV_Speed(1000, 500),
		Rotation = PV_Direction(),
		OnCollision = PC_Die(),
		CollisionVertex = 0,
	    R = 100,
	    G = 100,
	    B = 100,
		BlitMode = GFX_BLIT_Additive,
	};
	CreateParticle("Smoke", 0, 0, PV_Random(-10 , 10), PV_Random(-10, 20), 50, props, 10);
	
	var smoke = 
	{
		ForceX = PV_Wind(200 - 180),
		DampingX = 900, DampingY = 900,
		Alpha = PV_Linear(255, 0),
		R = 100, G = 100, B = 100,
		Size = PV_Linear(PV_Random(4, 10), PV_Random(20, 30)),
		Phase = PV_Random(0, 15)
	};
	CreateParticle("Smoke", PV_Random(-5,5), PV_Random(-5,5), PV_Random(-15, 15), PV_Random(-15, 15), 30, smoke, 15);
}
Beispiel #7
0
void BombObject::UpdateUI(TimeValue t)
	{
	if (hParam && !waitPostLoad) {
      if (this == DLGetWindowLongPtr<BombObject *>(hParam)) {
			strengthSpin->SetValue(GetStrength(t),FALSE);
			gravSpin->SetValue(GetGravity(t),FALSE);
			chaosSpin->SetValue(GetChaos(t),FALSE);			
			falloffSpin->SetValue(GetFalloff(t),FALSE);
			spinSpin->SetValue(GetSpin(t),FALSE);

			if (pblock->KeyFrameAtTime(PB_STRENGTH,t))
				 strengthSpin->SetKeyBrackets(TRUE);
			else strengthSpin->SetKeyBrackets(FALSE);

			if (pblock->KeyFrameAtTime(PB_GRAVITY,t))
				 gravSpin->SetKeyBrackets(TRUE);
			else gravSpin->SetKeyBrackets(FALSE);

			if (pblock->KeyFrameAtTime(PB_CHAOS,t))
				 chaosSpin->SetKeyBrackets(TRUE);
			else chaosSpin->SetKeyBrackets(FALSE);

			if (pblock->KeyFrameAtTime(PB_SPIN,t))
				 spinSpin->SetKeyBrackets(TRUE);
			else spinSpin->SetKeyBrackets(FALSE);

			if (pblock->KeyFrameAtTime(PB_FALLOFF,t))
				 falloffSpin->SetKeyBrackets(TRUE);
			else falloffSpin->SetKeyBrackets(FALSE);
			}
		}
	}
Beispiel #8
0
void CParticleSystem::Update(const float dt, const uint32_t ticks, const vec3_t& ownerpos)
{
    const float gravity = GetGravity();

    std::vector<particle_t>::iterator iter;
    for(iter = m_particles.begin();iter != m_particles.end(); ++iter)
    {
        if(iter->lifetime < 0.0f)
        {
            if(iter->respawn)
            {
                InitParticle(*iter, ownerpos);
            }
            else
            {
                continue;
            }
        }

        iter->origin = iter->origin + iter->vel*dt - vec3_t(0,dt*dt*0.5f*gravity,0);
        iter->vel.y -= gravity*dt;
        iter->lifetime -= dt;
        const float f = iter->lifetime / iter->totallifetime;
        const float scale = sin(f * lynxmath::PI);
        iter->alpha = iter->startalpha * scale;
        iter->size = scale * iter->startsize + 0.1f;
    }
}
Beispiel #9
0
public func Activate(caster, real_caster) {
  // Zaubernden Clonk ermitteln
  var clonk = caster;
  if (real_caster) clonk = real_caster;
  // Kombiniert mit Beton -> Clonk in den Boden stecken
  var obj;
  if (!Contained(clonk) && (obj = FindContents(CNCR, clonk))) {
    var height = GetDefCoreVal("Height", "DefCore", GetID(clonk));
    var radius = RandomX(25, 35);
    var x = GetX(clonk);
    var y = GetY(clonk);
    // Unter dem Clonk freischütteln und buddeln
    DigFree(x, y+height+radius, height/2);
    ShakeFree(x, y+height+(radius/2), radius);
    // Tiefstes freigeschüttelte Y-Position ermitteln
    while (!GBackSolid(AbsX(x), AbsY(y++ + height))) {}
    // Effekte!
    DrawParticleLine("MSpark",
      0, 0, 0, AbsY(y),
      height*3/2, height*5/2,
      RGBa(255-Random(50),255-Random(50), 0,128),
      RGBa(155-Random(50),155-Random(50), 0,128),
      -10);
    // Zauberer an ermittelte Stelle versetzen
    SetPosition(x, y, clonk);
    // Objekt entfernen
    RemoveObject(obj);
  }
  // Sonst normale Wirkung (Gravitation erhöhen)
  else {
    // Gravitation bereits auf Maximum?
    if (GetGravity() >= 290)
      return(0, Message("$MsgAlreadyMaxed$", caster), RemoveObject());
    // Sonst erhöhen
    // Effekt global starten
    if (!AddEffect("GravChangeUSpell", 0, 150, 80, 0, MGDW, 20))
      return(0, RemoveObject());
    Message("$MsgRaised$", caster, GetGravity());
  }
  Sound("Magic1");
  RemoveObject();
  return(1);
}
//-----------------------------------------------------------------------------
// Purpose: Monitor the alien's jump to play the proper landing sequence
//-----------------------------------------------------------------------------
bool CAI_ASW_JumpBehavior::CheckLanding( void )
{
    trace_t	tr;
    Vector	testPos;

    //Amount of time to predict forward
    const float	timeStep = 0.1f;

    //Roughly looks one second into the future
    testPos = GetAbsOrigin() + ( GetOuter()->GetAbsVelocity() * timeStep );
    testPos[2] -= ( 0.5 * sv_gravity.GetFloat() * GetGravity() * timeStep * timeStep);

    if ( asw_debug_jump_behavior.GetInt() == 2 )
    {
        NDebugOverlay::Line( GetAbsOrigin(), testPos, 255, 0, 0, 0, 0.5f );
        NDebugOverlay::Cross3D( m_vecSavedJump, -Vector(2,2,2), Vector(2,2,2), 0, 255, 0, true, 0.5f );
    }

    // Look below
    AI_TraceHull( GetAbsOrigin(), testPos, NAI_Hull::Mins( GetHullType() ), NAI_Hull::Maxs( GetHullType() ), GetOuter()->GetAITraceMask(), GetOuter(), COLLISION_GROUP_NONE, &tr );

    //See if we're about to contact, or have already contacted the ground
    if ( ( tr.fraction != 1.0f ) || ( GetOuter()->GetFlags() & FL_ONGROUND ) )
    {
        int	sequence = GetOuter()->SelectWeightedSequence( (Activity)ACT_ALIEN_LAND );
        if ( GetSequence() != sequence )
        {
            CASW_Alien *pNPC = static_cast< CASW_Alien * >( GetOuter() );

            pNPC->VacateStrategySlot();
            pNPC->SetIdealActivity( (Activity) ACT_ALIEN_LAND );
            //pNPC->Land();

            if ( GetEnemy() && GetEnemy()->IsPlayer()  )
            {
                CBasePlayer *pPlayer = ToBasePlayer( GetEnemy() );

                if ( pPlayer && pPlayer->IsInAVehicle() == false )
                {
                    //pNPC->MeleeAttack( m_flDamageDistance, m_flJumpDamage, QAngle( 4.0f, 0.0f, 0.0f ), Vector( -250.0f, 1.0f, 1.0f ) );
                }
            }

            GetOuter()->SetAbsVelocity( GetOuter()->GetAbsVelocity() * 0.33f );
            return false;
        }

        return GetOuter()->IsActivityFinished();
    }

    return false;
}
Beispiel #11
0
// Purpose: Monitor the antlion's jump to play the proper landing sequence
bool CASW_Alien_Jumper::CheckLanding( void )
{
	trace_t	tr;
	Vector	testPos;

	//Amount of time to predict forward
	const float	timeStep = 0.1f;

	//Roughly looks one second into the future
	testPos = GetAbsOrigin() + ( GetAbsVelocity() * timeStep );
	testPos[2] -= ( 0.5 * sv_gravity.GetFloat() * GetGravity() * timeStep * timeStep);

	if ( asw_debug_aliens.GetInt() == 2 )
	{
		NDebugOverlay::Line( GetAbsOrigin(), testPos, 255, 0, 0, 0, 0.5f );
		NDebugOverlay::Cross3D( m_vecSavedJump, -Vector(2,2,2), Vector(2,2,2), 0, 255, 0, true, 0.5f );
	} 
	
	// Look below
	AI_TraceHull( GetAbsOrigin(), testPos, NAI_Hull::Mins( GetHullType() ), NAI_Hull::Maxs( GetHullType() ), MASK_NPCSOLID, this, COLLISION_GROUP_NONE, &tr );

	//See if we're about to contact, or have already contacted the ground
	if ( ( tr.fraction != 1.0f ) || ( GetFlags() & FL_ONGROUND ) )
	{
		int	sequence = SelectWeightedSequence( (Activity)ACT_ASW_ALIEN_LAND );

		if ( GetSequence() != sequence )
		{
			VacateStrategySlot();
			SetIdealActivity( (Activity) ACT_ASW_ALIEN_LAND );

			CreateDust( false );
			EmitSound( "ASW_Drone.Land" );

			// asw todo: make the alien attack here?
			//if ( GetEnemy() && GetEnemy()->IsPlayer()  )
			//{
				//CBasePlayer *pPlayer = ToBasePlayer( GetEnemy() );

				//if ( pPlayer && pPlayer->IsInAVehicle() == false )
					 //MeleeAttack( ANTLION_MELEE1_RANGE, sk_antlion_swipe_damage.GetFloat(), QAngle( 4.0f, 0.0f, 0.0f ), Vector( -250.0f, 1.0f, 1.0f ) );
			//}

			SetAbsVelocity( GetAbsVelocity() * 0.33f );
			return false;
		}

		return IsActivityFinished();
	}

	return false;
}
Beispiel #12
0
Interval BombObject::ObjectValidity(TimeValue time) 
	{	
	Interval ivalid = FOREVER;
	if (!waitPostLoad) {
		GetStrength(time,ivalid);
		GetGravity(time,ivalid);	
		GetFalloff(time,ivalid);
		GetChaos(time,ivalid);
		GetSpin(time,ivalid);
		UpdateUI(time);
		}
	return ivalid;	
	}
Beispiel #13
0
func Initialize()
{
	chargeprt =
	{
		Size = 5,
		Alpha = PV_Linear(255, 0),
		R = 150,
		G = 150,
		B = 150,
		ForceY = GetGravity(),
		Stretch = PV_Linear(1500, 1500),
		Rotation = PV_Step(10, PV_Random(0, 360), 1),
		OnCollision = PC_Bounce(),
	};
	snapped = false;
	
	
}
void vpSiloWorld::UserInputFun(unsigned char dir)
{
	switch ( dir )
	{
	case 0x1B : // escape
		exit(0);
		break;
	case ' ':	// drop sphere
		ReleaseRoof();
		break;
	case 'r':
		RollbackState();
		break;
	case 't':
		SetGravity(-1.0 * GetGravity());
		break;
	}
}
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
void CNPC_Launcher::LaunchGrenade( CBaseEntity* pEnemy )
{
	// If a path following missile, create a path following missile
	if (m_sPathCornerName != NULL_STRING)
	{
		CGrenadePathfollower *pGrenade = CGrenadePathfollower::CreateGrenadePathfollower( m_sMissileModel, m_sFlySound,  GetAbsOrigin(), vec3_angle, edict() );
		pGrenade->SetDamage(m_flDamage);
		pGrenade->SetDamageRadius(m_flDamageRadius);
		pGrenade->Launch(m_flLaunchSpeed,m_sPathCornerName);
	}
	else
	{
		Vector vUp;
		AngleVectors( GetAbsAngles(), NULL, NULL, &vUp );
		Vector vLaunchVelocity = (vUp * m_flLaunchSpeed);

		CGrenadeHomer *pGrenade = CGrenadeHomer::CreateGrenadeHomer( m_sMissileModel, m_sFlySound,  GetAbsOrigin(), vec3_angle, edict() );
		pGrenade->Spawn( );
		pGrenade->SetSpin(m_flSpinMagnitude,m_flSpinSpeed);
		pGrenade->SetHoming((0.01*m_nHomingStrength),m_flHomingDelay,m_flHomingRampUp,m_flHomingDuration,m_flHomingRampDown);
		pGrenade->SetDamage(m_flDamage);
		pGrenade->SetDamageRadius(m_flDamageRadius);
		pGrenade->Launch(this,pEnemy,vLaunchVelocity,m_flHomingSpeed,GetGravity(),m_nSmokeTrail);
	}

	CPASAttenuationFilter filter( this, 0.3 );

	EmitSound_t ep;
	ep.m_nChannel = CHAN_WEAPON;
	ep.m_pSoundName = STRING(m_sLaunchSound);
	ep.m_SoundLevel = SNDLVL_NORM;

	EmitSound( filter, entindex(), ep );

	if (m_bSmokeLaunch)
	{
		UTIL_Smoke(GetAbsOrigin(), random->RandomInt(20,30), random->RandomInt(10,15));
	}
	m_flNextAttack = gpGlobals->curtime + LAUNCHER_REST_TIME;

}
Beispiel #16
0
void BombObject::BeginEditParams(IObjParam *ip,ULONG flags,Animatable *prev)
	{
	this->ip = ip;
	
	if (!hParam) {
		hSot = ip->AddRollupPage( 
				hInstance, 
				MAKEINTRESOURCE(IDD_BOMB_SOT),
				DefaultSOTProc,
				GetString(IDS_RB_SOT), 
				(LPARAM)ip,APPENDROLL_CLOSED);

		hParam = ip->AddRollupPage( 
				hInstance, 
				MAKEINTRESOURCE(IDD_BOMBPARAMS),
				BombParamProc,
				GetString(IDS_RB_BOMBPARAMS), 
				(LPARAM)this );
	} else {
      DLSetWindowLongPtr(hParam, this);      

		// Init the dialog to our values.
		strengthSpin->SetValue(GetStrength(ip->GetTime()),FALSE);
		gravSpin->SetValue(GetGravity(ip->GetTime()),FALSE );
		chaosSpin->SetValue(GetChaos(ip->GetTime()),FALSE );
		detSpin->SetValue(GetDetonation(ip->GetTime()),FALSE );
		spinSpin->SetValue(GetSpin(ip->GetTime()),FALSE);
		falloffSpin->SetValue(GetFalloff(ip->GetTime()),FALSE);
		minFragSpin->SetValue(GetMinFrag(ip->GetTime()),FALSE);
		maxFragSpin->SetValue(GetMaxFrag(ip->GetTime()),FALSE);
		seedSpin->SetValue(GetSeed(ip->GetTime()),FALSE);
		CheckDlgButton(hParam,IDC_FALLOFF_ON,GetFalloffOn(ip->GetTime()));
		}

	if (GetFalloffOn(ip->GetTime())) {
		NotifyDependents(FOREVER,0,REFMSG_CHANGE);
		ip->RedrawViews(ip->GetTime());
		}
	}
Beispiel #17
0
global func FxSmokeTrailTimer(object pTarget, int iEffectNumber, int iEffectTime)
{
  var iStrength = EffectVar(0, pTarget, iEffectNumber);
  var iAStr = EffectVar(1, pTarget, iEffectNumber);
  var iX = EffectVar(2, pTarget, iEffectNumber);
  var iY = EffectVar(3, pTarget, iEffectNumber);
  var iXDir = EffectVar(4, pTarget, iEffectNumber);
  var iYDir = EffectVar(5, pTarget, iEffectNumber);

  iAStr = Max(1,iAStr-iAStr/10+Random(2));
  iAStr--;
  iYDir += GetGravity()*2/3;
  iYDir += GetWind(iX,iY)/20;

  var xdir = iXDir*iAStr/iStrength;
  var ydir = iYDir*iAStr/iStrength;

  // Neu: Random
  iX += RandomX(-3,3);
  iY += RandomX(-3,3);
  
  // zuerst zeichnen
  CreateParticle("Smoke3",iX,iY,RandomX(-2,2),RandomX(-2,2)-3,20+iAStr*8,RGBa(128,128,128,55+35*iAStr/iStrength));
  CreateParticle("Blast",iX,iY,0,0,10+iAStr*8,RGBa(250,100+Random(100),100,160));

  // dann nächste position berechnen
  iX += xdir/100;
  iY += ydir/100;
  
  if(GBackSemiSolid(iX,iY))
    return -1;
  if(iAStr <= 1)
    return -1;
    
  EffectVar(1, pTarget, iEffectNumber) = iAStr;
  EffectVar(2, pTarget, iEffectNumber) = iX;
  EffectVar(3, pTarget, iEffectNumber) = iY;
  EffectVar(5, pTarget, iEffectNumber) = iYDir;
}
Beispiel #18
0
int ms_update() {
	if (!dmpReady) {
		printf("Error: DMP not ready!!\n");
		return -1;
	}

	while (dmp_read_fifo(g,a,_q,&sensors,&fifoCount)!=0); //gyro and accel can be null because of being disabled in the efeatures
	q = _q;
	GetGravity(&gravity, &q);
	GetYawPitchRoll(ypr, &q, &gravity);

	mpu_get_temperature(&t);
	temp=(float)t/65536L;

	mpu_get_compass_reg(c);

	//scaling for degrees output
	for (int i=0;i<DIM;i++){
		ypr[i]*=180/M_PI;
	}

	//unwrap yaw when it reaches 180
	ypr[0] = wrap_180(ypr[0]);

	//change sign of Pitch, MPU is attached upside down
	ypr[1]*=-1.0;

	//0=gyroX, 1=gyroY, 2=gyroZ
	//swapped to match Yaw,Pitch,Roll
	//Scaled from deg/s to get tr/s
	for (int i=0;i<DIM;i++){
		gyro[i]   = (float)(g[DIM-i-1])/131.0/360.0;
		accel[i]   = (float)(a[DIM-i-1]);
		compass[i] = (float)(c[DIM-i-1]);
	}

	return 0;
}
Beispiel #19
0
void Quaternion::GetYawPitchRoll(FloatVectorStruct& ypr) {
	FloatVectorStruct gravity;
	GetGravity(ypr,*this);
	GetYawPitchRoll(*this,gravity,ypr);
}
Beispiel #20
0
func GetRopeGravity()
{
	return GetGravity()*Rope_Precision/100;
}
Beispiel #21
0
void EngineActions::DuplicateEntity( ECS::Entity* p_entity )
{
	//Create new entity
	ECS::Entity* newEntity = CreateEntity();
	//Set position, scale and rotation of new entity to same as old entity + a little offset in X (to avoid clipping and confusion)
	SetPosition(newEntity, GetPosition(p_entity) + glm::vec3(10, 0, 0));
	SetOrientation(newEntity, GetOrientation(p_entity));
	SetScale(newEntity, GetScale(p_entity));

	//Get all components
	RootForce::Renderable*		renderable		= m_world->GetEntityManager()->GetComponent<RootForce::Renderable>(p_entity);
	RootForce::Physics*			physics			= m_world->GetEntityManager()->GetComponent<RootForce::Physics>(p_entity);
	RootForce::Collision*		collision		= m_world->GetEntityManager()->GetComponent<RootForce::Collision>(p_entity);
	RootForce::Script*			script			= m_world->GetEntityManager()->GetComponent<RootForce::Script>(p_entity);
	RootForce::WaterCollider*	watercollider	= m_world->GetEntityManager()->GetComponent<RootForce::WaterCollider>(p_entity);
	RootForce::ParticleEmitter* particleEmitter = m_world->GetEntityManager()->GetComponent<RootForce::ParticleEmitter>(p_entity);

	//Check if there's a renderable and copy data
	if(renderable != nullptr)
	{
		AddRenderable(newEntity);
		SetRenderableModelName(newEntity, GetRenderableModelName(p_entity));
		SetRenderableMaterialName(newEntity, GetRenderableMaterialName(p_entity));
	}

	//Check if there's a renderable and copy data
	if(collision != nullptr)
	{
		if(physics != nullptr)
		{
			AddPhysics(newEntity, true);
			SetMass(newEntity, GetMass(p_entity));
		}
		else
			AddPhysics(newEntity, false);

		SetPhysicsType(newEntity, GetPhysicsType(p_entity));
		SetPhysicsShape(newEntity, GetPhysicsShape(p_entity));
		SetShapeHeight(newEntity, GetShapeHeight(p_entity));
		SetShapeRadius(newEntity, GetShapeRadius(p_entity));
		SetPhysicsMesh(newEntity, GetPhysicsMesh(p_entity));
		SetCollideWithStatic(newEntity, GetCollideWithStatic(p_entity));
		SetCollideWithWorld(newEntity, GetCollideWithWorld(p_entity));
		SetGravity(newEntity, GetGravity(p_entity));	
	}

	//Check if there's a script and copy data
	if(script != nullptr)
	{
		AddScript(newEntity);
		SetScript(newEntity, GetScript(p_entity));
	}

	//Check if there's a water collider and copy data
	if(watercollider != nullptr)
	{
		AddWaterCollider(newEntity);
		SetWaterColliderInterval(newEntity, GetWaterColliderInterval(p_entity));
		SetWaterColliderPower(newEntity, GetWaterColliderPower(p_entity));
		SetWaterColliderRadius(newEntity, GetWaterColliderRadius(p_entity));
	}

	if(particleEmitter != nullptr)
	{
		AddParticle(newEntity);
		SetParticleEmitter(newEntity, GetParticleEmitter(p_entity));
	}
}
Beispiel #22
0
void CDHLProjectile::PhysicsSimulate( void )
{
	//-------------------------------------------------------------------------------
	//Our own movement/physics simulation!
	//-------------------------------------------------------------------------------
	#ifdef CLIENT_DLL
		if ( m_bCollided )
			return;

		if ( !m_pShooter && m_hShooter )
			m_pShooter = m_hShooter.Get();
	#else
		if ( m_flRemoveAt > 0.0f )
		{
			if ( m_flRemoveAt < gpGlobals->curtime )
			{
				m_flRemoveAt = 0.0f;
				SUB_Remove();
			}
			return;
		}
		if ( IsMarkedForDeletion() )
			return;
	#endif

	float flFrametime = gpGlobals->frametime;
	//Scale for slow motion
	if ( DHLRules() )
	{
		if ( (m_iType == DHL_PROJECTILE_TYPE_BULLET || m_iType == DHL_PROJECTILE_TYPE_PELLET) )
			flFrametime *= (dhl_bulletspeed.GetFloat() * DHLRules()->GetTimescale());
		else if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
			flFrametime *= (dhl_knifespeed.GetFloat() * DHLRules()->GetTimescale());
		else
			flFrametime *= DHLRules()->GetTimescale();
	}

	Vector vecDir = vec3_origin;
#ifndef CLIENT_DLL
	Vector vecStartPos = m_vecCurPosition; //This is where we are
	Vector vecEndPos = m_vecCurPosition; //This is where we're going
	Vector vecVelocity = m_vecCurVelocity; //Velocity
#else
	Vector vecStartPos = GetLocalOrigin(); //This is where we are
	Vector vecEndPos = GetLocalOrigin(); //This is where we're going
	Vector vecVelocity = GetLocalVelocity(); //Velocity
#endif
	//Find out where we should move to
	if ( vecVelocity != vec3_origin )
	{
		static ConVarRef gravVar( "sv_gravity" );
		//Gravity
		float newZVelocity = vecVelocity.z - ( flFrametime * gravVar.GetFloat() * GetGravity() );
		vecVelocity.z = ( (vecVelocity.z + newZVelocity) / 2 );

		vecDir = vecVelocity;
		VectorNormalize( vecDir );

		//Gravity needs to be cumulative
		#ifndef CLIENT_DLL
			m_vecCurVelocity = vecVelocity;
		#else
			SetLocalVelocity( vecVelocity );
		#endif
		vecVelocity *= flFrametime;
		vecEndPos = vecStartPos + vecVelocity;
		if ( vecEndPos.IsValid() )
		{
			CTraceFilterSkipTwoEntities movetrfilter( this, m_pShooter, COLLISION_GROUP_NONE );
			trace_t movetr;
			UTIL_TraceLine( vecStartPos, vecEndPos, MASK_SHOT, &movetrfilter, &movetr );

			#ifndef CLIENT_DLL
				//Trace to triggers so we can hit surf glass and such
				CTakeDamageInfo	triggerInfo( this, GetOwnerEntity(), m_iDamage, DMG_BULLET );
				if ( m_iType == DHL_PROJECTILE_TYPE_COMBATKNIFE )
				{
					//CalculateMeleeDamageForce( &triggerInfo, vecDir, movetr.endpos, 0.7f );
					Vector vecForce = vecDir;
					VectorNormalize( vecForce );
					//vecForce *= 10.0f;
					triggerInfo.SetDamageForce( vecForce );
				}
				else
					CalculateBulletDamageForce( &triggerInfo, m_iAmmoType, vecDir, movetr.endpos, 1.0f );
				triggerInfo.SetDamagePosition( movetr.endpos );
				TraceAttackToTriggers( triggerInfo, movetr.startpos, movetr.endpos, vecDir );
			#else
				//Hit ragdolls on the client
				CBaseEntity* pEnt = DHL_FX_AffectRagdolls( movetr.endpos, movetr.startpos, DMG_BULLET, &m_RagdollHitList );

				//Keep track of ones we've hit
				if ( pEnt )
					m_RagdollHitList.AddToTail( pEnt );
			#endif

			if ( movetr.DidHit() )
				if ( OnTouch( movetr, false, &movetrfilter ) )
					return;
			
			MoveProjectileToPosition( vecEndPos );
			m_flDistanceTravelled += vecEndPos.DistTo( vecStartPos );

			#ifndef CLIENT_DLL
				//On rare occasions the projectile likes to fly right through the world and keep going forever, causing a memory leak
				if ( m_flDistanceTravelled > MAX_TRACE_LENGTH )
				{
					SUB_Remove();
					//SetThink( &CDHLProjectile::SUB_Remove );
					//SetNextThink( gpGlobals->curtime + 0.1 );
				}
			#endif

		}

		//Simulate Angles
		//QAngle angles;
		#ifdef CLIENT_DLL
			QAngle angles = GetLocalAngles();
			//VectorAngles( vecDir, angles );
			//angles.z = GetLocalAngles().z; //Vector conversion loses z
			QAngle angVel = GetLocalAngularVelocity();
			angles += angVel * flFrametime;
			SetLocalAngles( angles );
			SetNetworkAngles( angles );
		#endif
	}
}
//------------------------------------------------------------------------------
// Purpose : Move toward targetmap 
// Input   :
// Output  :
//------------------------------------------------------------------------------
void CGrenadeHomer::AimThink( void )
{ 
	// Blow up the missile if we have an explicit detonate time that
	// has been reached
	if (m_flDetonateTime != 0 &&
		gpGlobals->curtime > m_flDetonateTime)
	{
		Detonate();
		return;
	}

	PlayFlySound();

	Vector		vTargetPos	= vec3_origin;
	Vector		vTargetDir;
	float		flCurHomingStrength = 0;

	// ------------------------------------------------
	//  If I'm homing
	// ------------------------------------------------
	if (m_hTarget != NULL)
	{
		vTargetPos		= m_hTarget->EyePosition();
		vTargetDir		= vTargetPos - GetAbsOrigin();
		VectorNormalize(vTargetDir);

		// --------------------------------------------------
		//  If my target is far away do some primitive
		//  obstacle avoidance
		// --------------------------------------------------
		if ((vTargetPos - GetAbsOrigin()).Length() > 200)
		{
			Vector  vTravelDir	= GetAbsVelocity();
			VectorNormalize(vTravelDir);
			vTravelDir *= 50;

			trace_t tr;
			UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() + vTravelDir, MASK_SHOT, m_hTarget, COLLISION_GROUP_NONE, &tr );
			if (tr.fraction != 1.0)
			{
				// Head off in normal 
				float dotPr			=  DotProduct(vTravelDir,tr.plane.normal);
				Vector vBounce		=  -dotPr * tr.plane.normal;
				vBounce.z			=  0;
				VectorNormalize(vBounce);
				vTargetDir			+= vBounce;
				VectorNormalize(vTargetDir);
				// DEBUG TOOL
				//NDebugOverlay::Line(GetOrigin(), GetOrigin()+vTravelDir, 255,0,0, true, 20);
				//NDebugOverlay::Line(GetOrigin(), GetOrigin()+(12*tr.plane.normal), 0,0,255, true, 20);
				//NDebugOverlay::Line(GetOrigin(), GetOrigin()+(vTargetDir), 0,255,0, true, 20);
			}
		}

		float	flTargetSpeed					= GetAbsVelocity().Length();
		float	flHomingRampUpStartTime			= m_flHomingLaunchTime		+ m_flHomingDelay;
		float	flHomingSustainStartTime		= flHomingRampUpStartTime	+ m_flHomingRampUp;
		float	flHomingRampDownStartTime		= flHomingSustainStartTime	+ m_flHomingDuration;
		float	flHomingEndHomingTime			= flHomingRampDownStartTime + m_flHomingRampDown;
		// ---------
		// Delay
		// ---------
		if		(gpGlobals->curtime < flHomingRampUpStartTime)
		{
			flCurHomingStrength = 0;
			flTargetSpeed		= 0;
		}
		// ----------
		//  Ramp Up
		// ----------
		else if (gpGlobals->curtime < flHomingSustainStartTime)
		{
			float flAge			= gpGlobals->curtime - flHomingRampUpStartTime;
			flCurHomingStrength = m_flHomingStrength * (flAge/m_flHomingRampUp);
			flTargetSpeed		= flCurHomingStrength * m_flHomingSpeed;
		}
		// ----------
		//  Sustain
		// ----------
		else if (gpGlobals->curtime < flHomingRampDownStartTime)
		{
			flCurHomingStrength = m_flHomingStrength;
			flTargetSpeed		= m_flHomingSpeed;
		}
		// -----------
		//  Ramp Down
		// -----------
		else if (gpGlobals->curtime < flHomingEndHomingTime)
		{
			float flAge			= gpGlobals->curtime - flHomingRampDownStartTime;
			flCurHomingStrength = m_flHomingStrength * (1-(flAge/m_flHomingRampDown));
			flTargetSpeed		= m_flHomingSpeed;
		}
		// ---------------
		//  Set Homing
		// ---------------
		if (flCurHomingStrength > 0)
		{	
			// -------------
			// Smoke trail.
			// -------------
			if (m_nRocketTrailType == HOMER_SMOKE_TRAIL_ON_HOMING)
			{
				UpdateRocketTrail(flCurHomingStrength);
			}

			// Extract speed and direction
			Vector	vCurDir		= GetAbsVelocity();
			float flCurSpeed = VectorNormalize(vCurDir);
			flTargetSpeed = MAX(flTargetSpeed, flCurSpeed);

			// Add in homing direction
			Vector vecNewVelocity = GetAbsVelocity();
			float flTimeToUse = gpGlobals->frametime;
			while (flTimeToUse > 0)
			{
				vecNewVelocity = (flCurHomingStrength * vTargetDir) + ((1 - flCurHomingStrength) * vCurDir);
				flTimeToUse = -0.1;
			}
			VectorNormalize(vecNewVelocity);
			vecNewVelocity *= flTargetSpeed;
			SetAbsVelocity( vecNewVelocity );
		}
	}
	
	// ----------------------------------------------------------------------------------------
	// Add time-coherent noise to the current velocity 
	// ----------------------------------------------------------------------------------------
	Vector vecImpulse( 0, 0, 0 );
	if (m_flSpinMagnitude > 0)
	{
		vecImpulse.x += m_flSpinMagnitude*sin(m_flSpinSpeed * gpGlobals->curtime + m_flSpinOffset);
		vecImpulse.y += m_flSpinMagnitude*cos(m_flSpinSpeed * gpGlobals->curtime + m_flSpinOffset);
		vecImpulse.z -= m_flSpinMagnitude*cos(m_flSpinSpeed * gpGlobals->curtime + m_flSpinOffset);
	}

	// Add in gravity
	vecImpulse.z -= GetGravity() * GetCurrentGravity() * gpGlobals->frametime;
	ApplyAbsVelocityImpulse( vecImpulse );

	QAngle angles;
	VectorAngles( GetAbsVelocity(), angles );
	SetLocalAngles( angles );

#if 0 // BUBBLE
	if( gpGlobals->curtime > m_flNextWarnTime )
	{
		// Make a bubble of warning sound in front of me.
		const float WARN_INTERVAL = 0.25f;
		float flSpeed = GetAbsVelocity().Length();
		Vector vecWarnLocation;

		// warn a little bit ahead of us, please.
		vecWarnLocation = GetAbsOrigin() + GetAbsVelocity() * 0.75;

		// Make a bubble of warning ahead of the missile.
		CSoundEnt::InsertSound ( SOUND_DANGER, vecWarnLocation, flSpeed * WARN_INTERVAL, 0.5 );

#if 0
		Vector vecRight, vecForward;

		AngleVectors( GetAbsAngles(), &vecForward, &vecRight, NULL );

		NDebugOverlay::Line( vecWarnLocation, vecWarnLocation + vecForward * flSpeed * WARN_INTERVAL * 0.5, 255,255,0, true, 10);
		NDebugOverlay::Line( vecWarnLocation, vecWarnLocation - vecForward * flSpeed * WARN_INTERVAL * 0.5, 255,255,0, true, 10);

		NDebugOverlay::Line( vecWarnLocation, vecWarnLocation + vecRight * flSpeed * WARN_INTERVAL * 0.5, 255,255,0, true, 10);
		NDebugOverlay::Line( vecWarnLocation, vecWarnLocation - vecRight * flSpeed * WARN_INTERVAL * 0.5, 255,255,0, true, 10);
#endif
		m_flNextWarnTime = gpGlobals->curtime + WARN_INTERVAL;
	}
#endif // BUBBLE

	SetNextThink( gpGlobals->curtime + 0.1f );
}
Beispiel #24
0
global func ExplosionParticles_Init()
{
	ExplosionParticles_Smoke =
	{	    
		Size = PV_KeyFrames(0, 180, 25, 1000, 50),
	    DampingY = PV_Random(890, 920, 5),
		DampingX = PV_Random(900, 930, 5),
		ForceY=-1,
		ForceX = PV_Wind(20, PV_Random(-2, 2)),
		Rotation=PV_Random(0,360,0),
		R=PV_KeyFrames(0, 0, 255, 260, 64, 1000, 64),
		G=PV_KeyFrames(0, 0, 128,  260, 64, 1000, 64),
		B=PV_KeyFrames(0, 0, 0, 260, 108, 1000, 108),
	    Alpha = PV_KeyFrames(0, 0, 0, 100, 20, 500, 20, 1000, 0)
	};
	
	ExplosionParticles_Blast =
	{
		Size = PV_KeyFrames(0, 0, 0, 260, 25, 1000, 40),
		DampingY = PV_Random(890, 920, 0),
		DampingX = PV_Random(900, 930, 0),
		ForceY = PV_Random(-8,-2,0),
		ForceX = PV_Random(-5,5,0),
		R = 255,
		G = PV_Random(64, 120, 0),
		Rotation = PV_Random(0, 360, 0),
		B = 0,
		Alpha = PV_KeyFrames(0, 260, 100, 1000, 0),
		BlitMode = GFX_BLIT_Additive,
		Phase = PV_Random(0, 1)
	};
	
	ExplosionParticles_BlastSmooth =
	{
		Size = PV_KeyFrames(0, 0, 0, 250, PV_Random(30, 50), 1000, 80),
		R = PV_KeyFrames(0, 0, 255, 250, 128, 1000, 0),
		G = PV_KeyFrames(0, 0, 255, 125, 64, 1000, 0),
		Rotation = PV_Random(0, 360, 0),
		B = PV_KeyFrames(0, 0, 100, 250, 64, 100, 0),
		Alpha = PV_KeyFrames(0, 0, 255, 750, 250, 1000, 0),
		BlitMode = GFX_BLIT_Additive
	};
	
	ExplosionParticles_BlastSmoothBackground =
	{
		Prototype = ExplosionParticles_BlastSmooth,
		BlitMode = nil,
		R = PV_Linear(50, 0),
		G = PV_Linear(50, 0),
		B = PV_Linear(50, 0),
		Alpha = PV_Linear(128, 0)
	};
	
	ExplosionParticles_Star =
    {
        Size = PV_KeyFrames(0, 0, 0, 500, 60, 1000, 0),
        R = PV_KeyFrames(0, 750, 255, 1000, 0),
        G = PV_KeyFrames(0, 300, 255, 1000, 0),
        B = PV_KeyFrames(0, 300, 255, 500, 0),
		Rotation = PV_Random(0, 360, 4),
        Alpha = PV_KeyFrames(0, 750, 255, 1000, 0),
		BlitMode = GFX_BLIT_Additive,
		Stretch = PV_Speed(1000, 1000)
    };
    
	ExplosionParticles_Shockwave =
    {
        Size = PV_Linear(0, 120),
        R = 255,
        G = 128,
        B = PV_KeyFrames(0, 0, 128, 200, 0),
		Rotation = PV_Step(20),
		BlitMode = GFX_BLIT_Additive,
        Alpha = PV_Linear(255, 0)
    };
    
    ExplosionParticles_Glimmer=
	{
		Size = PV_Linear(2, 0),
	    ForceY = GetGravity(),
		DampingY = PV_Linear(1000,700),
		DampingX = PV_Linear(1000,700),
		Stretch = PV_Speed(1000, 500),
		Rotation = PV_Direction(),
		OnCollision = PC_Die(),
		CollisionVertex = 500,
	    R = 255,
	    G = PV_Linear(128,32),
	    B = PV_Random(0, 128, 2),
	    Alpha = PV_Random(255,0,3),
		BlitMode = GFX_BLIT_Additive,
	};
}
void Cf3MapObjectfunya::OnMove()
{
	if (!IsValid()) return;
	if (!m_pParent->IsPlayable()) return;
	if (m_bFirst) { HitCheck(); m_bFirst = false; }
	float Wind = m_pParent->GetWind(floor(m_X/32),floor(m_Y/32));
	float Friction = m_pParent->GetFriction(floor(m_X/32),floor((m_Y+14)/32));
	float Gravity = GetGravity();
	if (m_pParent->ItemCompleted()) Smile();
	if (theSetting->m_Hyper) m_nPower=4;
	// 動かしま〜す
	if (m_State==STANDING||m_State==SLEEPING||m_State==BLINKING) {
		// 立ってるとき
		m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
		BringClose(m_DX,0.0f,Friction);
		if (m_DX==0) m_Direction = DIR_FRONT;
		if (m_State==STANDING && ++m_Sleepy>=30*40/3) Sleep();
		if (m_State==BLINKING && --m_PoseCounter==0) m_State = STANDING;
		if (m_State==STANDING && CApp::random(120)==0) Blink();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) Run(DIR_LEFT);
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) Run(DIR_RIGHT);
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==RUNNING) {
		// 走ってるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX -= Friction*(m_DX-Wind)*RUNFRICTION;
		m_DX += Friction*2.0f*(AXR-AXL);
		if (AXL&&!AXR) m_Direction = DIR_LEFT;
		if (AXR&&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&&!AXR) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPressed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPressed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) {
			Fall();
		}
	}ef(m_State==WALKING) {
		// 歩いてるとき
		int AXL = 0, AXR = 0;
		if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
		if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
		m_DX += WALKACCEL*(AXR-AXL);
		m_DX -= m_DX*WALKFRICTION;
		if (AXL&!AXR) m_Direction = DIR_LEFT;
		if (AXR&!AXL) m_Direction = DIR_RIGHT;
		if (!AXL&!AXR) m_Direction = DIR_FRONT;
		if (!m_pInput->GetKeyPressed(F3KEY_DOWN)) Stop();
		if (m_PowerY<=0 && m_pInput->GetKeyPushed(F3KEY_JUMP)) StartJump();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_HitBottom) Fall();
	}ef(m_State==CHARGING) {
		// パワー充填中
		if (m_ChargePower>0) {
			m_ChargePower -= m_ChargeDec;
			if (m_ChargePower<0) m_ChargePower = 0;
		}
		m_X -= m_DX;
		if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (!m_pInput->GetKeyPressed(F3KEY_JUMP)) Jump();
		if (!m_HitBottom) Fall();
	}ef(m_State==JUMPING) {
		// 空中
		if (m_DY>=0) {
			int AXL = 0, AXR = 0;
			if (m_PowerX<=0 && m_pInput->GetKeyPressed(F3KEY_LEFT)) AXL = 1;
			if (m_PowerX>=0 && m_pInput->GetKeyPressed(F3KEY_RIGHT)) AXR = 1;
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			m_DX += JUMPACCEL*(AXR-AXL);
			if (AXL&!AXR) m_Direction = DIR_LEFT;
			if (AXR&!AXL) m_Direction = DIR_RIGHT;
		}
		if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
		m_DY += Gravity;
		if (m_DY>=0) {
			if (m_PowerY>=0 && m_pInput->GetKeyPressed(F3KEY_DOWN)) m_DY += Gravity*ADDGRAVITY;
			m_DY -= m_DY*JUMPFRICTIONY;
			if (m_pInput->GetKeyPressed(F3KEY_UP)) {
				m_DY += Gravity;
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_pInput->GetKeyPushed(F3KEY_ATTACK)) BreatheIn();
		if (m_HitBottom) Land();
	}ef(m_State==BREATHEIN) {
		// 冷気充填中
		m_ChargePower+=1.0f;
		if (m_pInput->GetKeyPushed(F3KEY_LEFT)) m_Direction = DIR_LEFT;
		if (m_pInput->GetKeyPushed(F3KEY_RIGHT)) m_Direction = DIR_RIGHT;
		if (m_pInput->GetKeyPushed(F3KEY_UP)) m_Direction = DIR_FRONT;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
			if (m_pInput->GetKeyPushed(F3KEY_DOWN)) Sit();
		}else {
			m_ChargePower+=1.0f;
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (!m_pInput->GetKeyPressed(F3KEY_ATTACK)) BreatheOut();
	}ef(m_State==BREATHEOUT) {
		// 冷気放出!!
		m_ChargePower-=1.0f;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			if (m_DY>=0) {
				m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			}
			m_DY += Gravity;
			if (m_DY>=0) {
				m_DY -= m_DY*JUMPFRICTIONY;
			}
		}
		if (m_ChargePower<=0.0f) {
			if (m_nPower) {
				if (m_HitBottom) Land(); else Fall();
			}else {
				Tire();
			}
		}
	}ef(m_State==TIRED) {
		// ちかれたー!
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION;
			BringClose(m_DX,0.0f,Friction);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX;
			if (m_HitLeft||m_HitRight) m_Direction = DIR_FRONT;
			m_DY += Gravity;
			m_DY -= m_DY*JUMPFRICTIONY;
		}
		if (m_PoseCounter==0) Land();
	}ef(m_State==FROZEN) {
		// 凍っちゃった…
		m_PoseCounter--;
		if (m_HitBottom) {
			m_DX -= WINDFACTOR*(m_DX-Wind)*RUNFRICTION/5;
			BringClose(m_DX,0.0f,Friction/5);
		}else {
			m_DX -= (m_DX-Wind)*JUMPFRICTIONX/5;
			m_DY += Gravity*(1+ADDGRAVITY);
			m_DY -= m_DY*JUMPFRICTIONY/5;
		}
		if (m_PoseCounter==0) Land();
	}
	// 速度飽和(めり込み防止)
	Saturate(-RUNMAX,m_DX,RUNMAX);
	Saturate(-JUMPMAX,m_DY,FALLMAX);
	// 実際の移動+当たり判定
	// 1回の移動ごとに当たり判定
	// という手順ですり抜けバグは解消されるはず
	m_HitLeft = m_HitRight = m_HitTop = m_HitBottom = false;
	m_X += m_DX;
	HitCheck();
	if (!m_HitTop&&!m_HitBottom) {
		m_Y += m_DY;
		HitCheck();
	}
}
Vector2 ETHPhysicsSimulator::GetGravity() const
{
	return GetGravity(m_world);
}