[MOD] Ciri Torch Night

+
Hello, I want to create a mod for Ciri automatically use the torch in the night.
observation: in the game the NPCs use the torch automatically at night

possible request with
quest function AddItemQuest(targetTag : CName, itemName : CName, quantity : Int3 2, items : array, informGUI : Bool)

if( thePlayer.IsCiri())
{
if(theGame.envMgr.IsNight())
{

with q001_beginning.w2phase you ave CQuestScriptBlock #14 Torch function AddItemQuest for Geralt in Start Game at Prologue

 
Last edited:
after several attempts to change Ciri's movements and add a torch to hand.
he has nothing to do, she does not want to move.
 




[Exploration_Replacer_Ciri]
IK_8=(Action=CiriTorchToggle)

-----------------------------------------------

playerInput.ws

Code:
public var CiriTorchToggleButton : bool;
theInput.RegisterListener( this, 'OnCiriTorchToggle', 'CiriTorchToggle' );

    event OnCiriTorchToggle ( action : SInputAction )
    {
    var resourcePath    : string;
    var entityTemplate  : CEntityTemplate;
    var entitytc           : CEntity;   
 
        if ( IsPressed (action) )
        {
            CiriTorchToggleButton = ( !CiriTorchToggleButton ); 

            if ( CiriTorchToggleButton && thePlayer.IsCiri())
            {         
                resourcePath = "items\usable\torch\torch.w2ent";       
                entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
                entitytc = (CTorchLight)theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition(), thePlayer.GetWorldRotation());       
                entitytc.CreateAttachment(thePlayer, 'l_weapon', /* NO P */, /* NOP */);
                theGame.GetGuiManager().ShowNotification("torch on");               
        
            }
            else       
            {
                 theGame.GetGuiManager().ShowNotification("torch off");                           
                entitytc.StopEffect( 'light_on' );       
            }
        }
    }
-------------------------------------------------------------


 
Last edited:
playerInput.ws

Code:
event OnCiriTorchToggle ( action : SInputAction ) 
    {
    var resourcePath    : string;
    var entityTemplate  : CEntityTemplate;
    var entity    :  CEntity;
    var factAddedOnUse : string;
    var factValue    : int;
    var factTimeValid     : int;


                //resourcePath = "quests\part_2\quest_files\q309_casablanca\entities\q309_hanging_lamp.w2ent";
                //resourcePath = "items\quest_items\q104\q104_item__keira_lamp.w2ent";
                //resourcePath = "items\work\lantern_dwarf_01\lantern_dwarf_01.w2ent";                 
                //resourcePath = "items\usable\quest_character_lamp.w2ent";             
                //resourcePath = "items\work\work_torch\torch_work.w2ent";             
                //resourcePath = "items\usable\torch\torch.w2ent";
                //resourcePath = "items\usable\oillamp\oillamp.w2ent";
              
    resourcePath = "items\usable\quest_character_lamp.w2ent";
        entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);

  
        if ( IsPressed (action) && !FactsDoesExist("tlciri_used"))
        {
        CiriTorchToggleButton = ( !CiriTorchToggleButton );
      
            if (CiriTorchToggleButton && thePlayer.IsCiri())
            {
          
            theGame.GetGuiManager().ShowNotification("torch on");
            //FactsAdd(factAddedOnUse, factValue, factTimeValid);             
            entity = theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition(), thePlayer.GetWorldRotation());
            entity.AddTag('tlciri_used');
            entity.PlayEffect('light_on');
            entity.CreateAttachment(thePlayer, 'l_weapon', Vector(0.1,0.0, 0.0), EulerAngles(0.000000, 0.0, 270.00000)); 
            //thePlayer.PlayerStartAction( 1, 'man_geralt_carry_torch_low_loop_left' );
      
            }
            else
            {
              
                theGame.GetGuiManager().ShowNotification("torch off"); 
            //FactsRemove(factAddedOnUse);
            entity = theGame.GetEntityByTag('tlciri_used');
            //entity.StopEffect( 'light_on' );         
            entity.DestroyAfter(0.1);             
                  
            }
      
        }

    }
 
Last edited:
update






Code:
    event OnCiriTorchToggle ( action : SInputAction )   
    {
    var resourcePath    : string;
    var entityTemplate  : CEntityTemplate;
    var entity    :  CEntity;


        
        resourcePath = "items\usable\torch\torch.w2ent";
        entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);

    
        if ( IsPressed (action) && !FactsDoesExist("tlciri_used"))
        {
        CiriTorchToggleButton = ( !CiriTorchToggleButton );
        thePlayer.RaiseEvent( 'ItemUseL' );                                 
        
            if (CiriTorchToggleButton && thePlayer.IsCiri())
            {
            
            theGame.GetGuiManager().ShowNotification("torch on");
                            
            entity = theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition(), thePlayer.GetWorldRotation());
            entity.AddTag('tlciri_used');
            entity.PlayEffect('light_on');
            entity.CreateAttachment(thePlayer, 'l_weapon',,);
            
        
            }
            else
            {

                theGame.GetGuiManager().ShowNotification("torch off");   
            
            entity = theGame.GetEntityByTag('tlciri_used');
                        
            entity.DestroyAfter(0.1);               
                    
            }
        
        }


    }




Code:
    event OnCiriTorchToggle ( action : SInputAction ) 
    {
    var resourcePath    : string;
    var entityTemplate  : CEntityTemplate;
    var entity    :  CEntity;


      
        resourcePath = "quests\part_2\quest_files\q309_casablanca\entities\q309_hanging_lamp.w2ent";
        entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);

  
        if ( IsPressed (action) && !FactsDoesExist("tlciri_used"))
        {
        CiriTorchToggleButton = ( !CiriTorchToggleButton );
        thePlayer.RaiseEvent( 'ItemUseL' );                               
      
            if (CiriTorchToggleButton && thePlayer.IsCiri())
            {
          
            theGame.GetGuiManager().ShowNotification("torch on");
                          
            entity = theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition(), thePlayer.GetWorldRotation());
            entity.AddTag('tlciri_used');
            entity.PlayEffect('light_on');
            entity.CreateAttachment(thePlayer, 'l_weapon',Vector(0.000000, 0.000000, 0.000000),  EulerAngles(0.000000, 270.000000, 0.000000));
          
      
            }
            else
            {

                theGame.GetGuiManager().ShowNotification("torch off"); 
          
            entity = theGame.GetEntityByTag('tlciri_used');
                      
            entity.DestroyAfter(0.1);             
                  
            }
      
        }


    }
 
Last edited:
i ave trouble with script.

c.p.:
"Also, if you have the torch equipped before a cutscene starts, the torch is included in the cutscene floating around and looks funny. lol "

I think the solution would be to make a loop timer in pleyer.ws with an 'if (! Player.IsCiri)' condition.

Do you ave idea?
 
new code torches and lamps

I moved the majority of the code in player.ws to fix the bugs, the toogle stays in playerinput.ws and uses the OnCiriTorch () and OnCiriTorchOff () functions in player.ws.

for input.settings

[Exploration_Replacer_Ciri]
IK_8=(Action=CiriTorchToggle)


add. at player.ws

// Torch for Ciri
editable var factValue : int;
editable var factTimeValid : int;
editable var factAddedOnUse : string;
var entityc : CEntity;
// Torch for Ciri

event OnSpawned( spawnData : SEntitySpawnData )
// Torch for Ciri
if( !thePlayer.IsCiri() )
{
OnCiriTorchOff ();
}
// Torch for Ciri


Code:
//    Torch for Ciri   
    function  OnCiriTorch ( )   
    {
    var resourcePath    : string;
    var entityTemplate  : CEntityTemplate;

    //var inGameConfigWrapper                 : CInGameConfigWrapper;
    //var CTLValue                     : float;
    
    //inGameConfigWrapper = (CInGameConfigWrapper)theGame.GetInGameConfigWrapper();       
    //CTLValue = StringToFloat(inGameConfigWrapper.GetVarValue('ModCiriTandL', 'CTLchoice'));
        
    //if (CTLValue == 0)
        //{
            //resourcePath = "items\work\work_torch\torch_work.w2ent";
        //}
    //else if (CTLValue == 1)
        //{
            //resourcePath = "items\usable\torch\torch.w2ent";
        //}               
    ///else if (CTLValue == 2)
        //{
            resourcePath = "quests\part_2\quest_files\q309_casablanca\entities\q309_hanging_lamp.w2ent";
        //}
    //else if (CTLValue == 3)
        //{
            //resourcePath = "items\quest_items\q104\q104_item__keira_lamp.w2ent";
        //}
    //else if (CTLValue == 4)
        //{
            //resourcePath = "items\work\lantern_dwarf_01\lantern_dwarf_01.w2ent";
        //}
    //else if (CTLValue == 5)
        //{
            //resourcePath = "items\usable\quest_character_lamp.w2ent";
        //}
    //else if (CTLValue == 6)
        //{
            //resourcePath = "items\usable\oillamp\oillamp.w2ent";
        //}               
            
        entityTemplate = (CEntityTemplate)LoadResource(resourcePath,true);
        thePlayer.RaiseEvent( 'ItemUseL' );               
        //theGame.GetGuiManager().ShowNotification("torch on");
        entityc = theGame.CreateEntity(entityTemplate, thePlayer.GetWorldPosition(), thePlayer.GetWorldRotation());
        entityc.AddTag('tlciri_used');
        entityc.PlayEffect('light_on');
        FactsAdd(factAddedOnUse, factValue, factTimeValid );
    //if (CTLValue == 2||CTLValue == 3 ||CTLValue == 4 ||CTLValue == 5 ||CTLValue == 6 )
        //{
            entityc.CreateAttachment(thePlayer, 'l_weapon',Vector(0.100000, 0.000000, 0.000000),  EulerAngles(0.000000, 270.000000, 0.000000));
        //}
    //else if (CTLValue == 0||CTLValue == 1)
        //{
            //entityc.CreateAttachment(thePlayer, 'l_weapon',,);
        //}           
    }
    function OnCiriTorchOff ( )
    {   
        thePlayer.RaiseEvent( 'ItemEndL' );           
        //theGame.GetGuiManager().ShowNotification("torch off");   
        entityc = theGame.GetEntityByTag('tlciri_used');
        entityc.DestroyAfter(0.2);
        FactsRemove(factAddedOnUse);
        entityc.StopEffect( 'light_on' );

    }
//    Torch for Ciri

in playerinput.ws

// modLampForCiri
public var CiriTorchToggleButton : bool;
// modLampForCiri

// modLampForCiri
theInput.RegisterListener( this, 'OnCiriTorchToggle', 'CiriTorchToggle' );
// modLampForCiri

Code:
//    Torch for Ciri   
    
    event OnCiriTorchToggle ( action : SInputAction )   
    {
            
        if ( IsPressed (action) && !FactsDoesExist("tlciri_used") && thePlayer.IsCiri())
        {
        CiriTorchToggleButton = ( !CiriTorchToggleButton );

        
            if (CiriTorchToggleButton )
            {
        thePlayer.OnCiriTorch();           
        
        
            }
            else
            {
        thePlayer.OnCiriTorchOff();
        
            }       
        }
        
    }
//    Torch for Ciri
 
Hi its me GodsMistake from nexus. Unfortunately I cannot post anything in the forums yet since I have a new account. :D
 



script is not optimized:
Code:
    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);
          
    }

input.settings

[Exploration_Replacer_Ciri]
IK_8=(Action=CiriTorchToggle)


add. at player.ws

// Torch for Ciri
editable var factValue : int;
editable var factTimeValid : int;
editable var factAddedOnUse : string;
var entityc : CEntity;
// Torch for Ciri

event OnSpawned( spawnData : SEntitySpawnData )
// Torch for Ciri
if( !thePlayer.IsCiri() )
{
OnCiriTorchOff ();
}
// Torch for Ciri
Post automatically merged:

for hand_levitation_fx
open ciri.w2ent ,ciri_player.w2ent and keira_metz.w2ent with Wolven
I do not know if it is ciri.w2ent or ciri_player.w2ent which works because I have modify both.
I will do the tests later.

index 0
at cookedEffects:
copy hand_levitation_fx at Keira to ciri Ciri
 
Last edited:
Top Bottom