Forums Gallery LOGIN |REGISTER

Community Archive is read-only - Here you can view content recorded up until February 2017. To join the latest discussions visit our new forums


melee\ranged attack on custom AI[SOLVED]

Please use this forum for questions on C++, Lua, XML, and any other languages used in CryENGINE development.


 

User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

melee\ranged attack on custom AI[SOLVED]

Postby pamy88 » 19.10.2012, 03:12

Hi, I would have a little question about my chars(aliens, non biped).
I did create my own AI class(VS c++), I did setup idle sequence, walk and run using the animationgraph girltest.xml renamed as "mycustom".xml; now I can use flowgraph nodes AI goto etc and it works, but I would now using my melee(claw) and ranged attack(spit) animations so if for istance I add an AI grunt and an AI "custom" they attack each other.
I need a little advice on how to proceed!Thank you!
Last edited by pamy88 on 28.10.2012, 22:33, edited 1 time in total.
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 20.10.2012, 00:19

For the melee, you could use something like this:

AI.BeginGoalPipe("melee_attack");
AI.PushGoal("firecmd",0,FIREMODE_MELEE);
AI.PushGoal("locate",0,"atttarget",1000);
AI.PushGoal("bodypos",0,BODYPOS_STAND);
AI.PushGoal("run",0,2);
AI.PushGoal("stick",1,0, 0, STICK_BREAK);
AI.EndGoalPipe();
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 20.10.2012, 00:45

Thank you for the reply faith, I didnt understand precisely how use the strings that you did suggest me; I found a PipeManagerExamples.lua in Cryengine\Game\Scripts.pak\Scripts\AI\GoalPipes\ that contains something similar to what you said but I have not clear the pipeline to make them work. If you have the patience to explain me how I ve to proceed..

Correct me if I'm wrong, maybe I ve to copy string in a new text file called for example GoalPipeMelee.xml then add it to original pipemanager.lua?I'm trying just now to learn more about scripting but I havent luck yet.

thank you for your patience..

P.S. as there is a way to load run\walk\idle anim on a existing animationgraph is there one to load a melee_attack and ranged_attack animations to it?Or I have to do it necessarily by flowgraph or selection trees?
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 20.10.2012, 13:49

Yeah you could make your own goalpipe file but you'll need to register it. If you want just paste it into PipeManagerExamples.lua. Once it is in there you can then use

entity:SelectPipe(0, "melee_attack");

to call it from a behavior file.

Yes, you can add them to your existing animation graph under the menu Graph>>Add State. If you need to you can connect the state by holding shift and dragging. Just don't right click in there, it will crash. :P
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 20.10.2012, 20:21

Hi feith Thank you!all is a bit more clear now but unfortunately you overrated me :-) and I ve still some doubts!

1)In animation graph-humanmalefullbody.xml I did try to find some view or state regarding combat to use them as reference but I didnt find anything then, in short, I thought that adding melee and ranged anims to animationgraph is possible but not necessary, isnt'it?

2)I add the strings to Pipemanagerexamples.lua just before end; now I ve to use that string u said entity:SelectPipe(0, "melee_attack"); somewhere(but where ?( ) to can call the behavior in game but the engine doesnt know what anim has to use...what a mess...

Sorry but the only pipeline I know(and just in theory) is create a ST in selectiontrees->create a goalpipe in Goalpipes->create luas in personalities->register in pipemanager.lua but I havent got success yet!
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 20.10.2012, 21:03

Ok...I think I understand. You have a custom melee animation you want to call? I would create a new state in the graph. Add a new signal to that state. From the behavior you do this:

AI.BeginGoalPipe("melee");
AI.PushGoal("animation", 0, AIANIM_SIGNAL, "meleeSignal");
AI.EndGoalPipe();

This will execute the animation. Don't worry about connecting the state to anything just add it to the graph. If your still confused maybe read up on the freesdk docs to get a better idea of the big picture.

Another way would be to create your own melee weapon where you could send the signal from there instead of from a goalpipe. Hope that helps.
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 20.10.2012, 23:09

Thank you faith and yes, you right, I ve a custom melee attack animation but not a weapon cause weapons are claws themselves(I dont know how this changes my setup)..and my goal is to make a battle simulation with custom entities.

Now to recap:
1)create a new state in the view "locomotion"(where I ve idle,walk,jump and run) and I call it melee_attack. I dont link this state to anything.
2)for add signal I think you mean a input(type signal)..this has to have some particular setup?
3)add last strings u said to pipemanagerexamples.lua(and forget strings from second post)
4)?

While I take advantage of your kindness I ll continue to study hardly on docs but it's so weird!

Thank you so much!
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 21.10.2012, 14:19

Ok, then I would create a claw weapon.

1. Correct
2. Yeah, input signal, can be any value just as long as it maps to your weapons xml(i.e <animation target="owner" name="meleeSignal" />)
3. No, add the code from the 2nd post to pipemanagerexamples.lua(you'll see it looks similar to everything else in there) and if you use a weapon just forget about the other code. That code just calls your animation but if you use a weapon, the signal will come from the weapon so you won't have to call it manually.

You will need to call that melee_attack goalpipe in your behavior lua file.

More info about setting up the weapon:
viewtopic.php?f=314&t=93575

Keep at it! :D
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 21.10.2012, 16:22

Hi faith!!Your help is very appreciated, yesterday I ve tried using this http://freesdk.crydev.net/display/SDKDO ... l+Playback (from obsolete anim graph) but just because obsolete I have not found some parameters like template and when I try to use "specific value" in signal state's selection critera the editor crashes!

I m sorry and I'll seem a bit slow-witted but I just want to be sure!!
If I undestand correctly I ve 2choices: use a weapon that is the claw itself or dont use it and call a simple animation.
I would try both ways cause I m trying to learn more about AI, but I'd like try the "no weapon way" first(cause I think is easier).

Just to recap(I m only expert on recap):
1)Add strigs(from sec post) to pipemanagerexamples;
2)Create a new state melee_attack and copy\paste animation name in animation slot
3)Go in input panel->select signal->add a key for melee_attack in key properties->return in melee_attack state's selection criteria and give to signal->specific value->melee_attack.
4)Go in \Game\Scripts\AI\Behaviors\Personalities\Skeleton_hydralisk and create a .lua called melee_attack with last strings u said exactly as you did write them. Or maybe I ve to change animation with my name animation e melee signal with name I used in signal->add key. ?(

With this attempt, when I switch in game, my char runs towards of me, the rifle compares in initial position(stands still) and he kills me using it X( (cant see the melee animation at all); so..as usually I did something wrong. :puppy:
I'll raise a statue of you!Thank you in advance!!
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 21.10.2012, 17:49

All correct up until step 4. I would look at the grunts behavior files and create something similar to start with. You'll need to set up behavior files for your character with a selection tree. Then inside of the behavior file you will use that call animation code. It will make sense once you play around with it more. :)

http://freesdk.crydev.net/display/SDKDOC5/AI+Scripting
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 21.10.2012, 18:39

Do u mean I ve to recreate the whole process?!create something like seek.lua, idle.lua and melee_attack.lua in \personalities\, a Goalpipe"custom" in \Goalpipes\, register it in pipemanager.lua and a selectiontree in \SelectionTrees\ ?:-( there is no chance for a shortcut!?Finally I need only a little melee anim!!...It seems so hard..

When I use a default behavior all seems to work good, the difference is that my custom has no a weapon, is there no way to tell the engine to use "hands" with a animation instead of use a gun?...
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 21.10.2012, 20:30

Try taking everything out of AIs equipment pack except for fists and see what happens.
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 21.10.2012, 22:16

I probably need a weapon bone to do this cause fists are weapon isnt it?I ve to find a plce to set my weapone bone(cause he does not have now), anyway, If this attempt doesnt work I'll probably try the weapon way and I try to use the Zombie AI thread and the other about weapon you linked me before...I really hope that I can do it!!Thank you for now, I did abuse your patience enough!I'll study a bit then I'll let you know!
User avatar pamy88
Intern Dev
Intern Dev
 
Posts: 148
Member since: 18.07.2012, 00:10
Likes: 0

Re: melee\ranged attack on custom AI

Postby pamy88 » 22.10.2012, 04:25

I m working very hardly...!

1)I did as you suggest me, I did put on primary fists(doent work) then I did exclude all weapon and ammo from AI equipment and leave it only fists; my custom kills me with fists probably but without the melee animation...

2)Before put pause in BST learn and play in weapon setup, I did a last try; I found a little example here http://seithcg.com/wordpress/?page_id=1567and I setup all accordingly to the tutorial and changing all "swordsman" with "skeleton_hydralisk" that is my custom and changing local range from 2.5 to 1.5. When I switch in game my char does idle, approach, seek perfectly but when he attacks me there is no attack animation(even if I remove all from AI equipment), and compares this in the console
[Warning] Item owner 'Skeleton_hydralisk1' doesn't have third-person item attachment point 'right_item_attachment'!
so I assume that the problem now is link my melee_animation with attack.lua; I'm so near....If I can ask this last thing, how I can use it without attaching a weapon_bone to my char?Is it possible?Thank you very much...

P.S. My char doesnt attack other entities(different factions) anymore with the custom behavior, he tries to "seeking" me and look in my direction even thought I m not in game ?( and it compares this console message
[Warning] Invalid Animation ID: -1 [File=objects/characters/skeleton_hydralisk/skeleton_hydralisk.chr]
User avatar faith113
Regular Dev
Regular Dev
 
Posts: 513
Member since: 22.04.2012, 15:00
Likes: 52

Re: melee\ranged attack on custom AI

Postby faith113 » 22.10.2012, 15:04

Ok cool...you are still using the fists weapon right? So, you can either make your own weapon or modify the fists. If you look at Game\Scripts\Entities\Items\XML\Weapons\Fists.xml you will see some tags like '<animation target="owner" name="melee_punch_swing_left" />' this is the call for what animation to use. There are ones for first person and third(owner is third). The name corresponds to your signal you created in your graph. Try changing those to your signal to test it.


cron