• Welcome to Freedom Reborn Archive.
 

Magnifying Magnetic2

Started by Urthman, March 15, 2007, 11:33:47 PM

Previous topic - Next topic

Urthman

I'd like to tweak the FFX attribute MAGNETIC (WEAK) (called magnetic2 in the FFX code) so it's not quite so weak.  Specifically, I'd like to add enough oomph to the repel and attract commands to do the equivalent of a medium knockback to one of Mr. Mechanical's Mech Men.

I think this is the bit of code in FFX.PY that I'd need to tweak, but I'm not sure which number(s) to modify and by how much:
#magnetic specials

def OnAttract(target,char):
    if chargeEP(char,FFX_EP_THROWMAG)==0:
        return
    OnTKPower(char,target,4)
    RegTimer('OnAttract2',1,0,target,char)

def OnAttract2(event):
    target=event.object
    char=event.string
    if hasAttribute(char,'magnetic'):
        makepull(target,char,16)
    else:
        makepull(target,char,1)

def OnRepel(target,char):
    if chargeEP(char,FFX_EP_THROWMAG)==0:
        return
    OnTKPower(char,target,4)
    RegTimer('OnRepel2',1,0,target,char)

def OnRepel2(event):
    target=event.object
    char=event.string
    direction=Vector_Sub(Get_ObjectPos(target),Get_ObjectPos(char))
    Trigger_Force(target,direction[0],direction[1],0.5,getMagnetForce(target,char),TF_ABSOLUTE)

def getMagnetForce(target,char):
    force=40*Object_GetAttr(target,'mass')
    if hasAttribute(char,'magnetic'):
        force=800*Object_GetAttr(target,'mass')
        if force>500000:
            force=500000
    else:
        if force>8000:
            force=8000
    if force<Object_GetAttr(target,'minForce'):
        force=Object_GetAttr(target,'minForce')
    return force


catwhowalksbyhimself

Is the regular Magnetic too powerful for you?

Urthman

Quote from: catwhowalksbyhimself on March 16, 2007, 04:58:02 AM
Is the regular Magnetic too powerful for you?

Yes.  I don't want the charcter to be able to magnetically lift cars, I just want him to have a more-powerful metal-only knockback attack.   As it is, magnetic (weak) can just barely make a character like man-bot or iron man fall over, which is hardly worth the energy cost of doing it.   I'd like to be able to knock them around a bit.

But thanks for the followup, cat.  You're really good about jumping in and saying, "Have you thought about doing it this way..." before someone goes and writes new code for something.

stumpy

The mech men weigh twice what a car does. If the character can do an attack that knocks back a mech man, ...

Nonetheless, just using the code you posted, you can tweak the factors that determine how much force is used. Here are the places where upping the numbers (you will have to play with it to see how much) should affect magnetic2.

  • In OnAttract2(), look at makepull(target,char,1)
  • In getMagnetForce(), look at force=40*Object_GetAttr(target,'mass').

Urthman

Quote from: stumpy on March 16, 2007, 09:06:04 AM
The mech men weigh twice what a car does. If the character can do an attack that knocks back a mech man, ...

Nonetheless, just using the code you posted, you can tweak the factors that determine how much force is used. Here are the places where upping the numbers (you will have to play with it to see how much) should affect magnetic2.

  • In OnAttract2(), look at makepull(target,char,1)
  • In getMagnetForce(), look at force=40*Object_GetAttr(target,'mass').

Seems possible to me that it could take a lot more power/energy (or at least a different kind of power) to lift, move, and throw a car in a controlled manner than to simply impart a force to it.

Thanks for the pointer, Stumpy.  That second line makes sense to me, but I'm not sure about the first one.  If I change the 1 to a 2 will that double the force?

stumpy

Quote from: Urthman on March 16, 2007, 10:48:20 AMSeems possible to me that it could take a lot more power/energy (or at least a different kind of power) to lift, move, and throw a car in a controlled manner than to simply impart a force to it.

It all depends on your concept of how the magnetic attributes work and how TK in general works. As far as the physics of it go, the same energy is required to throw a car 50 feet either way, but you could have a different idea about the coordination needed to do one operation versus the other. And, you are right that it takes a continuous effort to hold something up indefinitely instead of pushing it once and being done with it. (In other words, I can throw a 100 pound sack onto a truck with no problem, but if I have to stand there with it for half an hour, fatigue becomes an issue.)

Quote from: Urthman on March 16, 2007, 10:48:20 AMThanks for the pointer, Stumpy.  That second line makes sense to me, but I'm not sure about the first one.  If I change the 1 to a 2 will that double the force?

Yes.