[font="Verdana"]
[/font]
[font="Verdana"]I'm pretty new to AI programming, but I am familiar with event driven development. My game currently has a system for Behavior action events which can be anything that defined a behavior of an object. For example, AnimationBehavior, MovementBehavior, IdleBehavior, AttackBehavior...etc. I am also currently using javascript in some small places, but I decided from the beginning that I was going to eventually implement a much game logic as possible via script...to make it easier for others to work on without them needing a full IDE environment and compiler. I will admit that I do still get a bit confused with event driven development at times, so I'm sure that my trouble right now is probably because of that..but really what I am trying to figure out is WHERE things should be..[/font]
[font="Verdana"]
[/font]
[font="Verdana"]For example, let's say I want a zombie to roam around until he spots the player (or a living human). Now, I figured that this is a local event to the zombie itself which can be handled via a behavior class such as "LookForHumans" so once the behavior spots a human, it sets the zombies target and notifies it that a human is in site, which then, the zombie (which is the controller?) will then react to the event by say, starting it's MovementBehavior with the targets position as a parameter for location (of course this would get updated every ai think tick). Once the movement is satisfied (ie. the distance between the zombie and the destination is within range) the movement behavior then sends event to the zombie... Now...here's one place I'm confused.. [/font]
[font="Verdana"]
[/font]
[font="Verdana"]
[/font]
[font=Verdana]if(event == movement) attack_behavior.enable()[/font]
[font=Verdana]
[/font][font=Verdana]
[/font]
[font=Verdana]but what if there is no target? Attack makes no sense. My though is this, though this is probably obvious... Simply create an instance of MovementBehavior called "move_to_target" which when it's received in the zombies event handler, it knows it's finally caught the target. The attack behavior can then simply notify the zombie again if the target is null. [/font][font=Verdana]Am I right in my think here as far as the basic AI goes? This in theory, will all be handled via script.[/font]
[font=Verdana]
[/font]
[font=Verdana]Now, triggers and events... A TriggerEvent may be fired by another game object, such as a tile on the ground, when touched, would send a TriggerEvent like so:[/font]
[font=Verdana]
[/font]
[font="Verdana"]broadcast(new TriggerEvent("activate_poison_darts", this) // where as this refers to the (activator?)[/font]
[font=Verdana]
[/font]
[font=Verdana]
[/font]
[font="Verdana"]Several questions here...[/font]
[font=Verdana]
[/font]
[font=Verdana]My thinking is that, this would register the event with the AIManager which would then pass it along to ALL other actors. When the poison darts (or the object that shoots them) sees the event "activate_poison_darts" it then runs the method that fires the poison darts. This of course would definitely be a scripted event. However, where would this event be defined?? Should their be just a single script file for each level in which all logic for that level is defined? Also, in a case like the above, HOW will the script know when the object was touched?? It would need to listen for an event to be received it's self.. So using my behavior system...maybe have a ScriptedBehavior class and then exposed them to the script at run time? Hmmm.....[/font]
[font=Verdana]
[/font]
[font="Verdana"]Also, what about game events such as "player_entered_end_zone"? Should that possible be done like: broadcast_game_event(...) in which a WorldListener listens for?[/font]
[font="Verdana"]
[/font]
[font="Verdana"]I know this is probably quite a lot to tackle. I've been researching all of this for the past few days, but these are the things I was just really confused on how I might go about implementing...so thanks a ton if you help!![/font]
[font=Verdana]
[/font]
[font=Verdana]
[/font]