What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

Trying to solve turret rotation issue

Kurt Knispel

New Member
Joined
Jul 3, 2014
Messages
19
Reaction score
0
Well, as known, default tank behaviour doesn,t manage turret facing when moving.

WOT turret tanks facing depends on camera facing (if you move mouse, you move camera, and turret moves where camera is facing), so I'm going to use this to make turret face to front as we move vehicle so that it makes a little more difficult for players to detect our bot, report us, and get banned.

Lets start by some basic aspects:

When moving, we must have a Vector3 to move to
When facing camera, we must pass a Vector3 to look at

But, what the hell is Vector3? As it says, it is just a vector, based on 3 positions/coordinates, usually x,y,z corresponding to the 3d axis. To reference them, we can use Vector3 (the whole vector) or one of them (Vector3.x; Vector3.y; or Vector3.z) and there is another way to use it; Vector3.forward; Vector3.Up; Vector3.Right; Vector3.Left;

So, it depends on our interests how we will use it to take profit and achieve our objective.

Now lets try to code something usefull with this.

I will use DefaultBattleRoutine.cs code: we have this function

Code:
public Composite CreateRoamBehaviour()
        {
            return new PrioritySelector(ctx => ObjectiveManager.FirstObjective, // Objective as context please. Kthx!
                CommonBehaviours.CreateWaypointNavigationBehaviour(),
                // If we're out of waypoints to navigate, just rush the objective from where we are currently.
                new Decorator(ret =>
                    {
                        [B]var objective = ret as WotObjective;[/B]
                        if (objective == null)
                            Logging.Write("[{0}] Objective is null, something went terribly wrong!", ScyllaWot.Me.Arena.Name);
                        return objective != null && [B]objective.Location != Vector3.Zero;[/B]
                    },
                    new Sequence(
                        CommonBehaviours[B].MoveToAndStop[/B](ret => (ret as WotObjective).Location.Value, 10f, true),
                        new Action(ret => { Poi.Current = new Poi(PoiType.Objective, "Moving to complete objective", (ret as WotObjective)); })
                    )
                )
            );
        }

I have put in bold things that maybe suit what we are looking for, a variable, a vector, a method..... let's try to use it

We can do following; Create a new protected Vector3 in class, to make it accesible but not visible, assing it a value, use it.


Create a new protected Vector3 in class
Go to the top of class and add line as shown here;

Code:
    public class DefaultBattleTank : ITankRoutine
    {
        public Composite RoamBehaviour { get { return CreateRoamBehaviour(); } }

        public Composite CombatBehaviour { get { return CreateCombatBehaviour(); } }

        [COLOR="#0000CD"]protected Vector3 Direction;[/COLOR]


Assing it a value
Just under first line in bold in the very first code add;

Code:
var objective = ret as WotObjective;
  [COLOR="#0000CD"]Direction = objective.Location;[/COLOR]

Use it.
Finally, just before ending CreateRoamBehaviour function add

Code:
     );
   [COLOR="#0000CD"]Camera.LookAt (Direction);[/COLOR]
}

Ready, I will compile this afternoon and see what happens. I'm afraid it wouldn't work, but its a beggining.....
 
Last edited:
Google Translator generated a BSOD on this... :p



Sounds awesome!
 
I am curious to hear what the result of the first test was....
 
Didn't work

Well, it was an approach, I will keep trying solutions.

First of all, we need to gain access to Camera (compiler does not recognize it and is throwing an error), so first step is add

Code:
using Scylla.Wot.Objects.Environment;

to our class to access Camera

Next error is an assignment error, so maybe we can try to replace sentence and initialize Direction to fix it

Code:
Direction = new Vector3(objective.Location);
or
Code:
Direction = new Vector3(objective.GetActualLocation());

Unfortunatelly I can not test code till afternoon; till then I will keep on reading documentation and search more options
 
Last edited:
After changing some this errors dissapeared, but it makes nothing.

I've decided do it from scratch instead of modifying existing code.

First attempt is to access camera just in garage, not in battle, so let's go ahead with this test. I've called plugin FixCamera and its only purpouse is to move camera looking at vehicle in garage as we click to activate plugin in TL window (without running bot)

Test 1: GARAGE

Code:
using System;
using System.Windows;
using System.Windows.Forms;
using Scylla.Common;
using Scylla.Common.Plugins;
using Scylla.Common.Math;
using Scylla.Wot;
using Scylla.Wot.Objects;
using Scylla.Wot.Objects.Environment;

namespace Scylla.CommonBot.Plugins
{

    public class FixCamera : IPlugin
    {
		protected Vector3 Direction;
		protected WotVehicle bot;
        public bool Equals(IPlugin other)
        {
            return Name == other.Name && Version == other.Version;
        }

        public string Author { get { return "Kurt Knispel"; } }
        public Version Version { get { return new Version(1, 0); } }
        public string Name { get { return "FixCamera"; } }
        public string Description { get { return "FixCamera to vehicle."; } }
        public Window DisplayWindow { get { return null; } }

        public void OnPulse()
        {
        }

        public void OnInitialize()
        {
            
        }

        public void OnShutdown()
        {
        }

        public void OnEnabled()
        {
			Logging.Write("FixCamera plugin enabled.");
			bot = ScyllaWot.Me.Vehicle;
				Direction =  bot.Position;
				Camera.Instance.LookAt (Direction);
        }

        public void OnDisabled()
        {
			
        }
		
		
    }
}

It works fine, camera moves to back of vehicle in garage as we click plugin
 
Tried battle; nothing to do with camera on it (tested in automatic and key input management)

I've used ScyllaWot.Me.Vehicle to access tank properties and methods; tested with IsMoving in a function and used Position and Yaw properties; tryied with ScyllaWot.Me.GunRotator to access also Yaw and Pitch to use Camera.Instance.Set and ScyllaWot.Me.GunRotator,Update methods but there is no way to make it work with camera.

Next step is try to rotate turret to face vehicle direction instead of camera every time vehicle is moving.

Maybe Aevitas, highvoltz or superreeen can give some light about this?
 
Last edited:
Attemp to move turret

Code:
var BotRotation = Scylla.Wot.Objects.WotLocalPlayer.Vehicle.Yaw;
			var BotGun = Scylla.Wot.Objects.WotLocalPlayer.GunRotator;
			BotGun.Update(BotRotation, BotGun.GunPitch, 10, 10);

Nothing happens....
 
In fact, when my student loans come in, I will DONATE him a lifetime key.
 
Would love to see this fixed, easiest way to tell a bot is to just watch the turret.. oh yeah and to watch them endlessly circle, oh, and to watch them run into something at full speed and just keeping full throttle while being stuck ... ;)
 
Back
Top