Please login or register.

Login with email, password and session length
 

News:

Happy 15th Birthday, Freedom Force!


Author Topic: Issue 44: Active Defense Coding problem.  (Read 18824 times)

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #540 on: October 27, 2017, 05:00:24 PM »
Ok, spyder you kinda lost me there. I didn't change anything in  the datfiles.py and the power still workis in game without crashes. Do i still need to do that?


Also i have no idea where the m25ai file is or how to add the Ai tactic  :P. Every AI i have made is through the AI generator in-game.


Edit: Ok if i understand this correctly the campaignchangeactivedefense function is if you want the AD to be longer than 10 seconds. In my case 10 seconds is exactly the duration i want. So, do i still need to do the first paragraph that spyder wrote?

Ok, so you won't actually modify anything in the datfiles.py.

Do you have anything that can run python scripts? If not, download this: http://www.mediafire.com/file/8pvl4i96grgqu6l/FFvtTR_Ghosting_Fix.zip

In it, there will be a readme file. Go ahead and follow the instructions in that file. After you go through it, you will have PythonWin installed.

From there, you will right-click on the datfiles.py in your ffx3/Missions/Scripts folder and select "Edit with PythonWin"

Once that window is up, follow the instructions above.

While you might have this particular AD working just the way you want it, there might be some ADs that you'll want to last longer than 10 seconds. Following the method in my previous post will allow for ADs that have Medium (20) and Long (30) durations, and more.

Another technique is just creating a dummy character in EZHero, give that character an AD that is exactly how you like it, then import that character with EZHero. That will put the AD in the game, but if you ever edit that power in FFEdit, you'll have to import the AD again.

As for the m25AI tactic for FFAD, you can find it in the ffx3/Manual/index.html file. Just open that file in any browser of your choice and go to the AI Tactics section. There is a LOT to learn in there and it's a really good read.
« Last Edit: October 27, 2017, 05:01:55 PM by spydermann93 »

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #541 on: October 27, 2017, 05:15:27 PM »
Ah, pythonwin, i have that and i have used the ghost fix before. It's a good method to remember. My main concern now is the m25ai tactic. if i understand it correctly if i don't put it in when the character is controlled by the AI he won't use the AD even if it's fully functional? That's a problem considering graviton is a glass cannon. So i go to the tactic section and i will know what i need to do next?

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #542 on: October 27, 2017, 05:31:52 PM »
I'm sorry another thing i need to clarify. In the tactics when i should put the power name does it mean the FFEdit power name? graviton's AD is called mvgraviton_s in FFedit.

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #543 on: October 27, 2017, 06:25:12 PM »
You shouldn't have to specify it in the tactics

Here's what you use for FFActiveDefense:

Code: [Select]
"TActiveDefenseFFRemote(pct=50, time=3, energy=33, mindist=0, maxdist=200, type='friend', subtype='not active_defense', situation='none', role='none', priority='medium')",

Use the FF Active Defense Remotely on an ally.

"TActiveDefenseFFSelf(pct=100, time=3, energy=33, mindist=0, maxdist=400, type='enemy', subtype='none', situation='not active_defense', role='none', priority='medium')",

Use the FF Active Defense on yourself.

You can adjust all of the parameters, but since a character can only have one FFActiveDefense, there is no need to specify any names.

This tactic is NOT to be confused with the ActiveDefense tactic:

Code: [Select]
"TActiveDefense('power name', pct=80, time=3, energy=None, mindist=0, maxdist='long', type='enemy', subtype='none', situation='not displaced', role='none', priority='high', defense_time=None)",
Notice that this tactic is TActiveDefense() while the tactic for the FFActiveDefense attribute is TActiveDefenseFFRemote() or TActiveDefenseFFSelf()

Offline BentonGrey

  • Titans
  • Hero Member
  • Posts: 14435
    • The Greylands
Re: Issue 44: Active Defense Coding problem.
« Reply #544 on: October 27, 2017, 06:27:07 PM »
I'm really glad you got it working, Jim!  I am far from certain, but I wonder if the culprit might be the space in the name.  Despite the fact that the default powers have spaces, FFEdit and the system sometimes doesn't like spaces.  I try to avoid them in whatever I do.  You're right in that it shouldn't have been the name length, but I was grasping at straws.

Thanks for the duration change instructions, Spyder!  I've always just copied an existing AD that I knew was the length I wanted, because that functionality is missing from FFEdit.

Also, thanks for the AI info!  I need that as well!
God Bless
"If God came down upon me and gave me a wish again, I'd wish to be like Aquaman, 'cause Aquaman can take the pain..." -Ballad of Aquaman
Check out my DC voicepacks at my yahoo group.
http://games.groups.yahoo.com/group/bentongrey/
http://games.groups.yahoo.com/group/bentongrey2

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #545 on: October 27, 2017, 06:46:00 PM »
I'm really glad you got it working, Jim!  I am far from certain, but I wonder if the culprit might be the space in the name.  Despite the fact that the default powers have spaces, FFEdit and the system sometimes doesn't like spaces.  I try to avoid them in whatever I do.  You're right in that it shouldn't have been the name length, but I was grasping at straws.

Thanks for the duration change instructions, Spyder!  I've always just copied an existing AD that I knew was the length I wanted, because that functionality is missing from FFEdit.

Also, thanks for the AI info!  I need that as well!

Copying the power, at least in my experience, has always reset the Active Defense length to short. Using that script was the only way I could get an FFAD to be longer than 10 seconds.

Now, I haven't fully and extensively tested that, but maybe the original active defenses don't get their length changed when copied?

And don't thank me on the m25AI info. It's all in that wonderful manual. There are a lot of really good nuggets of info in there, and it's just amazing that so much documentation was written for it. Big props to Dr Mike and M25! If anybody else has written to that doc, my thanks to you guys and gals, too!

EDIT: I took a look at the FFADs in your MA mod, Benton, and it does seem like you're right! That's really handy to know. Perhaps it's just when you save an ffactivedefense that it resets to short? hmmm...
« Last Edit: October 27, 2017, 06:52:12 PM by spydermann93 »

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #546 on: October 28, 2017, 08:01:49 AM »
You shouldn't have to specify it in the tactics

Here's what you use for FFActiveDefense:

Code: [Select]
"TActiveDefenseFFRemote(pct=50, time=3, energy=33, mindist=0, maxdist=200, type='friend', subtype='not active_defense', situation='none', role='none', priority='medium')",

Use the FF Active Defense Remotely on an ally.

"TActiveDefenseFFSelf(pct=100, time=3, energy=33, mindist=0, maxdist=400, type='enemy', subtype='none', situation='not active_defense', role='none', priority='medium')",

Use the FF Active Defense on yourself.

You can adjust all of the parameters, but since a character can only have one FFActiveDefense, there is no need to specify any names.

This tactic is NOT to be confused with the ActiveDefense tactic:

Code: [Select]
"TActiveDefense('power name', pct=80, time=3, energy=None, mindist=0, maxdist='long', type='enemy', subtype='none', situation='not displaced', role='none', priority='high', defense_time=None)",
Notice that this tactic is TActiveDefense() while the tactic for the FFActiveDefense attribute is TActiveDefenseFFRemote() or TActiveDefenseFFSelf()

Ok spyder just one more thing before i put it in the m25aidata file. If i just copy/paste the line you posted in the graviton section without any specification since it's his only FF Active Defense will it work? Also does it matter if paste the line in the end or in the middle of the section. Graviton's section btw looks like this:

['mvgraviton',
   ['target enemy',
      'weakness_melee_crushing',
      'not staticked',
      'weakness_ranged_crushing',
      'weakness_area_crushing',
      'weakness_direct_crushing',
   ],
   ["timer", 'auto',
      'TUseRemedy()',
      "TFleeMelee(mindist='medium',movetype='fly',time=0.88)",
      'TFleeMelee(type="any",subtype="emitting_damage",time=0.88)',
      'TTK()',
      'TArea("mvgraviton newton\'s theory",time=1.27)',
      "TArea('mvgraviton gravitational hold',time=2.07)",
      'TArea("mvgraviton jupiter\'s gravity",time=1.27)',
      "TDirect('mvgraviton 200 g-force',time=1.27)",
      "TRanged('mvgraviton graviton blast',time=1.27)",
      "TDirect('mvgraviton 0 g-force',time=1.27)",
      "TDirect('mvgraviton graviton cocoon',time=1.27)",
      "TRanged('mvgraviton maximum gravity be',time=1.27)",
      "TMelee('mvgraviton megalomaniac punch',time=1.4)",
      'TLand()',
      'TMoveTo(mindist=\'long\' ,subtype="not emitting_damage",time=0.88)',

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #547 on: October 28, 2017, 03:39:48 PM »
Yes, it will be the only AD he'll use since you can only have one FFActiveDefense on a character at a time.

Placement only matters if you want to alter the "priority" of the power. What happens is that the AI will go down the list of powers in the AI file and randomly land on one. Powers higher on the list will typically be used more often, but you can alter the parameters of the power to give it a higher priority.

Typically, defenses are usually placed right before the offensive powers, but after the "flee melee" lines and the occasional FFX attributes, but you can place it wherever you want it. Below is a very simple example:

['mvgraviton',
   ['target enemy',
      'weakness_melee_crushing',
      'not staticked',
      'weakness_ranged_crushing',
      'weakness_area_crushing',
      'weakness_direct_crushing',
   ],
   ["timer", 'auto',
      'TUseRemedy()',
      "TFleeMelee(mindist='medium',movetype='fly',time=0.88)",
      'TFleeMelee(type="any",subtype="emitting_damage",time=0.88)',
      'TTK()',
      TActiveDefenseFFSelf(time=3, type='enemy', situation='not active_defense')
      'TArea("mvgraviton newton\'s theory",time=1.27)',
      "TArea('mvgraviton gravitational hold',time=2.07)",
      'TArea("mvgraviton jupiter\'s gravity",time=1.27)',
      "TDirect('mvgraviton 200 g-force',time=1.27)",
      "TRanged('mvgraviton graviton blast',time=1.27)",
      "TDirect('mvgraviton 0 g-force',time=1.27)",
      "TDirect('mvgraviton graviton cocoon',time=1.27)",
      "TRanged('mvgraviton maximum gravity be',time=1.27)",
      "TMelee('mvgraviton megalomaniac punch',time=1.4)",
      'TLand()',
      'TMoveTo(mindist=\'long\' ,subtype="not emitting_damage",time=0.88)',


Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #548 on: October 29, 2017, 06:45:24 AM »
Thanks a lot pyder and everyone who has chimed in. Coding always scared but i think i learned  thing or two the past days. You have been a huge help. I will try it and i ill report back  :D.

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #549 on: October 29, 2017, 08:38:28 AM »
Ok, so i put Spyder's line in the m25aidata and he now uses the AD in-game although sparingly. The file looks like that:

['mvgraviton',
   ['target enemy',
      'weakness_melee_crushing',
      'not staticked',
      'weakness_ranged_crushing',
      'weakness_area_crushing',
      'weakness_direct_crushing',
   ],
   ["timer", 'auto',
      'TUseRemedy()',
      "TFleeMelee(mindist='medium',movetype='fly',time=0.88)",
      'TFleeMelee(type="any",subtype="emitting_damage",time=0.88)',
      'TTK()',
                "TActiveDefenseFFSelf(time=3,type='enemy',situation='not active_defense')",
      'TArea("mvgraviton newton\'s theory",time=1.27)',
      "TArea('mvgraviton gravitational hold',time=2.07)",
      'TArea("mvgraviton jupiter\'s gravity",time=1.27)',
      "TDirect('mvgraviton 200 g-force',time=1.27)",
      "TRanged('mvgraviton graviton blast',time=1.27)",
      "TDirect('mvgraviton 0 g-force',time=1.27)",
      "TDirect('mvgraviton graviton cocoon',time=1.27)",
      "TRanged('mvgraviton maximum gravity be',time=1.27)",
      "TMelee('mvgraviton megalomaniac punch',time=1.4)",
      'TLand()',
      'TMoveTo(mindist=\'long\' ,subtype="not emitting_damage",time=0.88)',

In order for him to use it more do i have to add a priority value in the end? Make it priority=high?

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #550 on: October 29, 2017, 07:19:52 PM »
That will probably work, yeah

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #551 on: October 30, 2017, 08:33:12 AM »
Unfortunately it didn't  :(. I put a priority='high' in the end of the sentence and it caused him to not use it all in-game. In order for you to get the picture in an average 10 minute RR of Absorbing Man (me) vs Graviton (AI) graviton used the AD 3-4 before the priority line. After i put it in the end he didn't use the power at all. I also noticed that after the altering he didn't chase me throughout the man and stayed in one spot. Something changed int he AI? Again for reference this is how graviton's ai looks in the m25aidata file:

['mvgraviton',
   ['target enemy',
      'weakness_melee_crushing',
      'not staticked',
      'weakness_ranged_crushing',
      'weakness_area_crushing',
      'weakness_direct_crushing',
   ],
   ["timer", 'auto',
      'TUseRemedy()',
      "TFleeMelee(mindist='medium',movetype='fly',time=0.88)",
      'TFleeMelee(type="any",subtype="emitting_damage",time=0.88)',
      'TTK()',
                "TActiveDefenseFFSelf(time=3,type='enemy',situation='not active_defense')",
      'TArea("mvgraviton newton\'s theory",time=1.27)',
      "TArea('mvgraviton gravitational hold',time=2.07)",
      'TArea("mvgraviton jupiter\'s gravity",time=1.27)',
      "TDirect('mvgraviton 200 g-force',time=1.27)",
      "TRanged('mvgraviton graviton blast',time=1.27)",
      "TDirect('mvgraviton 0 g-force',time=1.27)",
      "TDirect('mvgraviton graviton cocoon',time=1.27)",
      "TRanged('mvgraviton maximum gravity be',time=1.27)",
      "TMelee('mvgraviton megalomaniac punch',time=1.4)",
      'TLand()',
      'TMoveTo(mindist=\'long\' ,subtype="not emitting_damage",time=0.88)',

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #552 on: October 30, 2017, 10:54:06 PM »
hmm... looks like I have some experimenting to do

Offline Cyber Burn

  • Hero Member
  • Posts: 7980
Re: Issue 44: Active Defense Coding problem.
« Reply #553 on: October 30, 2017, 11:53:22 PM »
Ok!!! What language are you guys speaking already???  :banghead:

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #554 on: October 31, 2017, 02:04:31 AM »
Hey Jim,

Try something like this line:

"TActiveDefenseFFSelf(pct=60,mindist=100,time=4,,situation=['not active_defense','higherenergy 66'],priority=50)",

Also, make sure that you don't have the power tabbed like your text. I'm not sure if it's that way in your m25ai file, but try keeping all of the lines aligned.

For example, here's my Spider-Man file:

Code: [Select]
['m spider-man',
["target enemy",
'weakness_melee_crushing',
'not staticked',
'weakness_ranged_crushing',
],
["timer", 'auto',
'TUseRemedy()',
"TActiveDefenseFFSelf(pct=60,mindist=100,time=4,,situation=['not active_defense','higherenergy 66'],priority=50)",
'TFleeMelee(type="any",subtype="emitting_damage",time=3)',
"TRangedCone('funnel web',time=3)",
"TMelee('acrobatic spider',time=2.84)",
"TRanged('tangling webs',time=3)",
"TRanged('web bullet',time=3)",
"TMelee('spidey sting',time=2.8)",
'TThrow(pickup_time=3,throw_time=3)',
'TMoveTo(mindist=\'medium\' ,subtype="not emitting_damage",time=3)',
],
]

EDIT: Also, if you need any help with this, Cyber, just let me know and I'll do my best to assist ya. I'm in the process of learning how this all works, but I *think* I'm starting to get a handle on it.
« Last Edit: October 31, 2017, 02:07:04 AM by spydermann93 »

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #555 on: October 31, 2017, 09:17:12 AM »
The thing is that my AD has 33 energy cost and i prefer it this way so will this change the cost of the power? Oh and the lines are perfectly aligned in the file, it's just a weird thing that happens when i paste it here.
« Last Edit: October 31, 2017, 09:19:06 AM by Jimaras8 »

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #556 on: October 31, 2017, 09:30:48 AM »
Copied/pasted the line exactly as you wrote it spyder and it didn't work. now he floats completely inactive.

Edit: I don't know if it's any help to you spyder but so far the only line that has worked sufficiently in-game was the first one you gave me when only the necessary values:
"TActiveDefenseFFSelf(time=3, type='enemy', situation='not active_defense')

The only problme i had with this one was the frequency he used the AD. otherwise he was moving and using all his abilities. I don't know if this helps clear this whole situation up.
« Last Edit: October 31, 2017, 09:54:02 AM by Jimaras8 »

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #557 on: October 31, 2017, 11:50:16 PM »
I'm wondering if it's because he is flying. I notice that whenever I have my characters use it (when controlled by me), they land before using the power.

My Spider-Man has Rope-Swinger, so he lands after a while, and it may have been coincidental. I'll have to play around with it some more.

Offline Jimaras8

  • Hero Member
  • Posts: 756
Re: Issue 44: Active Defense Coding problem.
« Reply #558 on: November 01, 2017, 07:13:17 AM »
Yes there is something weird about it. When i play the character and every character with a FF AD they have to land to use it. Graviton as AI can use it in the air. It's weird.

Offline spydermann93

  • Hero Member
  • Posts: 3819
Re: Issue 44: Active Defense Coding problem.
« Reply #559 on: November 05, 2017, 06:10:25 PM »
Ok, so I was fiddling around with it and I think I found the answer.

In the m25ai.py file, there is a function that handles how the AI uses the TActiveDefenseFFSelf() tactic:

Code: [Select]
def TActiveDefenseFFSelf(tactic_id, char, object, flt, user, pct=50, time=1, energy=None, mindist=0, maxdist=200, type='enemy', subtype='none', situation='none', role='none', priority=TACTIC_PRIORITY_MEDIUM):
if ffx.FFX_ObjectGetAttr(char,'ffactivedefenseMaxHP')==0:
return 0
target = Target_GetCurrentTarget(char,type,subtype)
defense_time = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,3)
power = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,2)
epCost = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,7)
if not AISupport_CheckConditions(char, target, Target_GetDistance(char,type), pct, priority, mindist, maxdist, subtype, situation, role, energy=epCost):
return 0
if ffx.FFX_ObjectGetAttr(char,'ffactivedefenseSelf',0)==1:
return 0
turnTo(char,target)
AISupport_DoFunction(char, 'ffx.OnffActiveDefense(%s,%s)'%(`char`,`char`), target, priority, time, desc='ff active defense')
AddRole(char,power)
AddRole(char,'active_defense')
ffx.FFX_ObjectSetAttr(char,'ffactivedefenseSelf',1)
m25event.SetTimer(defense_time,'AIActiveDefenseOff',char,power)
return 1

There is also a function that dictates how the AI handles the TActiveDefense() tactic:

Code: [Select]
def AIGenericActiveDefense(tactic_id, char, object, flt, user, power='', defense_time=20, pct=80, time=3, energy=0, mindist=0, maxdist=m25distance.DISTANCE_LONG, type=TARGET_ENEMY, subtype=None, situation=None, role=None, priority=TACTIC_PRIORITY_HIGH, desc='active defense'):
target = Target_GetCurrentTarget(char)
if not AISupport_CheckConditions(char,target,Target_GetDistance(char),pct,priority,mindist,maxdist,subtype,situation,role,energy):
return 0
AISupport_DoSelfPowerTimed(char, power, target, priority, time, desc)
AddRole(char,power)
AddRole(char,'active_defense')
m25event.SetTimer(defense_time,'AIActiveDefenseOff',char,power)
return 1

Notice that there is a difference in the parameters of the two functions. AIGenericActiveDefense() has a pct of 80 and a priority of HIGH while TActiveDefenseFFSelf() has a pct of 50 and a priority of MEDIUM. Well, I copied those parameters from TActiveDefense() and this is what I got:

Code: [Select]
def TActiveDefenseFFSelf(tactic_id, char, object, flt, user, pct=80, time=1, energy=None, mindist=0, maxdist=200, type='enemy', subtype='none', situation='none', role='none', priority=TACTIC_PRIORITY_HIGH):
if ffx.FFX_ObjectGetAttr(char,'ffactivedefenseMaxHP')==0:
return 0
target = Target_GetCurrentTarget(char,type,subtype)
defense_time = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,3)
power = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,2)
epCost = ffx.getByTemplate(char,FFX_FFACTIVEDEFENSE_CUSTOM,7)
if not AISupport_CheckConditions(char, target, Target_GetDistance(char,type), pct, priority, mindist, maxdist, subtype, situation, role, energy=epCost):
return 0
if ffx.FFX_ObjectGetAttr(char,'ffactivedefenseSelf',0)==1:
return 0
turnTo(char,target)
AISupport_DoFunction(char, 'ffx.OnffActiveDefense(%s,%s)'%(`char`,`char`), target, priority, time, desc='ff active defense')
AddRole(char,power)
AddRole(char,'active_defense')
ffx.FFX_ObjectSetAttr(char,'ffactivedefenseSelf',1)
m25event.SetTimer(defense_time,'AIActiveDefenseOff',char,power)
return 1

Once I got that written, I also went to my heroName.m25ai file and added this line:

Code: [Select]
"TActiveDefenseFFSelf(time=2.0,situation='not active_defense')",
It is very simple, but it's all that I need for right now.

I launched the game and tested it, and now the AI actively uses and reuses the FFActiveDefense! Hurray!

One thing to note is that the AI will wait, at a minimum, the amount of time that you specified in your FFX_FFACTIVEDEFENSE_CUSTOM section of the ffxcustom2.py file to use the FFActiveDefense again. I'm going to toy around with it some more to try and get the AI to reuse the FFActiveDefense as soon as its HP runs out, but I don't think that this function is updated every second like the functions in the ffx.py.

For those that want the AI to prioritize FFActiveDefense, here's the file: http://www.mediafire.com/file/em98ivdiulf53dd/m25ai.zip
« Last Edit: November 05, 2017, 06:12:05 PM by spydermann93 »