News:

Rings of Reznor!

Main Menu

Attribute Hack

Started by yell0w_lantern, February 09, 2011, 09:34:26 PM

Previous topic - Next topic

yell0w_lantern

Kenn inspired me to look at increasing the strength cap for characters. I used the heavy lifter code but as I look at it I'm thinking that I may have snafu'd things with the "def Checkliftableobjects" because I have a copy of that code after each extra strength entry.

###########################Extra Strength 5##############################################

def initextrastrength5(char,update=0,remove=0):
    if remove:
        FFX_ObjectSetAttr(char,'extrastrength5',0)
        CheckLiftableObjects(char, remove)
        return
    #Ep. 2007-03-24: Corrected stupid bug I introduced. Added delay so attribute would get registered correctly as it is checked in CheckLiftableObjects().
    #    2006-08-29: Encapsulated attribute detection for compatibility with new system; removed unused update=
    if not (hasAttribute(char, 'extrastrength5')):
        FFX_ObjectSetAttr(char,'extrastrength5',1)
        RegTimer('OnHeavyLifter', 0.5, 0, char)

def Onextrastrength1(event):
    char = event.object
    CheckLiftableObjects(char)

# Run this initially and periodically to see if new throwable objects need to be added.
# stumpy 2006-09-12: We could potentially trigger this as a regSpawnObject() sink.  Have to test for efficiency gain/loss.
def CheckLiftableObjects(event,remove=0):
    if isinstance(event,types.StringType):
        char = event
    else:
        char = event.object
    maxLiftableMass = getMaxLiftableMasses() #Ep. 2006-08-29: made into a function, as simlar code was used elsewhere
    strength = Object_GetAttr(char,'strength')
    liftStrength = strength + 5
    liftableMass = maxLiftableMass[int(strength)]
    newLiftableMass = maxLiftableMass[int(liftStrength)]
    throwable = filter(lambda o: Object_GetAttr(o,'throwable'),Mission_GetObjects())
    liftable = filter(lambda o,NLM=newLiftableMass: Object_GetAttr(o,'mass')<=NLM,throwable)
    liftable = filter(lambda o,LM=liftableMass: Object_GetAttr(o,'mass')>LM,liftable)
    if not ( ( ( hasAttribute(char, 'heavylifter') or hasAttribute(char, 'heavy lifter') ) == 0 ) or ( remove ) ):  # add lift commands
        for obj in liftable:
            Mission_RemoveCustomAction('Pickup',char,obj)
            Mission_CustomAction('Pickup',char,obj,'HeavyLift',2000,0)
        RegTimer('CheckLiftableObjects',5,0,char)
    else:   # remove the lift commands from these objects
        for obj in liftable:
            Mission_RemoveCustomAction('Pickup',char,obj)


and Level Ten has pretty much the same thing:

def CheckLiftableObjects(event,remove=0):
    if isinstance(event,types.StringType):
        char = event
    else:
        char = event.object
    maxLiftableMass = getMaxLiftableMasses() #Ep. 2006-08-29: made into a function, as simlar code was used elsewhere
    strength = Object_GetAttr(char,'strength')
    liftStrength = strength + 10
    liftableMass = maxLiftableMass[int(strength)]
    newLiftableMass = maxLiftableMass[int(liftStrength)]
    throwable = filter(lambda o: Object_GetAttr(o,'throwable'),Mission_GetObjects())
    liftable = filter(lambda o,NLM=newLiftableMass: Object_GetAttr(o,'mass')<=NLM,throwable)
    liftable = filter(lambda o,LM=liftableMass: Object_GetAttr(o,'mass')>LM,liftable)
    if not ( ( ( hasAttribute(char, 'heavylifter') or hasAttribute(char, 'heavy lifter') ) == 0 ) or ( remove ) ):  # add lift commands
        for obj in liftable:
            Mission_RemoveCustomAction('Pickup',char,obj)
            Mission_CustomAction('Pickup',char,obj,'HeavyLift',2000,0)
        RegTimer('CheckLiftableObjects',5,0,char)
    else:   # remove the lift commands from these objects
        for obj in liftable:
            Mission_RemoveCustomAction('Pickup',char,obj)


I think I'm in over my head.
Yellow Lantern smash!

stumpy

What exactly are you trying to do? Are you trying to give a character a higher strength attribute only in certain situation (as the HEAVY LIFTER attribute does)? I'm not quite sure what you mean by "strength cap".
Courage is knowing it might hurt, and doing it anyway. Stupidity is the same. And that's why life is hard. - Jeremy Goldberg

yell0w_lantern

I know philosophically some folks disagree with going beyong the 10 point attribute spread but a recent hero file thread post by Kenn X got me interested in playing with strength above 10.

Since my last post I scrapped the above attempt and used the following code that commented out of FFX.

def initextrastrength5(char,update=0):
    if update==0:
        str=Object_GetAttr(char,'strength')+5
        Object_SetAttr(char,'strength',str)
        Object_SetAttr(char,'baseStrength',str)
        Object_SetAttr(char,'templateStrength',str)


I wanted both heavy lifter and extra strength available to different characters anyway.

Unfortunately, many FFX attributes do not seem to function in the Rumble Room so I haven't had a chance to test it in the campaign.
Yellow Lantern smash!