• Welcome to Freedom Reborn Archive.
 

random energy blast!

Started by seraglio, April 03, 2007, 08:19:12 PM

Previous topic - Next topic

seraglio

Hello all. I wanted to get a little help with a project I am working on. My recent kick has been randomization. I've made 3 power swaps that have varying effects. The first was a "critical strike" swap. It does damage like mentaldamage, but instead of fixed damage it does a percentage of the targets maxHP, so that its equally effective on strong targets. Then it rolls a number of random"physical" effects in an attempt to emulate an injury. Effects like long term stuns, density, vertigo, weaken etc. The second is a "mentalblast". I got the idea from using Alteration with several power swaps. I wanted an attack that does minor damage but inflicts random mental states like blank, fear and rage. Both of these seem to be working. I need help on my third, EnergyBlast.

def makeenergyblast(char,source,intensity):
    ebrand=randint(1,4)
    if ebrand==1:
        AI_SetEnabled(char,0)
        Trigger_Power(char,char,'energyblast1','',intensity)
        ffx.Mission_StatusText('energy!')
        AI_SetEnabled(char,1)
        ebrand=randint(1,4)
    if ebrand==2:
        AI_SetEnabled(char,0)
        Trigger_Power(char,char,'energyblast2','',intensity)
        ffx.Mission_StatusText('fire!')
        AI_SetEnabled(char,1)
        ebrand=randint(1,4)
    if ebrand==3:
        AI_SetEnabled(char,0)
        Trigger_Power(char,char,'energyblast3','',intensity)
        ffx.Mission_StatusText('radiation!')
        AI_SetEnabled(char,1)
        ebrand=randint(1,4)
    elif ebrand==4:
        AI_SetEnabled(char,0)
        Trigger_Power(char,char,'energyblast4','',intensity)
        ffx.Mission_StatusText('electrical!')
        AI_SetEnabled(char,1)
        ebrand=randint(1,4)



This piece of codebashed junk works 90% of the time. The 4 energyblasts are direct attacks, set to low and the energy type specified. The only trick is that the target calls the energyblast on himself. That way I dont have to deal with my hero getting frozen in an animation. The direct attacks are set to "stunned" for an animation which I think works even though there is no contact on stunned. It looks cools since the target looks hurt when the power is triggerred. The power scales nicely for damage since the intensity variable is carried over as power level, more powerful swaps like hypnosis(intensity3) do way more dmage than density max(intensity1). Perfect candidate for energy surge since an energy attack shouldnt be resistable anyway.

I have 2 problems I have been working on. One it doesnt work as a stun swap. No idea why but I dont think the fact that the animations are set to stun is it. For that matter the power won't work if there is a stun either on the trigger power or the energyblast in powers.dat

Two, sometimes it doesnt trigger. I think its because the targets AI is too busy in the middle of an animation to perform the stun animation, it gets interrupted mid-way and the power never triggers. It may also be because the stun animation doesnt have a contact, have to test that. Thats why I added the AI_SetEnabled(char,0) line, in an attempt to briefly turn off AI to assure it completes the anim and triggers the power. I think its still too fast though. How can I set a 'wait state'? I want the AI off for a good second to assure the power is triggered.

If I can get this to work the next step is to make an adaptive version that keeps track of damage done to baddies and picks the most damaging blast!

Any othe criticism or advise that might help is greatly appreciated. My other power swaps use a similar randomization, constantly recalling the randint or FFX_rand after the power is triggered. Is thier a better way?

seraglio

Just another thought after some more testing. Another strange thing is that sometimes low powered power swaps do high damage. Like denstiy max usually does like 6-13, but sometimes I get 20s or even high 30's against targets with no vulneribilities to any of the energies. No idea why, I dont figure its bad since I like random.

But then I was thinking maybe it DOES trigger all the time but sometimes just does NO DAMAGE! Where should I put in some test text to indicate whether damage took place or not?

Let me know if posting the rest of the basic code is worthwhile...

M25

You can set up a timer to introduce a delay between the power going off and the AI being turned back on (the code here uses a 1 second timer).  I'm pretty sure you're using FFX, so to play nice with the custom AI you should use m25ai.AIDisable(char) and m25ai.AIEnable(char) to turn the AI on and off.


def makeenergyblast(char,source,intensity):
    ebrand=randint(1,4)
    m25ai.AIDisable(char)
    if ebrand==1:
        Trigger_Power(char,char,'energyblast1','',intensity)
        ffx.Mission_StatusText('energy!')
    elif ebrand==2:
        Trigger_Power(char,char,'energyblast2','',intensity)
        ffx.Mission_StatusText('fire!')
    elif ebrand==3:
        Trigger_Power(char,char,'energyblast3','',intensity)
        ffx.Mission_StatusText('radiation!')
    else:
        Trigger_Power(char,char,'energyblast4','',intensity)
        ffx.Mission_StatusText('electrical!')
   #restart the AI for char in 1.0 seconds
    js.Event_RegisterSink(js.EVENT_TIMER, 'energyblast_restoreAI', char, '', 1.0, 0, 0)

def makeenergyblast_restoreAI(event):
    m25ai.AIEnable(char)



There's still the possibility that the triggered power will get interrupted by other code or in-game events, so it likely won't work 100% of the time.

seraglio

saweeet thanks!!!!! I'll try this out now. I'm using ffx2.6 by the way. Awesome thanks for your help.

seraglio

I'm playing FF, FFx 2.6 if that matters M25. I cant find any reference to that command, and its not working. Was thier a similar command in FF?


M25

Which command?

If it's the AI stuff, that's odd, but it's been a while since I looked at  :ff:.    Try it without the m25ai. prefix ( AIEnable(char) and AIDisable(char) ) or just use  AI_SetEnabled(char, 0) and AI_SetEnabled(char, 1) in place of AIDisable and AIEnable.


seraglio

thanks a ton for the help M25. I wasnt sure how best to use if/elf/else..your example has helped me clean up tons of random stuff I wrote that was being triggered more than once..thanks.

As for what m25 AI is in ffx 2.6 i'm not sure..heres what I see elsewhere in the code

m252.m25Disable(civ)
cshelper.disable(source)

Also listed under PLUGGABLE FUNCTIONS FOR PAIN RESPONSE/LAST RESORT

def m25_Disable(char):
    if Object_Exists(char):
        Object_SetAttr(char, 'enabled', 0)
        Object_SetAttr(char, 'ai_priority', 99)
        cshelper.disable(char)

def m25_Enable(event):
    char=event.object
    if Object_Exists(char):
       Object_SetAttr(char, 'enabled', 1)
       Object_SetAttr(char, 'ai_priority', 0)
       if Object_GetAttr(char, 'ai_nostandardai') == 0:
           enable(char)


I redid the code as you suggested, it indeed works better, but I tried the m25_disable/enable route and the Enable would never trigger:


def makeenergyblast(char,source,intensity):
    ebrand=randint(1,4)
    m25_Disable(char)
    if ebrand==1:
        Trigger_Power(char,char,'energyblast1','',intensity)
        ffx.Mission_StatusText('energy!')
    elif ebrand==2:
        Trigger_Power(char,char,'energyblast2','',intensity)
        ffx.Mission_StatusText('fire!')
    elif ebrand==3:
        Trigger_Power(char,char,'energyblast3','',intensity)
        ffx.Mission_StatusText('radiation!')
    else:
        Trigger_Power(char,char,'energyblast4','',intensity)
        ffx.Mission_StatusText('electrical!')
   #restart the AI for char in 1.0 seconds
    js.Event_RegisterSink(js.EVENT_TIMER, 'energyblast_restoreAI', char, '', 1.5, 0, 0)

def energyblast_restoreAI(event):
    char=event.object
    m25_Enable(char)
    ffx.Mission_StatusText('AI ENABLED!!!')



So curently I am replacing m25_enable/disable with regular AI_enable/disable for now, which works great, but I don't use AI extensively yet.

Also this still doesnt work as a stun swap. No error in log, stun condition is removed but power is not triggerred although my screen text says it should be. Wasn't critical anyway, but any suggestions are appreciated. I have another damage over time power swap that triggers a direct power on char, from char every 2 seconds and it works fine as a stun swap. :banghead:


Thanks again for all the help!