Forums
Crymods :: Forums :: Forum :: Far Cry Mods
 
<< Previous thread | Next thread >>
Tank Turret
Go to page       >>  
Moderators: Tnlgg, sniper_m4, VET, eviltimes, Basss, 39Modder, Kiper
Author Post
pvcf
Wed Sep 17 2014, 08:28PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
Problem:
have a Tank, a Turret and a Canon, the Turret shell rotate in z-axis and not like the canon in y-axis too.

as we know there is currently no solution.
I have had currently some hours time and started to create a routine for and found out, why it was impossible up to now:
it seems there is no global function for Get cam/weapon Angles (wether first or third person, which are different !!).

so i have now created a new routine which can detect the weapon rotating angle on Tank in first person view and third person view (its a little bit complicated because in third person view the cam range is from -180 to 180 and in first person its from 0 to 360. thank you, whoever in crytek was responsible for that

as i now have that basic core routine, it should be easy to attach the Turret at the gun helper from Tank and give him the weapon z angle.

will post soon the code here.

btw.:
its totally different to the mounted weaponshield i have done for sniper, because there i have a weapon entity where i can simply get the angles with self:GetAngles(), but the vehicle canon is virtualized and i did not found a lua script for (only the params settings).
maybe its somewhere in basicweapon client on update but there i never know which is bound to a certain tank, and the tank itself have to be the master, to get the x,y,z positions and x,y angles from the tank.

[ Edited Wed Sep 17 2014, 08:33PM ]
Back to top
El
Wed Sep 17 2014, 08:49PM

Registered Member #265
Joined: Thu Feb 18 2010, 06:17AM
Posts: 542

Tank is great news pvcf. You are a scripting god. wink.png

Then all I need is a plane or helicopter I can fly.
Back to top
pvcf
Wed Sep 17 2014, 08:54PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
wrote ...
Then all I need is a plane or helicopter I can fly.


do your homeworks

http://www.moddb.com/mods/farcry-operation-clearing/videos/singleseater1
http://www.moddb.com/mods/farcry-operation-clearing/videos/rpg-system-full-finished-and-working

tank turret:
have inserted support for AI driven tanks too, now i currently in the subroutine which really creates the turret und mount it to the tank.
Back to top
pvcf
Wed Sep 17 2014, 10:04PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
ok, turret is autospawned, automounted and autorotated, laod/savestalbe, now i try to get it editor stable (this is very complicated because of onreset command of autospawned things).

i now have the problem that the gun have some lazy-weapon setting which can't be overrided with the lazy weapon setting in farcry config menu, will post a video soon which shows the problem. wow, there are so many clips and traps -.-
Back to top
pvcf
Wed Sep 17 2014, 11:10PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
ok, here is a alpha version:

www.reflex-studio.com/clearing/video/qual28.avi 100mb

open issues:
-turret need additoinally z-offset to fit better the chassis (helper is not in ideal position in the tank model)
-no chain movement support in that model
-no correct tank chain skid marks
-no correct sounds
-no turret sound routines coded yet
-no gun movement sound routines coded yet
-gun laziness problem not solved
-viewing angle limiter missing in first person view
-gun shooiting should be possible even if gun angle limiter blocks it

there is a lot to do, if someone cares, here is the current core code.
if someone can tell me how i get the actual weapon angles from a vehicle, (from vehicle side ! i need someting like vehicle.cnt:GetWeaponAngles() , NOT in basicweapon self:GetAngles() ! )), i would be thankfull! )

first we define in vehicle properties some things:
wrote ...
set objects in proberties for object like this:

Properties = {
------operation clearing------------
Clearing = {
object_ModelTankTurret = "",
bHaveMountedCannon=1,
},
Weapon ={
wpnLimitDown = 20,
wpnLimitUp = -90,
wpnLimitLeftRight = 0,
nWpnStyle = 1, --1 = MG, 2= canon 3= mixed
nAmmoRocket = 20,
nAmmoMG = 500,
},



now we add some complete functions in to the vehicle:

wrote ...
function ClearingUniversalVehicle:UpdateTankTurret()


--local campos = System:GetViewCameraPos(); --work but only pos, no angles
--local camang = System:GetViewCameraAngles(); --dont work
--local camang = System:GetViewCameraAng(); --dont work
--local camang = _localplayer.cnt:GetFirstPersonWeaponAngles();--dont work
--local camang = _localplayer:GetDirectionVector(0); --useless

local camang = self:GetAngles(); --not the needed angles but i use this table as failsave values if no driver is in
if self.driverT and self.driverT.entity then

if self.driverT.entity == _localplayer then
camang = new(_localplayer:GetAngles());
if camang.z >= 180 and not _localplayer.cnt.first_person then
camang.z = camang.z - 360;
end
--Hud:ShowPos(camang,1) --pvcf --_localplayer -- (only devkid)
else -- support for AI tank turret rotation
camang = new(self.driverT.entity:GetAngles());
camang.z = camang.z - 360;
end

end

if not self.turret then
self.turret = Server:SpawnEntity("RigidBody");
self.turret:SetName("turret_"..self:GetName());
if not self.turret.Properties.Clearing then self.turret.Properties.Clearing ={}; end -- (only devkid)
self.turret.Properties.Clearing.bAutoHidebyFarDistance = 0; -- (only devkid)
self.turret.Properties.objModel = self.Properties.Clearing.object_ModelTankTurret;
self.turret.Properties.bResting = 1;
self.turret.Properties.bRigidBodyActive = 0;
self.turret:OnReset();
--Hud:AddMessage("turret created for "..self:GetName());
else
pos = new(self:GetHelperPos("gun"));
self.turret:SetPos(pos);
local ang = new(self:GetAngles());
local zrotationoffset = 0;
if self.driverT and self.driverT.entity then
zrotationoffset = 180;
end
ang.z = camang.z+zrotationoffset;
self.turret:SetAngles(ang);
--Hud:ShowPos(pos,1) --pvcf --_localplayer -- (only devkid)
--Hud:AddMessage("turret found and set pos for "..self:GetName());
self.turret:EnablePhysics(0);
if not self.turret.Properties.Physics then -- (only devkid)
self.turret.Properties.Physics = {};
end
self.turret.Properties.Physics.bPhysicalized = 0; --need for entity distance unhider and for load save proof (only devkid)
end

end



we call this routine in update server in vehiclecommon like this:

function VC:UpdateServer(dt)

if self.Properties.Clearing and self.Properties.Clearing.object_ModelTankTurret ~= "" then
self:UpdateTankTurret();
end

we also have to replace the init weapon routine in the vehicle with this:

wrote ...
function ClearingUniversalVehicle:InitWeapon()
if(not self.Ammo)then
self.Ammo = {};
end
if (self.Properties.Clearing.bHaveMountedCannon==1) then
self.cnt:SetWeaponLimits(self.Properties.Weapon.wpnLimitUp,self.Properties.Weapon.wpnLimitDown,self.Properties.Weapon.wpnLimitLeftRight,self.Properties.Weapon.wpnLimitLeftRight);
self.driverShooting = 1; --pvcfmod
if self.Properties.Weapon.nWpnStyle == 1 then
self.cnt:SetWeaponName("VehicleMountedAutoMG", ""); --pvcfmod
elseif self.Properties.Weapon.nWpnStyle == 2 then
self.cnt:SetWeaponName("VehicleMountedRocket", "");
elseif self.Properties.Weapon.nWpnStyle == 3 then
self.cnt:SetWeaponName("VehicleMountedRocketMG", "VehicleMountedRocket");
else
Hud:AddMessage("wrong weaponstyle, choose 1 for MG, 2 for Cannon, 3 for Mixed")
end
VC.InitAutoWeapon( self ); --pvcfmod --creates physical jeep canon
self.Ammo["VehicleMG"] = self.Properties.Weapon.nAmmoMG;
self.Ammo["VehicleRocket"] = self.Properties.Weapon.nAmmoRocket;
self.cnt:SetWeaponLimits(self.Properties.Weapon.wpnLimitUp,self.Properties.Weapon.wpnLimitDown,self.Properties.Weapon.wpnLimitLeftRight,self.Properties.Weapon.wpnLimitLeftRight);

else
--self.cnt:SetWeaponLimits(0,0,0,0); --pvcfmod
self.cnt:SetWeaponLimits(self.Properties.Weapon.wpnLimitUp,self.Properties.Weapon.wpnLimitDown,self.Properties.Weapon.wpnLimitLeftRight,self.Properties.Weapon.wpnLimitLeftRight);
--self.cnt:SetWeaponLimits(-90,90,-10,10); --pvcfmod
self.Ammo["VehicleMG"] = 0;
self.Ammo["VehicleRocket"] = 0;
self.driverShooting = 0; --pvcfmod
self.cnt:SetWeaponName("", ""); --pvcfmod
--Hud:AddMessage("no weapon",4);
end

-- //m_MinVAngle, m_MaxVAngle, m_MinHAngle, m_MaxHAngle

end



for reset event you need also this:

function ClearingUniversalVehicle:OnReset()

self:OnRemoveTurret();


aaaaaaand the last needed function in vehicle:

wrote ...
function ClearingUniversalVehicle:OnRemoveTurret()

----------------get rid of previous spawned turret --------------------------
if self.turret then --should happen only in editor, never in game !
self.turret:SetPos({x=1,y=2,z=3});
if not self.turret.Properties.Clearing then self.turret.Properties.Clearing ={}; end
self.turret.Properties.Clearing.bAutoHidebyFarDistance = 1;
--self.turret = nil;
else
self.turret = System:GetEntityByName("turret_"..self:GetName());
if self.turret then --should happen only in editor, never in game !
self.turret:SetPos({x=1,y=2,z=3});
if not self.turret.Properties.Clearing then self.turret.Properties.Clearing ={}; end
self.turret.Properties.Clearing.bAutoHidebyFarDistance = 1;
--self.turret = nil;
end
end
--self.turret = nil;

end


instead of clearinguniversalvehicle you have to use the vehicle which you like to equip with a turret.
sorry for that mass of code, but this is the minimum basic code for a turret ;(
Back to top
pvcf
Wed Sep 17 2014, 11:19PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
i forgot: the gun needs two helper if you need mg AND rocket:
spitfire and spitfire_RL
if your gun have only spitfire helper, add this code in BaseProjectile.lua:

search for

if (self.LaunchHelper and not shooter.ai) then

and add below this lines:

wrote ...
-----pvcf----------
-- maybe the vehicle canon have no spitfie_RL helper, but a usual spitfire helper, we use just the spitfire for
--first aid to avoid script crasches here
local pos = self:GetHelperPos(self.LaunchHelper);
if not pos or pos.x == 0 then self.LaunchHelper = "spitfire"; end
----pvcf----------------



I'm now again out of time for a while, so it may take weeks or months until i can finish it byself, so, if someone have the time and knowledge it would be nice to finish the needed routines (moslty sound events and vehicle canon angles instead player viewing angles)

[ Edited Thu Sep 18 2014, 12:03AM ]
Back to top
flybitten
Thu Sep 18 2014, 10:30AM
flybitten

Registered Member #82
Joined: Fri Aug 21 2009, 02:43PM
Posts: 261
https://www.youtube.com/watch?v=6E5_As3sz5o&list=UU_4mSB6nPvVw80J6uo1dC8g I did this using the MOD Crazycry and the level the Fetz . Rubbish video but you can fly the plane and helicopter
Back to top
pvcf
Thu Sep 18 2014, 01:27PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
mixer released also a script called "jetvehicle" which allows to fly in mp, my planes and helicopters base on that script.
Back to top
El
Thu Sep 18 2014, 05:36PM

Registered Member #265
Joined: Thu Feb 18 2010, 06:17AM
Posts: 542

Nice single seater pvcf.  I remember a screen of yours showing a small plane from 3rd person view, be nice if that is flyable too. (Cessna?).

flybitten nice flying the plane and helicopter in your Fetz-CrazyCry video.  Causes genuine motion sickness as well. such immersion.  Well maybe it was only your video's frame rate. wink.png
Back to top
pvcf
Thu Sep 18 2014, 06:05PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
@El

watch the second video link i have posted, there you see player flying that cessna

Back to top
pvcf
Thu Sep 18 2014, 06:09PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494

i created a tank minimod, base on a nice mp map, nrw_winter_1944. so i used once the FWDvehicle and second the buggy as tankvehicle and as tank (first one with t72, second with bmp). so, take that as modding base for your own tank scripts and games. -player can use 2 different tanks -AI drive one tank have fun! www.reflex-studio.com/clearing/mod/pvcf_tankmod.7z (ps.: its designed as SP but it also COULD work as MP, you probably have to remove the placed AI's. this mod was done in about 90 minutes, so please dont expect any missions ! it was only to have "something" around the tanks )

in weapon weaponstyle in properties choose 1-3 ( MG, RL, MG+RL)


[ Edited Thu Sep 18 2014, 07:50PM ]
Back to top
VET
Fri Sep 19 2014, 12:59AM
Vals_Evil_Twin


Registered Member #6
Joined: Mon May 25 2009, 08:36PM
Posts: 2508


                                   Cryengine1 TANK

Huge achievement by pcvf.  Operation Clearing has the Cessna, the motocross bike, the gyro-copter, and now ...  the tank!  amazed.png
We have waited a long time to see the tank working in cryengine1.  Drive wheels turn, tracks move, driveable in both first and person view, and weapons selectable (in editor mode as yet) MG, RL, MG+RL.
This small mod to showcase the tanks (x2) is based on the mp map nrw_winter_1944. 
ie There are AI, but no mission etc.
Tanks from crymods.news members, pvcf! cheesey.png





Back to top
pvcf
Fri Sep 19 2014, 07:14AM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
thank you VET but the driving chains are not part of this kit, even if the BMP driving model have driving chains, there is no switch between driving and non driving, such things are part of devkid.
BUT i won't have Tanks in OPCL, its not planned, but i have a question regarding the video you made: there is a enemy tank standing in front of you, this tank should be equiped with AI and shoot to you, (was working here), so, did you gently killed the driver and gunner before you captured it or does it simply not work for you ?

btw, t72 have two weaponmodes, MG and Canon !

[ Edited Fri Sep 19 2014, 07:18AM ]
Back to top
eviltimes
Fri Sep 19 2014, 09:13AM
eviltimes

Registered Member #7
Joined: Wed May 27 2009, 09:29AM
Posts: 1226
Just freakin awesome!
Back to top
Janzu
Fri Sep 19 2014, 11:14AM
Janzu

Registered Member #132
Joined: Thu Dec 03 2009, 05:46PM
Posts: 426
ive been gone for few days and when i come back i see this...
I like it! ;D
Back to top
pvcf
Fri Sep 19 2014, 12:03PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
thank you Janzu and Eviltimes
hmmm, thinking twice: i have forgotten to remove the turret after tank is destroyed.
could someone look what happens if the tank is blown away?
if the turret is still there, there is already a function in which just need a call in blow-up event. its
self:OnRemoveTurret()


[ Edited Fri Sep 19 2014, 12:10PM ]
Back to top
pvcf
Fri Sep 19 2014, 03:49PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
@VET
i have started the minimod and compared my FPS to yours, so, could you show me a screenshot from your farcry grafic advanced settings (also the AF in options /grafic) ?

it seems i have @ veryhigh settings with 8:AF constant 100FPS less than you so your machine seems about 40% better than mine
(ok, my gear is 5 year old and was released 6 years ago).

[ Edited Fri Sep 19 2014, 03:54PM ]
Back to top
VET
Fri Sep 19 2014, 07:51PM
Vals_Evil_Twin


Registered Member #6
Joined: Mon May 25 2009, 08:36PM
Posts: 2508

pvcf wrote ...
"Thank you VET but the driving chains are not part of this kit, even if the BMP driving model have driving chains, there is no switch between driving and non driving, such things are part of devkid. BUT i won't have Tanks in OPCL, its not planned, but i have a question regarding the video you made: there is a enemy tank standing in front of you, this tank should be equiped with AI and shoot to you, (was working here), so, did you gently killed the driver and gunner before you captured it or does it simply not work for you ? btw, t72 have two weaponmodes, MG and Canon !"

Yes. The tracks were working when it was stationary on the BMP, so no switch for "neutral" gear.
I only had the MG weapon mode, I'll try again to switch it to canon.
The enemy tank+AI did not shoot at me. After I poured some lead into the tank, the AI jumped out.  I ran out of ammo before I could see if the tank blew up.

pvcf wrote ...
"@VET i have started the minimod and compared my FPS to yours, so, could you show me a screenshot from your farcry grafic advanced settings (also the AF in options /grafic) ? it seems i have @ veryhigh settings with 8:AF constant 100FPS less than you so your machine seems about 40% better than mine (ok, my gear is 5 year old and was released 6 years ago)."


My computer is older than your computer LOL, April 2008.
Following advice in the FarCry Tweakguide, I have no 'Very High' settings at all, as there is a big FPS hit for very little benefit.  I have AA and AF 'Low' or 'Off".  Shadows, Lighting, Water Quality all 'Low'.  So that is why I have high FPS.
When I turn the settings up, I lose textures.  eg the perforated steel decking in Campaign: Carrier goes invisible.

I will try your Tank Mod on my "new" computer, which is itself 3 y.o.now, and see what happens.  I don't usually use it for FarCry, it is Win7 64bit and I don't like the hassle.  Great for modern games though.



Back to top
pvcf
Fri Sep 19 2014, 08:02PM
gone

Registered Member #549
Joined: Fri Oct 01 2010, 05:56PM
Posts: 1494
only the T72 have two weapons, BMP have only MG.
the enemy Tank is shooting with canon like hell to me, my tank blows up after second hit from them, needs about ~3-4 seconds.

editor won't run in 64bit environment, but the mod should, if you have the msvcr71.dll msvcp71.pdb and msvcp71.dll copied to your windows system folder, have had also trouble to got my mod running on W7 and W8.1 , both 64 bit, but there are many hints and tips in the internet which provide the correct dll's and tell where this have to copied in.
Back to top
VET
Fri Sep 19 2014, 09:39PM
Vals_Evil_Twin


Registered Member #6
Joined: Mon May 25 2009, 08:36PM
Posts: 2508

OK That was a pain in the ass: got FarCry working Win764bit, set all farCry Adv.Video Options to flat-out, and these are the frame rates I got.
Canon and machine gun both working on the T72.  The enemy tank fired back at me.  About five canon shots and it blew up.
Extremely cool, pvcf.  Reminded me strongly of Medal of Honour tank battles.  Half of the town in MOH was made up of destructible buildings too.






[/html]
Back to top
Go to page       >>   

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System
 
 
 
Render time: 1.4124 sec, 1.2659 of that for queries. Memory Usage: 1,591kB