var entity : CEntity;
var entityc : CEntity;
private var WPCurrentRotationCircleAngle : float;
private var WPCurrentRotation : EulerAngles;
private var WPCurrentPosition : Vector;
private var WPCurrentVelocity : Vector;
private var WPCurrentAcceleration : Vector;
private var WPGoalPosition : Vector;
private var WPGoalPositionOffset : Vector;
private var WPGoalPositionOffset_regenerateInSeconds : float;
function OnCiriTorch ( )
{
var entityTag : name;
var entities : array <CNode>;
var i : int;
var bonePos : Vector;
bonePos = MatrixGetTranslation(thePlayer.GetBoneWorldMatrixByIndex(24));
this.AddTimer('FollowPlayer', 0.0001, true);
entityTag = 'PLAYER';
animwisp ();
theGame.GetNodesByTag( entityTag, entities);
for (i = 0; i < entities.Size(); i += 1 )
{
entity = (CEntity) entities[i];
theGame.GetGuiManager().ShowNotification("torch on");
entity.PlayEffectSingle( 'hand_levitation_fx' );
thePlayer.PlayerStartAction( 1,'high_standing_agressive_gesture_fireball_idle' );
}
if (i - 0)
{
entity.StopEffect('hand_levitation_fx');
}
}
function OnCiriTorchOff ( )
{
theGame.GetGuiManager().ShowNotification("torch off");
entity.StopEffect('hand_levitation_fx');
entity.DestroyAfter(0.5);
entityc.DestroyAfter(0.5);
thePlayer.PlayerStopAction( 1 );
}
function animwisp ( )
{
var animatingEntity : CGameplayEntity;
var entityTag : name;
var i : int;
var entitiewisp : array<CEntity>;
var actorTag : name;
var resourcePath : string;
var entityTemplate : CEntityTemplate;
theGame.GetWorld().ShowLayerGroup( "quests\q402_ciri\wisp" );
actorTag = 'PLAYER';
entityTag = 'q402_wisp';
entityc = entitiewisp[1];
resourcePath = "quests\part_2\quest_files\q402_ciri\entities\q402_wisp.w2ent";
entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
entityc = theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition() , thePlayer.GetWorldRotation());
entityc.PlayEffect('wisp_fx');//wisp_fx
entityc.AddTag('q402_wisp');
theGame.GetEntitiesByTag( actorTag, entitiewisp );
for ( i = 0; i < entitiewisp.Size(); i += 1 )
{
animatingEntity = (CGameplayEntity)entitiewisp[ i ];
animatingEntity.PlayPropertyAnimation( 'Move', 1, 1, 0 );
}
}
timer function FollowPlayer(deltaTime : float, id : int) {
var target : CActor;
var targetPosition : Vector;
var targetRotation : EulerAngles;
var playerPosition : Vector;
var playerRotation : EulerAngles;
var goalAcceleration : Vector;
var navigationComputeZReturn : float;
var rotationCircleRadius : float;
var rotationCircleMovementSpeed : float;
var selfRotationSpeed : float;
var maxAcceleration : float;
var accelerationMultiplier : float;
var maxVelocity : float;
var velocityDampeningFactor : float;
if(thePlayer.IsInInterior())
{
rotationCircleMovementSpeed = 25;
rotationCircleRadius = 0.45;
selfRotationSpeed = 0.3;
maxAcceleration = 100;
accelerationMultiplier = 20;
maxVelocity = 20;
velocityDampeningFactor = 0.9;
}
else
{
rotationCircleMovementSpeed = 25;
rotationCircleRadius = 0.75;
selfRotationSpeed = 0.3;
maxAcceleration = 100;
accelerationMultiplier = 20;
maxVelocity = 20;
velocityDampeningFactor = 0.9;
}
WPCurrentRotationCircleAngle += deltaTime * rotationCircleMovementSpeed;
while(WPCurrentRotationCircleAngle > 360)
{
WPCurrentRotationCircleAngle -= 360;
}
target = thePlayer.GetTarget();
targetPosition = target.GetWorldPosition();
targetRotation = target.GetWorldRotation();
playerPosition = thePlayer.GetWorldPosition();
playerRotation = thePlayer.GetWorldRotation();
WPGoalPosition = playerPosition;
WPGoalPosition += WPGoalPositionOffset;
WPGoalPosition.X += CosF(Deg2Rad(WPCurrentRotationCircleAngle)) * rotationCircleRadius;
WPGoalPosition.Y += SinF(Deg2Rad(WPCurrentRotationCircleAngle)) * rotationCircleRadius;
WPGoalPosition.Z += 2;
WPGoalPositionOffset_regenerateInSeconds -= deltaTime;
if(WPGoalPositionOffset_regenerateInSeconds < 0)
{
WPGoalPositionOffset_regenerateInSeconds = RandRangeF(1, 0.1);
WPGoalPositionOffset = VecRand() * rotationCircleRadius * 0.25;
}
WPCurrentAcceleration = (WPGoalPosition - WPCurrentPosition) * accelerationMultiplier;
if(VecLength(WPCurrentAcceleration) > maxAcceleration)
{
WPCurrentAcceleration = VecNormalize(WPCurrentAcceleration) * maxAcceleration;
}
WPCurrentVelocity += WPCurrentAcceleration * deltaTime;
WPCurrentVelocity *= velocityDampeningFactor;
if(VecLength(WPCurrentVelocity) > maxVelocity)
{
WPCurrentVelocity = VecNormalize(WPCurrentVelocity) * maxVelocity;
}
if (theGame.GetWorld().NavigationComputeZ( WPCurrentPosition, WPCurrentPosition.Z - 1, WPCurrentPosition.Z + 1, navigationComputeZReturn ) )
{
if(AbsF(WPCurrentPosition.Z - navigationComputeZReturn) < 0.1)
{
WPCurrentVelocity.Z *= -0.9;
}
}
WPCurrentPosition += WPCurrentVelocity * deltaTime;
if(VecDistance(WPCurrentPosition, WPGoalPosition) > 100)
{
WPCurrentPosition = WPGoalPosition;
WPCurrentVelocity = Vector(0,0,0);
WPCurrentAcceleration = Vector(0,0,0);
}
WPCurrentRotation.Pitch += deltaTime * selfRotationSpeed;
entityc.TeleportWithRotation(WPCurrentPosition, WPCurrentRotation);
}