Simple enemies
by Jonathan Rose · in Torque Game Engine · 08/29/2005 (2:16 pm) · 2 replies
I must confess that I'm still somewhat of an amateur when it comes to programming in Torque, so if I could get some advice by those more accomplished than myself, then that would be great. And no, I'm not silly enough to be asking if "this is possible"... of course it is :P I have the source! Anyway, I tried to hunt for a good way to do this that would be an easy starting point, but failed to find anything useful, so I figured I would try to get a discussion started on it and try to evolve it from there, and if it turns out good, maybe even get a good new resource posted eh?
What I am trying to do, is create a method for scripting extremely simple (in comparison to AI used to control players) enemies that operate by flying (just simple movement, and I'll worry about working out collision and pathfinding later) at the player, stopping, and shooting a predefined weapon. I assume it should work similar to the player class, in that it creates an entity with a weapon and nodes and things, but I would be needing to create the class (let's call it the attackdrone class to simplify things) with some fundamental concepts from the AIPlayer class or perhaps the AI vehicle class so that it can make these little bots target a specific player, float over to it, either stop or make another maneuver from that point (determined by that particular drone types AI part of the script).
So anyway, what I'm really looking for is a starting point to this :P I was just going to tweak the player class into something different, but then I ended up getting slightly confused at what I would end up needing to get rid of and needing to keep, so I sort of became a little more keen to the idea of start with something a little more bare-bones. So I guess I could just use a session of getting pointed in the right direction more than anything else.
Lets assume I want to make the rudimentary class allow for these to be part of the script for a particular attackdrone:
The first section of the script defines the cs file that defines the dts, texture, and dsq animations (which initially would only include a root animation of course).
Section two defines the weapons that are mounted to particular nodes for the attackdrone from other weapons scripts (for instance, mounting a crossbow to mount0 and a rocketlauncher to mount1)
Section three defines the amount of damage the attackdrone can sustain
Section four defines the activation distance for the attack drone to target a player
and finally,
Part five determines actions taken against the player upon being targeted, including:
set target move delta at target location and specified/arbitrary distance away
look/rotate at player
fire weapon (and which mounted weapon to fire)
and others could easily be added to the source after conception
I guess it ends up being a bit more complicated than ultra-simple, since I want it to be dynamic enough to be used for more than one type of drone really, but it certainly shouldn't be as complex as the stuff thats been done already with the player and vehicle classes and their complex AI.
Any help getting started with this would be great. Advice to :P
What I am trying to do, is create a method for scripting extremely simple (in comparison to AI used to control players) enemies that operate by flying (just simple movement, and I'll worry about working out collision and pathfinding later) at the player, stopping, and shooting a predefined weapon. I assume it should work similar to the player class, in that it creates an entity with a weapon and nodes and things, but I would be needing to create the class (let's call it the attackdrone class to simplify things) with some fundamental concepts from the AIPlayer class or perhaps the AI vehicle class so that it can make these little bots target a specific player, float over to it, either stop or make another maneuver from that point (determined by that particular drone types AI part of the script).
So anyway, what I'm really looking for is a starting point to this :P I was just going to tweak the player class into something different, but then I ended up getting slightly confused at what I would end up needing to get rid of and needing to keep, so I sort of became a little more keen to the idea of start with something a little more bare-bones. So I guess I could just use a session of getting pointed in the right direction more than anything else.
Lets assume I want to make the rudimentary class allow for these to be part of the script for a particular attackdrone:
The first section of the script defines the cs file that defines the dts, texture, and dsq animations (which initially would only include a root animation of course).
Section two defines the weapons that are mounted to particular nodes for the attackdrone from other weapons scripts (for instance, mounting a crossbow to mount0 and a rocketlauncher to mount1)
Section three defines the amount of damage the attackdrone can sustain
Section four defines the activation distance for the attack drone to target a player
and finally,
Part five determines actions taken against the player upon being targeted, including:
set target move delta at target location and specified/arbitrary distance away
look/rotate at player
fire weapon (and which mounted weapon to fire)
and others could easily be added to the source after conception
I guess it ends up being a bit more complicated than ultra-simple, since I want it to be dynamic enough to be used for more than one type of drone really, but it certainly shouldn't be as complex as the stuff thats been done already with the player and vehicle classes and their complex AI.
Any help getting started with this would be great. Advice to :P
#2
I'll see of that player tweak works for what I want though, but it would create a good bit more performance hit than something designed to do only what I need it to :)
08/31/2005 (9:16 am)
I was thinking to do it with C++ and create a new type of entity actually.I'll see of that player tweak works for what I want though, but it would create a good bit more performance hit than something designed to do only what I need it to :)
Torque Owner Brian "Bazz" Staudinger
AIplayer and make up some new functions something like this one. I made my player fly like this.
Bit of a hack but it may work ok?
function AIPlayer::FlyToAndAttack(%this)
{
%this.setAimObject($targetObject);//point at target
%vec = %this.getEyeVector();//get direction vec
%vec = vectorScale(%vec, 20);//set speed
%vec = vectorAdd(%vec,"0 0 200");// Add 200 z
%this.applyImpulse("0 0 0",%vec);//move the bot
%this.fire();//shoot
%this.schedule(20,FlyToAndAttack);//loop it
}