News:

Happy 20th, FFvT3R!

Main Menu

Bleeding State

Started by bearded, May 13, 2022, 11:53:32 AM

Previous topic - Next topic

bearded

Life Drain is very close to what I want. Is the damage blocked by Invulnerable? I would like to use the blood spray fx, while in the state, and no healing. Where would I start, other than creating an attribute in ffedit?

Epimethee

It's not an attribute, but  a power swap, so no FFEdit needed. Do you want it to be blocked by Invulnerable? From what I can gather looking at the code, it would be. What do you mean by no healing?

Ignoring the above questions, and assuming you're using FFX 3.3, the simplest way would be to open ffx2.py and duplicate the section with the vampiric variant of Life Drain (a.k.a. Life Drain with Hypnosis/Life Drain with Mind Control) already there. Something along these lines (not tested):

#################### bleeding life drain swap ################################################
# This is almost exactly like the existing life drain swap but ---add your
# description here
# -Bearded
#######################################################################################

MP_BLEEDLIFEDRAIN=15

def stuntoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_STUNNED,1)
def hypnosistoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_HYPNOTISED,ffx.COST_HYPNO)
def ragetoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_ENRAGED,ffx.COST_RAGE)
def exiletoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_EXILE,ffx.COST_EXILE)
def blanktoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_BLANK,ffx.COST_BLANK)
def panictoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_PANICKED,ffx.COST_PANIC)
def frozentoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_FROZEN,ffx.COST_FROZEN)
def stasistoBleedLifeDrain(event):
    BleedLifeDrainP(event,PCSTATE_STATIC,ffx.COST_STASIS)

def hextoBleedLifeDrain(event):
    BleedLifeDrainS(event,SCSTATE_HEXED,ffx.COST_HEX)
def blindtoBleedLifeDrain(event):
    BleedLifeDrainS(event,SCSTATE_BLIND,ffx.COST_BLIND)
def powernulltoBleedLifeDrain(event):
    BleedLifeDrainS(event,SCSTATE_POWER_NULLIFICATION,ffx.COST_NULL)
def weakentoBleedLifeDrain(event):
    BleedLifeDrainS(event,SCSTATE_WEAKENED,ffx.COST_WEAKEN)
def speeddecreasetoBleedLifeDrain(event):
    BleedLifeDrainS(event,SCSTATE_SPEED_DECREASED,ffx.COST_DECREASE)

def densitytoBleedLifeDrain(event):
    char=event.object
    source=event.string
    if ffx.densityaltered(char):
        Object_SetGenericState(char,OBJSTATE_DENSITY_CHANGE,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makeBleedLifeDrained(char,source,ffx.COST_DENSITY)

def BleedLifeDrainP(event,state,intensity):
    char=event.object
    source=event.string
    if Object_GetPrimaryState(char)==state:
        Object_SetPrimaryState(char,state,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makeBleedLifeDrained(char,source,intensity)

def BleedLifeDrainS(event,state,intensity):
    char=event.object
    source=event.string
    if Object_GetSecondaryStates(char)&state:
        Object_SetSecondaryState(char,state,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makeBleedLifeDrained(char,source,intensity)

def makeBleedLifeDrained(char,source,intensity):
    ffx.MPSendMessage(MP_BleedLifeDrain,Object_GetAttr(char,'ffxMPID'),Object_GetAttr(source,'ffxMPID'),intensity)
    if ffx.FFX_ObjectGetAttr(char,'BleedLifeDrainHandle',-1)==-1:
        handle=Object_PlayEffect(char,'****insert_the_name_of_your_fx_here*****','',FX_LOOP|FX_TRACK_OBJECT_FULL,0,'centre')
        ffx.FFX_ObjectSetAttr(char,'BleedLifeDrainHandle',handle)
        ffx.RegTimer('onBleedLifeDrain',1,0,char,source)
    ffx.FFX_ObjectSetAttr(char,'BleedLifeDrain',(1+intensity)*2)

def onBleedLifeDrain(event):
    char=event.object
    source=event.string
    drain=ffx.FFX_ObjectGetAttr(char,'BleedLifeDrain')
    drain=drain-1
    if Object_IsAlive(char)==0:
        drain=0
    if drain<=0:
        Object_StopEffect(char,ffx.FFX_ObjectGetAttr(char,'BleedLifeDrainHandle'))
        ffx.FFX_ObjectSetAttr(char,'BleedLifeDrainHandle',-1)
    else:
        ffx.RegTimer('onBleedLifeDrain',2,0,char,source)
        ffx.FFX_ObjectSetAttr(char,'BleedLifeDrain',drain)
    intensity=ffx.FFX_Rand(1,3)+drain/2
    Trigger_Damage(char,intensity)
    Trigger_Damage(source,-intensity)
FFX add-on for FFvsTTR at ffx.freedomforce4ever.com

bearded

I don't want it to be blocked by invulnerable. A puncture type attack, like wolverine's adamsntium vs iron man's armor. Life Drain heals the attacker every time the victim takes damage.
I tried something like this, but it didn't register. Is it because I changed the scripts in the mod folder? Should I change the scripts in the Data folder instead?

Epimethee

You shouldn't touch the Data folder, in FFX3, everything is in the mod's folder. Are the carriers set in ffxcustom.py under FFX_CARRIERS=[?

To check if the code is running you could add print statements inside your functions and check mission.log or the in-game console to see if they appear. Does using the default vampiric life drain from ffx2.py work?

By the way, I had been under the impression that we already had a bleeding state swap? There is one in ffx.py, but it's incomplete (there's at least one error in the code preventing it to work).

I've updated the code a bit, removing the healing of the attacker and adding a print statement for stun to bleed. Caveat emptor, I can't test the code...
#################### bleeding swap ################################################
# This is almost exactly like the existing life drain swap but ---add your
# description here
# -Bearded
##############################################################################################

MP_bleedingv2=15

def stuntobleedingv2(event):
    print "===== BLEEDING: bleedingv2P() Physical state swap" # TEMP!
    bleedingv2P(event,PCSTATE_STUNNED,1)
def hypnosistobleedingv2(event):
    bleedingv2P(event,PCSTATE_HYPNOTISED,ffx.COST_HYPNO)
def ragetobleedingv2(event):
    bleedingv2P(event,PCSTATE_ENRAGED,ffx.COST_RAGE)
def exiletobleedingv2(event):
    bleedingv2P(event,PCSTATE_EXILE,ffx.COST_EXILE)
def blanktobleedingv2(event):
    bleedingv2P(event,PCSTATE_BLANK,ffx.COST_BLANK)
def panictobleedingv2(event):
    bleedingv2P(event,PCSTATE_PANICKED,ffx.COST_PANIC)
def frozentobleedingv2(event):
    bleedingv2P(event,PCSTATE_FROZEN,ffx.COST_FROZEN)
def stasistobleedingv2(event):
    bleedingv2P(event,PCSTATE_STATIC,ffx.COST_STASIS)

def hextobleedingv2(event):
    bleedingv2S(event,SCSTATE_HEXED,ffx.COST_HEX)
def blindtobleedingv2(event):
    bleedingv2S(event,SCSTATE_BLIND,ffx.COST_BLIND)
def powernulltobleedingv2(event):
    bleedingv2S(event,SCSTATE_POWER_NULLIFICATION,ffx.COST_NULL)
def weakentobleedingv2(event):
    bleedingv2S(event,SCSTATE_WEAKENED,ffx.COST_WEAKEN)
def speeddecreasetobleedingv2(event):
    bleedingv2S(event,SCSTATE_SPEED_DECREASED,ffx.COST_DECREASE)

def densitytobleedingv2(event):
    char=event.object
    source=event.string
    if ffx.densityaltered(char):
        Object_SetGenericState(char,OBJSTATE_DENSITY_CHANGE,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makebleedingv2ed(char,source,ffx.COST_DENSITY)

def bleedingv2P(event,state,intensity):
    print "========== BLEEDING: bleedingv2P() Physical state swap" # TEMP!
    char=event.object
    source=event.string
    if Object_GetPrimaryState(char)==state:
        Object_SetPrimaryState(char,state,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makebleedingv2ed(char,source,intensity)

def bleedingv2S(event,state,intensity):
    char=event.object
    source=event.string
    if Object_GetSecondaryStates(char)&state:
        Object_SetSecondaryState(char,state,0,REMOVE_STATE)
        ffx.FFX_UpdateStates(char)
        makebleedingv2ed(char,source,intensity)

def makebleedingv2ed(char,source,intensity):
    print "=============== BLEEDING: makebleedingv2ed()" # TEMP!
    ffx.MPSendMessage(MP_bleedingv2,Object_GetAttr(char,'ffxMPID'),Object_GetAttr(source,'ffxMPID'),intensity)
    if ffx.FFX_ObjectGetAttr(char,'bleedingv2Handle',-1)==-1:
        handle=Object_PlayEffect(char,'****insert_the_name_of_your_fx_here*****','',FX_LOOP|FX_TRACK_OBJECT_FULL,0,'centre')
        ffx.FFX_ObjectSetAttr(char,'bleedingv2Handle',handle)
        ffx.RegTimer('OnBleedingV2',1,0,char,source)
    ffx.FFX_ObjectSetAttr(char,'bleedingv2',(1+intensity)*2)

def OnBleedingV2(event):
    char=event.object
    print "==================== BLEEDING: OnBleedingV2() character ," # TEMP!
    print char # TEMP!
    drain=ffx.FFX_ObjectGetAttr(char,'bleedingv2')
    drain=drain-1
    if Object_IsAlive(char)==0:
        drain=0
    if drain<=0:
        Object_StopEffect(char,ffx.FFX_ObjectGetAttr(char,'bleedingv2Handle'))
        ffx.FFX_ObjectSetAttr(char,'bleedingv2Handle',-1)
    else:
        ffx.RegTimer('OnBleedingV2',2,0,char)
        ffx.FFX_ObjectSetAttr(char,'bleedingv2',drain)
    intensity=ffx.FFX_Rand(1,3)+drain/2
    Trigger_Damage(char,intensity)


FFX add-on for FFvsTTR at ffx.freedomforce4ever.com