News › Forums › RAIN › Sample Projects, How To, and Code › Example custom action - attack script
This topic contains 4 replies, has 3 voices, and was last updated by ImmortalFlamingMonkey 8 months, 2 weeks ago.
September 1, 2022 at 5:27 pm #33087
Does anyone have a basic example script of a custom action whereby the ai attacks a player.
Just something basic, so that I can build upon it.
CarmeSeptember 2, 2022 at 10:52 pm #33097
Can you be more specific? I wouldn’t normally create a single custom action for ai attacking a player. I would create a whole behavior tree describing various strategies, actions, etc.
What are you looking to do?September 3, 2022 at 7:34 pm #33107
Hi, thanks for replying.
Yes, I have a BT, works fine. Ai has multiple sensors, notices a player, chases them, comes to with 2 yards or 2 units and then stops, mech animations work fine. I can then for instance get the ai to animate an attack - but of course that does no damage. I wanted to randomise an attack, from say one of four choices, hence I wanted (I believe) a custom action script to randomly pick an attack, then play that mech animation, then do damage via raycast or collider, probably a combination of both, collider for melee and raycast for a ranged magic attack.
I just wanted an example (if some kind soul had one) of something similar so I can get cracking and build upon it.
or do I just use rain for pure movement and use a normal (not rain c# script). Can I combine both, or must it be some kind of rain script only, I would have thought everything in using rain/controlled by rain would be smoother or from rain would be better. waffling a bit, lost a bit, direction needed and would love an example..
September 3, 2022 at 8:08 pm #33109
- This reply was modified 10 months, 2 weeks ago by carme.
I would use RAIN for all the behavior, not just movement.
In your case, I would:
1) Use a Random node to select the attack and play the proper animation
2) Use a Sensor to determine whether or not I can damage the target (although you could write a custom action for this)
3) Transmit the damage to the gameplay code via a custom action. In other words - somewhere in your game code you will have a means for tracking damage/health for each entity. A custom action in your BT is where you will link the AI behavior (firing a weapon) to the effect (hitting a target, causing damage, triggering FX).
Rival Theory will be putting out a demo scene later this month showing a firefight between a group of soldiers. It should demonstrate clearly how we would handle these issues and how to use RAIN to control AI and gameplay.October 31, 2022 at 11:09 am #33828
Would I be able to do the same with a medieval type game.
You must be logged in to reply to this topic.