Jump to content

New Vegas - ingame little machinima animation


A.J.

Recommended Posts

While I don't feel I can create some new guide in this website because there's plenty of amazing scripters and modders, I wanted to share this script just as a... proof of concept? is it called in this way?
I love machinima (generically, I love movies). These things are definetely not useful for a mod, but I really like doing things like this one. These little scenes are, for me, just as a nice ribbon over a gift box: nothing essential, compared to the content (or the thought), but also a nice box always gives me a better mood.

 

Here's a video of what happens:

http://www.youtube.com/watch?v=YjrmgMraG-8&feature=youtu.be

- Step 1
I created a food (Strange Cake) and I've placed the effect I created in Step 2. It is ESSENTIAL that the duration IS MORE THAN zero. There's an important reason to this, it will break it, but I can't remember now what was exactly the issue... I think it is because if it's zero it will break when I go from menumode of the pipboy to gamemode of the animated scene.

- Step 2
I created the effect: Archetype - Script, Associated item - the script I do in Step 4

- Step 3
I created a quest with a very low delay (0.0x). Lower this value will be, smoother will be the machinima. I attached the script I'll write in Step 5.
The quest won't be enabled: since it has a very low delay, I don't want to slow the system without a good reason, it will be enabled at the right time.

- Step 4
Here's the script for the Food effect:
 

scn aaPCakeFoodEffectScript

begin ScriptEffectStart

    if (aaPinkyAptSet.aaPCakeIsOn == 1) && ((GetStage aaPCakeQuest ==  20) || (GetStage aaPCakeQuest ==  30))    

        iMod aaPCakeVisualEffectISFX
        iMod FadeToBlack4sISFX
        disableplayercontrols 1 1 1 1 1 1 1

; JUST READ THIS PREVIOUS IF BLOCK AS "if I'm eating the food at the right time, make a fade to black effect and disable my controls, machinima starts"

    else        ; IF NOT, BLAHBLAHBLAH, THESE ARE CONCERNING MY OWN QUEST, SO IT'S NOT IMPORTANT

        if (GetStage aaPCakeQuest ==  0) || (GetStage aaPCakeQuest ==  10)

            set aaPinkyAptSet.aaPAddCake to 1

        showmessage aaPCakeEat1

        endif

        if (GetStage aaPCakeQuest ==  20) || (GetStage aaPCakeQuest ==  30)

            set aaPinkyAptSet.aaPAddCake to 1

        showmessage aaPCakeEat2

        endif

    endif

end

begin ScriptEffectFinish

    if (aaPinkyAptSet.aaPCakeIsOn == 1) && ((GetStage aaPCakeQuest ==  20) || (GetStage aaPCakeQuest ==  30))        ;SAME AS BEFORE, IF I WAS EATING AT THE RIGHT TIME...
        riMod aaPCakeVisualEffectISFX            ;WHEN EFFECT FINISHES, REMOVE THE FADE TO BLACK AND THE OTHER VISUAL EFFECTS
        riMod FadeToBlack4sISFX
        imod FadeInFromBlack4sISFX            ;START A FADE IN FROM BLACK
        Set aaPinkyAptSet.aaPCakeMorph to 1        ; SET VARIABLE TO START THE SCRIPT IN STEP 5
        set aaPinkyAptSet.aaPCakeIsOn to 0
        startquest aaPCakeMorphQuest            ; START QUEST IN STEP 3, SO THAT ITS SCRIPT IN STEP 5 CAN WORK PROPERLY
    endif

end

- STEP 5
This is the machinima effect script, attached to quest in Step 3, it's staged so it's also quite plain to be read.
 

scn aaPCakeQuestScript

int doonce
int dotwice
int eatonce
int doclone
int doback

ref cloneref
ref playeritemREF

float pangle
float cscale

float ctimer
int cstage

float backtimer

float menutime
int menustage


begin gamemode

if aaPinkyAptSet.aaPCakeMorph == 1        
; this variable is set inside the previous script, using my quest.var sheet, it simply means "ok the animation can start". AAPinkyAptSet is a generic quest where I store generic variables.

    if doclone == 0                ; this is the first stage variable, it will stage the creation of my own clone

        if IsPC1stPerson

            player.moveto aaPCakePlayerMarker    ; my player will be the camera, I move her to a marker with a good view of the scene

            if (cloneref.IsActor) == 0        ; if my clone doesn't exists, create it. This redundancy was essential because of de-sync under certain situations

                set cloneref to aaPCakeStartCloneMarkerREF.placeatme 7 1    ; create my clone to a specific marker where the scene will start, then increase the stage var value

                set doclone to 2
                endif

        else

            disableplayercontrols 0 0 0 1

        endif

    endif


    if doclone == 2        ; if the clone is created

        if IsModLoaded "Readius_NV.esp"            
; this requires NVSE. If the Readius mod is loaded, I SUPPOSE I'm using it, so my clone won't wear a pipboy, so simply remove it and its glove

            cloneref.removeitem Pipboy 1
            cloneref.removeitem PipboyGlove 1
            endif


; now, the following lines dress up my clone as me, providing her with the items I'm wearing. Not all the slots are covered, but you can easily add the missing lines if you need it. IF redundancy was made against de-syncs

        if (player.getequippedobject 0) != (cloneref.getequippedobject 0)    
            set playeritemREF to player.getequippedobject 1
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 1) != (cloneref.getequippedobject 1)
            set playeritemREF to player.getequippedobject 1
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 2) != (cloneref.getequippedobject 2)
            set playeritemREF to player.getequippedobject 2
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 7) != (cloneref.getequippedobject 7)
            set playeritemREF to player.getequippedobject 7
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 8) != (cloneref.getequippedobject 8)
            set playeritemREF to player.getequippedobject 8
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 9) != (cloneref.getequippedobject 9)
            set playeritemREF to player.getequippedobject 9
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 10) != (cloneref.getequippedobject 10)
            set playeritemREF to player.getequippedobject 10
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 11) != (cloneref.getequippedobject 11)
            set playeritemREF to player.getequippedobject 11
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 14) != (cloneref.getequippedobject 14)
            set playeritemREF to player.getequippedobject 14
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        if (player.getequippedobject 16) != (cloneref.getequippedobject 16)
            set playeritemREF to player.getequippedobject 16
            cloneref.additem playeritemREF 1
            cloneref.equipitem playeritemREF
        endif

        set doclone to 3                ; increase the stage var value, redundancy for disableplayercontrol (had issues a couple of times), make the clone travel from its starting mark to a proper destination

        disableplayercontrols 1 1 1 1 1 1 1
        cloneref.AddScriptPackage aaPCloneTravel
    endif


; this is concerning machinima: since my player is the camera, and she can't move, this line make its "camera" looking at the clone, when the clone is moving in front of her
    set Pangle to Player.GetAngle Z + Player.GetHeadingAngle cloneref    
    Player.SetAngle Z Pangle
    player.setangle X 10

endif

Now the clone is created and it's moving a the certain location, while my camera is watching her. When she'll arrive there she will eat and will grow. Script continues.
 

if aaPinkyAptSet.aaPCloneStage == 1    ; This is a global quest.var that is set to 1 when the clone reaches the end of its travel package.

    cloneref.additem aaPEatToken 1    ; Add a token to the clone, so that he can start the eat animation
    if cstage == 0            ; This is a staged timer, these seconds must be trimmed concerning of your animations. For me it was working good with 4.
    set ctimer to 4
    set cstage to 1
    endif

    if cstage == 1
    set ctimer to (ctimer - getsecondspassed)

        if ctimer <=2        ; After 2 seconds, the clone is eating, play the sound of eating. 2 seconds are my trimmed value
            if eatonce == 0
            playsound NPCHumanEatingFoodChewy
            set eatonce to 1
            endif
        endif


; After 4 seconds (clone has finished to eat), remove the token that was allowing the eating animation and advance the stage of the animation: the clone will grow up
        if ctimer <= 0        
        set cstage to 2
        set aaPinkyAptSet.aaPCakeMorph to 2
        set aaPinkyAptSet.aaPCloneStage to 0
        cloneref.removeitem aaPEatToken 1
        endif
    endif

endif

endif

if aaPinkyAptSet.aaPCakeMorph == 2    ; If the clone has finished to eat

    if dotwice == 0
        set cscale to 1        ; Now this could be made in a different way. It would be better to store somewhere the scale value of my player, but I didn't do it and I supposed player had a scale of 1, and this is not good...

        set dotwice to 1
        imod aaPCakeVisualEffectISFX        ; introduce a visual effect
        playsound aaPCakeMagic            ; and play a sound
        cloneref.playidle loosepanicgrenadeplant    ; and playidle the animation of a NPC with a grenade in its pocket.
        endif
    
    set cscale to cscale + (getsecondspassed * 1.5)        ; increases progressively the scale of the clone, the value needs to be trimmered, I trimmered at 1.5

    cloneref.setscale cscale         ; and gives the clone the new scale value (which is slowly increasing)

    if (cscale >= 3) && (cscale <= 6)   ; while the clone is still growing, place another visual effect
        if doback == 0
            set doback to 1
            imod aaPCakeVisualEffectISFX
        endif
    endif


; if the clone's scale reached 10, stick the value to 10, remove effects and start a fade to black, the scene is going to finish. Then, increase the animation's stage    
    if cscale >= 10                        
        cloneref.setscale 10
;        rimod aaPCakeVisualEffectISFX
        imod FadeInFromBlack4sISFX
        set aaPinkyAptSet.aaPCakeMorph to 3
    endif

endif


; At this next stage, destroy the clone since the player will take her place, and mark her for delete. Enable then some of the player controls, set her scale at 10 as the scale of the (killed) clone, show a message

if aaPinkyAptSet.aaPCakeMorph == 3

    if doback == 1
        set doback to 2
        cloneref.disable
        cloneref.markfordelete
        player.setscale 10
        enableplayercontrols 1 0 0 1 1
        showmessage aaPCakeTallMessage
        set backtimer to 20        ; the effect of the "big" player will least 20 seconds
    endif


; this is concerning the quest, I wanted the player be in that exact position. Since when you are tall you can climb slopes but you can easily die for falling damage just walking down, I wanted her to stay exactly in that position, she can't move.
    if doback == 2

        if backtimer > 0
            set backtimer to backtimer - getsecondspassed
            player.setpos x 467
            player.setpos y -4237
            player.setpos z 7775
        else
            set doback to 3
            disableplayercontrols 1 0 0 0 1        ; when the 20 seconds are passed, disable again player controls and increases stage.
        endif
    endif


    if doback == 3
; now the player is going to reduce the scale again, so let's trigger another visual effect, play another sound...

        set cscale to 10
        set doback to 4
        imod aaPCakeVisualEffectISFX
        playsound aaPCakeMagic
        endif


    if doback == 4

        set cscale to cscale - (getsecondspassed  * 1.5)    ; ... and reduce progressively its scale. Again, it was better if I stored the scale at player's original scale, instead of assuming it was 1...
        player.setscale cscale
            if cscale <= 1
                set doback to 5
            endif
        endif


    if doback == 5

        enableplayercontrols 1 1 1 1 1 1        ; effect finished, everything goes to normality
        player.setscale 1
        set aaPinkyAptSet.aaPCakeMorph to 4
        showmessage aaPCakeMessageNever

            if (getstage aaPCakeQuest == 20)
                setstage aaPCakeQuest 40
                rewardxp 50
            endif

            if (getstage aaPCakeQuest == 30)
                setstage aaPCakeQuest 50
                rewardxp 50
            endif

    stopquest aaPCakeMorphQuest        ; stop the very-short-delay-quest: it's finished, we don't need to slow down the game without a reason.

    endif

endif

end

While this script is working fine for me, keep in mind that I just wanted to share the idea, I surely know these scripts can be done in thousands better ways / optimized / etc. Also, a companion will obstruct the camera view but I didn't want to check their presence since it should be a lonely quest.

Link to comment

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. For more information, see our Privacy Policy & Terms of Use