Freedom Reborn Archive

Freedom Force Forums => Scripting Forum => Topic started by: Conduit on January 11, 2008, 06:11:19 PM

Title: Phasing
Post by: Conduit on January 11, 2008, 06:11:19 PM
I recently made a phaseTo function.  You can check out a test of it I did using some nifs from Matrix Mod Reloaded here (http://www.frpmods.com/files/Conduit/miscellanious/phasetest.wmv).  I'd really like to see this be added to FFX.

Here's the script I used:

# symphony

from cshelper import *
from js import *
import event
from random import randint
from ffx import *
from missionobjvar import *
from Stutter import *

def OnPostInitMap():
    Mission_SetSunlight(-140,70,1.0,0.8,(0.7,0.6,0.6))
    Mission_SetShadows(-140,70,(0.2,0.2,0.4))
    Mission_SetProjShadowBackground((1,1,1))
    Mission_SetProjShadowColor((.6,.6,.6,1))
    Mission_SetAttr('random', 87)
    Mission_SetAttr('dummyCount', 1)
    for objects in Mission_GetObjects():
        if cmp(objects, '_impobj_0') != 0:
            Mission_CustomAction('phase', 'persephone', objects, 'Phase', 60, 0)

def Phase(dest, char):
    x = 0
    if Object_VarExists(char, 'phasing'):
        if Object_GetVar(char, 'phasing') == 1:
            x = 1
    if x == 0:
        turnTo(char, dest)
        RegTimer('Phase2', 0.5, 0, "tuple = ('"+char+"', '"+dest+"')")

def Phase2(event):
    exec event.object
    dest = tuple[1]
    char = tuple[0]
    pos = Get_ObjectPos(dest)
    pos2 = Get_ObjectPos(char)
    if pos[2] < 90 and pos2[2] < 90:
        PhaseTo(char, 'effect_persephone_phase', pos)

def PhaseTo(character, effect, dest, end_effect=''):
    Object_SetVar(character, 'phasing', 1)
    pos=Get_ObjectPos(character)
    rot=Object_GetOrientation(character)
    proxy=getDummyName()
    Object_SpawnAt('fx_standin', pos, proxy, (rot[0], rot[1], rot[2]))
    handle=Object_PlayEffect(proxy, effect, '', FX_LOOP|FX_TRACK_OBJECT_FULL)
    Object_SetAttr(proxy, 'effect_handle', handle)
    if len(end_effect) > 0:
        Object_SetVar(proxy, 'end_effect', end_effect)
    Object_SetVar(proxy, 'character', character)
    Object_SetSecondaryState(character, SCSTATE_INVISIBLE, 900, PERMANENT_STATE)
    Trigger_Move(character, "lock")
    Object_SetAttr(character, 'minHealth', Object_GetAttr(character, 'health'))
    speed=(Object_GetAttr(character, 'speed')+1)/2.8
    Object_StutterMove(proxy, dest, rot[1], speed, 0, 1, 0, 'onPhaseReach', 0, proxy)

def onPhaseReach(event):
    proxy=event.object
    pos=Get_ObjectPos(proxy)
    rot=Object_GetOrientation(proxy)[1]
    character=Object_GetVar(proxy, 'character')
    handle=Object_GetAttr(proxy, 'effect_handle')
    Object_StopEffect(proxy, handle)
    if Object_VarExists(proxy, 'end_effect'):
        effect=Object_GetVar(proxy, 'end_effect')
        Object_PlayEffect(proxy, effect, 'Clean_UpProxy', FX_TRACK_OBJECT_FULL)
    else:
        Object_Destroy(proxy)
    marker=getDummyName()
    Marker_Spawn(marker, pos, rot)
    teleport(character, marker)
    Object_SetSecondaryState(character, SCSTATE_INVISIBLE, 9, REMOVE_STATE)
    Trigger_Move(character, "unlock")
    Object_SetVar(character, 'phasing', 0)
    Object_SetAttr(character, 'minHealth', 0)

def Clean_UpProxy(event):
    Object_Destroy(event.object)


Note that using this will require an animated nif made by adding a movement animation to the character nif using NifSkope.  The process for this is easy to learn, but can take a while to do.  You can also use other effects if you want to, say, have the character turn into a cloud of smoke.

Also, while testing it, I found that one could use it to "walk on air" to the tops of buildings, or from building to building, which looks kind of weird.  I incorporated a height check to keep this from happening in most cases.  However, this is perfectly acceptable if the character can fly while they phase, like the Vision, so there should probably be an option in the control center to turn this off.
Title: Re: Phasing
Post by: Epimethee on January 14, 2008, 05:54:51 PM
Nice hack, it certainly looks interesting!

I'll try to install it to have a look. Do you have a skoped Nif you could make available for testing? Thanks.
Title: Re: Phasing
Post by: Conduit on January 15, 2008, 03:15:29 PM
I recently made this nif (http://www.frpmods.com/files/Conduit/miscellanious/shadowcatnif.rar).  Unzip into your data folder to install.  It goes with Ink's kitty_blue mesh and the default skin.
Title: Re: Phasing
Post by: stumpy on January 15, 2008, 05:25:05 PM
Just a note, the directory layout in that archive looks like it's for an FX. But the files themselves look like they are for a character NIF.
Title: Re: Phasing
Post by: Epimethee on January 15, 2008, 08:23:00 PM
Looking at the code, isn't that the way things are supposed to be? :)
Title: Re: Phasing
Post by: stumpy on January 15, 2008, 09:51:04 PM
:lol: For sure. I was just trying to help out people trying this on their own who can't read through the code.
Title: Re: Phasing
Post by: stumpy on January 26, 2008, 06:27:45 AM
Had some free time today and I was going to check into this. Probably a silly questions, but where do you define Object_StutterMove()?
Title: Re: Phasing
Post by: Epimethee on January 26, 2008, 10:15:13 AM
http://freedomreborn.net/archive/index.php?topic=42119.0