Jump to content

AITurrets are too weak


Code_Man

Recommended Posts

I have been trying to play with turrets but despite tweaking the hell out of them i must say they feel pretty weak and useless.


Is it correct that AITurret can only rotate in 180 degrees?

Is there some way to hack around this?


Also is the turret required to see a player in order to target him?

Would it be possible to have the turret attack the player instantanious once he is within line of sight?

Link to comment
Share on other sites

Well anything is possible, since you have the source code, it is just a question how much work it will be.


For example you could make the turrets always see the player no matter if there are walls etc and then raycast constantly if he is visible and then shoot instantly, thats how my bots work for example.

Link to comment
Share on other sites

I did some work on the turret and i agree with you. Is a bit meh. To better understand the how turrets work you should take a look at some unreal or unity turret tutorials. After that you will have a better understanding. My opinion is that we need a new "general" turret tutorial and a new model. I started work on this but got stuck at the model part. Now i don't have time to finish it. I wish you good luck.

Link to comment
Share on other sites

I think that one of things to be sure and do is point the aiturret in the direction

it is to guard against else , as in my case , you could walk right up behind it .

Leads me to believe that it isnt scanning 360 degrees . Maybe the idea is so not to

have it turn against its own team .


Remember the datblock names where these fields are found , they can be refered to as

TurretBulletProjectiloe.directDamage and AiTurretHeadImage.projectileSpread , should

you wisht to access them in scripts .

*unless Im mistaken of course .


you could try these few edits to some default datablocks below . Everything is in

the one file mentioned below .


I'd like to add that the easiest way is to create a new datablock in the datablock

editor , Then you can hack away at whatever you like without worry of messing up

the original file . You can then assing your AI turret the new datablock , but in

my case it created a new object with the new datablock name which i can add through

the world editor , ..neato .

 

// ./art/datablocks/weapons/turret.CS
 
//---------------------------------------
 
datablock ProjectileData( TurretBulletProjectile )
{
   projectileShapeName = "";
 
   directDamage        = 500;//default = 5//<-------------THIS HELPS , 1 hit is 500 DMG 
   radiusDamage        = 0;
   damageRadius        = 0.5;
   areaImpulse         = 0.5;
   impactForce         = 1;
 
   damageType          = "TurretDamage";  // Type of damage applied by this weapon
 
   explosion           = BulletDirtExplosion;
   decal               = BulletHoleDecal;
 
   muzzleVelocity      = 120;
   velInheritFactor    = 1;
 
   armingDelay         = 0;
   lifetime            = 992;
   fadeDelay           = 1472;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod          = 1;
};
 
//------------------------------------------------
datablock AITurretShapeData(AITurret)
{                                    
   // Rotation settings                 //JUST EXPERIMENT WITH THESE AND DONT GET DISCOURAGED 
                                        //The numbers to the right of the remarks are defaults
   minPitch = 90;//15//<-------------------------
   maxPitch = 90;//80//<-------------------------
   maxHeading = 180;//90//<----------------------
   headingRate = 359;//50//<---------------------
   pitchRate = 359;//50//<-----------------------
 
   // Scan settings
 
   maxScanPitch = 90;//10//<---------------------
   maxScanHeading = 180;//30//<------------------
   maxScanDistance = 300;//20//<-----------------
   trackLostTargetTime = 2;
 
   maxWeaponRange = 300;//30//<------------------
 
   weaponLeadVelocity = 0;
   accufire = 1;//-------------------------------not so sure what it is
 
//======================================== YOU CAN EXPERIMENT WITH THESE TO SEE
//======================================== HOW YOU CAN ASSIGN DIFFERENT WEAPON
//======================================== DATABLOCKS TO THE MOUNT/S PLACED IN
//======================================== THE MODEL
//
//THIS ONE IS THE DEFAULT AITURRET WEAPON
 
//   weapon[0] = AITurretHead;
//   weaponAmmo[0] = AITurretAmmo;
//   weaponAmmoAmount[0] = 10000;
//
//   maxInv[AITurretHead] = 1;
//   maxInv[AITurretAmmo] = 10000;
 
 
//tHIS WILL MOUNT THE LURKERGRENADELAUNCHER
 
   maxInv[LurkerGrenadeLauncher] = 1;
   maxInv[LurkerGrenadeAmmo] = 10;
 
   weapon[0] = LurkerGrenadeLauncher;
   weaponAmmo[0] = LurkerGrenadeAmmo;
   weaponAmmoAmount[0] = 10;
 
 
//-=============================================
 
 
datablock ShapeBaseImageData(AITurretHeadImage)
{
//   Basic Item properties
   shapeFile = "art/shapes/weapons/Turret/Turret_Head.DAE";
   emap = true;
 
//   Specify mount point
   mountPoint = 0;
 
//   Add the WeaponImage namespace as a parent, WeaponImage namespace
   provides some hooks into the inventory system.
   class = "WeaponImage";
   className = "WeaponImage";
 
   Projectiles and Ammo.
   item = AITurretHead;
   ammo = AITurretAmmo;
 
   projectile = TurretBulletProjectile;
   projectileType = Projectile;
   projectileSpread = "0.005";//0.02//<---------------- THIS HELPS ACCURACY                           
                                                      //YOU CAN EVEN MAKE IT
                                                      //ZERO          
 
//===========================================================

 

This is a really nice fun engaging Item for levels with lots of potential for good game play .

I havent even tried out the turret like the one mounted on the cheetah , Have to try my hand at

building a nice vehicle for just that .

Link to comment
Share on other sites

OK , this was necessary too . See the lifetime field . Its necessary for projectile covering longer distance .

datablock ProjectileData( TurretBulletProjectile )
{
   projectileShapeName = "";
 
   directDamage        = 500;//default = 5//<-------------THIS HELPS , 1 hit is 500 DMG 
   radiusDamage        = 0;
   damageRadius        = 0.5;
   areaImpulse         = 0.5;
   impactForce         = 1;
 
   damageType          = "TurretDamage";  // Type of damage applied by this weapon
 
   explosion           = BulletDirtExplosion;
   decal               = BulletHoleDecal;
 
   muzzleVelocity      = 120;
   velInheritFactor    = 1;
 
   armingDelay         = 0;
   lifetime            = 5000;//   992;//<----------------------at 992 the projectile only exists for a couple hundred meters ,
                                                  //,---------------------- 5000 seems to be 800 meters  , give or take . 
   fadeDelay           = 1472;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod          = 1;
};

 

The lead velocity seems a bit tricky with weird things happening close to the turret even turning away as i would walk forward in front of it . So, Im playing around with that now , as it seems quite useful for AI . Anyway , these couple of changes were quite effective , I think , and the turret turned out to be quite a bit more fun .

Link to comment
Share on other sites

  • 2 weeks later...

I read that a cone in the model of a turret is used as the scan angle specifier, however i dont know how exactly this works.

Does anyone know if such a cone could be used to make a full 360 scan angle or scans in multiple direction at the same time.

Is there a point in this kind of specification vs datablock field?


Another problem i have is that it seems i cannot read out the items in the ignore list, which is troublesome to me.


I havent done much experimentation with turrets otherwise so far.

Link to comment
Share on other sites

it's not so much a 'model' as a construction based on the entries to make a trigger and an set of angle checks. you can see the particulars of that right around https://github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/turret/aiTurretShape.cpp#L733


on the ignore list end, theres a few methods listed https://github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/turret/aiTurretShape.cpp#L1243-L1279 that'll let you drill down there. though personally, I found it far simpler to just stick to adding a U8 to shapebase for teams and doing up a compare in https://github.com/GarageGames/Torque3D/blob/development/Engine/source/T3D/turret/aiTurretShape.cpp#L373 and be done with it.

Link to comment
Share on other sites

Torque 3D Documentation Release 3.5.1


available at readthedocs.com


page 529


AiTurretShape

Shape file nodes

scanPoint node

If the scanPoint node isn't present within the shape file then the turret's world transform is used .

aimPoint node

If the aimPoint is not found on the turrets shape then the pitch node will be used .



page 618

turretShape

shape file nodes

heading -

pitch -


says both nodes are controlled by the turretShape code and shouldnt be animated by the artist , nor should

it have anything but its default transform applied to it .


p. 621

Turret Optional Animation Sequences "heading" and "pitch" will be played as the turret rotates . And

mentions , may be used for animating wheels or gears during the rotation .


I imported the DAE's into Blender and I didnt see any of the nodes mentioned here in the turret_head or

Turret_legs DAE files in the art/shapes/weapons/Turret folder .


--------------------------------------------------------------------------------------------------------

--------------------------------------------------------------------------------------------------------


Doesnt exactly clear it all up , but Id expect that you could probably animate the the scanPoint node or

its parent like with the eye node being animated throught moving the head node in a player model.

maybe 90 degrees right and left might achieve 360 degrees . but really it seems that scanning from the

turrets world transform while using the terrain type mask sounds like potential problem and it "appears"

that that is what is being done .

Link to comment
Share on other sites

  • 2 weeks later...

Strange thing , you can set up you turret with a wide scan field and walk straight up to it , as long as you're not exactly in the center . If you stand off to the side , it doesnt detect you . While in world editor , use the rotate tool and just nudge the object around very slightly and suddenly its scanning within the defined field and will detect you very nicely , up to 180 heading not 360 , so far .

These DAE's files show that all of the nodes "scanPoint ,aimPoint , heading , pitch" are in the model , however i cant find them when I import it to Blender 2.76 . I haven't determined what exactly is necessary for the scanning and aiming animations . Theres no "base" object in mine just a column-like object with all other nodes parented to it . its ugly and simple for testing /learning .

Link to comment
Share on other sites

My "custom" version , mentioned in the last post , seems to be scanning in 360 deg. . There's a bit in the turret source that says

scanPoint = -1

aimPoint = -1

In the datablock I added strings in place of the -1 , I don't really know what is expected to be in this field or if it actually is the reason for the change in behavior .

scanPoint = -"scanPoint"

aimPoint = "aimPoint"

there seems to be some sort of pitch problem , but its definitely scanning 360 degrees .

The weapon isnt following the target . or moving at all . just firing .

Link to comment
Share on other sites

  • 4 weeks later...

well, I tried t0 figure things out about the 360 deg scanning and was thouroughly frustrated . My efforts lead me to rotating the entire model around the z axis 70 or so degrees at a time . That provide a 360 degree scan . And thats all I could do to make to deployable turret scan 360 degrees , I tried adding nodes , switching nodes , reorienting nodes etc, even mounting the turret to a rotating model would still only scan ahead along the y axis . This , I guess I might start and stop using schedules at onAdd/onRemove time , keep the turret weapon hidden until a target is detected , maybe swap out a static model for while there is no target because i had to rotate the entire origin . In the deployable turret datablock I put a field -

rotateZ = "0 0 1 0" ;

 


to be used by the function . So , just call the function , pass in the client and object id and in this case it rotates 70 degrees , I guess . If you find my coding funny and/or weird and/or ridiculous , feel free to share the humor . It needs a little tidying up though . such as maybe using this instead of obj.GetDataBLock but you get the picture .

//function serverCmdRotateScanner(%client, %obj, %Rot, %timeMS)
function rotatescanner(%this, %obj)
{
%vec = %obj.getdatablock().rotationZ;
//echo("\c1VECTOR pt1 = " @ %vec);
%word3 = getword(%vec,3);
%word3 +=70;
 
if (%word3 >= 360){
%word3 -=360;
}
 
//echo("\c4GETWORD3 pt1 = " @ %word3);
%vec = setword(%vec, 3, %word3);
 
%obj.setfieldvalue(rotation,%vec);
//echo("\c3VECTOR NOW = " @ %vec);
%obj.getdatablock().setfieldvalue(rotationZ, %vec);
//echo("\c1DATABLOCK.ROTATION = " @ %obj.getdatablock().rotationZ);
 
}
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...