OpenSpades And TOpenSpadongs SMG reload&shoot animations

OpenSpades is an open source alternative client for AoS Classic and beyond! Runs on Windows, Mac, and Linux. Created by yvt.
Compatible with AoS Classic.
2 posts Page 1 of 1 First unread post
Chameleon
Modder
Modder
Posts: 601
Joined: Thu Nov 22, 2012 6:41 pm


It happens when u Blue_Pistol and press r
lol
Spoiler:
Chameleon found out this one weird trick of dumping whole magazine under 1 second...
Image
Instructions first. Download & unzip Thompson.zip in Resources folder (Game reads from normal folders too etc. .../Resources/Scripts/Weapons/SMG/View.as). Now mod is halfway ready - you need to update the View.as file I mentioned before.
TOpenSpadongs.15 View.as:
Spoiler:
Code: Select all
/*
 Copyright (c) 2013 yvt
 
 This file is part of OpenSpades.
 
 OpenSpades is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 OpenSpades is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with OpenSpades.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 namespace spades {
	class ViewSMGSkin: 
	IToolSkin, IViewToolSkin, IWeaponSkin,
	BasicViewWeapon {
		
		private AudioDevice@ audioDevice;
		private Model@ gunModel;
		private Model@ magazineModel;
		private Model@ sightModel1;
		private Model@ sightModel2;
		private Model@ sightModel3;
		private Model@ movemodel;
		
		private AudioChunk@ fireSound;
		private AudioChunk@ reloadSound;
		
		float ReadyState;
		
		ViewSMGSkin(Renderer@ r, AudioDevice@ dev){
			super(r);
			@audioDevice = dev;
			@gunModel = renderer.RegisterModel
				("Models/Weapons/SMG/WeaponNoMagazine.kv6");
			@magazineModel = renderer.RegisterModel
				("Models/Weapons/SMG/Magazine.kv6");
			@sightModel1 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight1.kv6");
			@sightModel2 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight2.kv6");
			@sightModel3 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight3.kv6");
			@movemodel = renderer.RegisterModel
				("Models/Weapons/SMG/WeaponMove.kv6");
				
			@fireSound = dev.RegisterSound
				("Sounds/Weapons/SMG/Fire.wav");
			@reloadSound = dev.RegisterSound
				("Sounds/Weapons/SMG/Reload.wav");
				
		}
		
		void Update(float dt) {
			BasicViewWeapon::Update(dt);
		}
		
		void WeaponFired(){
			BasicViewWeapon::WeaponFired();	//NOTE i might be able to do firing animation by linking a function here
			
			if(!IsMuted){
				Vector3 origin = Vector3(0.f, -0.3f, 0.5f);
				AudioParam param;
				param.volume = 0.3f;
				audioDevice.PlayLocal(fireSound, origin, param);
			}
		}
		
		void ReloadingWeapon() {
			if(!IsMuted){
				Vector3 origin = Vector3(0.f, -0.3f, 0.5f);
				AudioParam param;
				param.volume = 0.2f;
				audioDevice.PlayLocal(reloadSound, origin, param);
			}
		}
		
		float GetZPos() {
			return 0.2f - AimDownSightStateSmooth * 0.038f;
		}
		
		// rotates gun matrix to ensure the sight is in
		// the center of screen (0, ?, 0).
		Matrix4 AdjustToAlignSight(Matrix4 mat, Vector3 sightPos, float fade) {
			Vector3 p = mat * sightPos;
			mat = CreateRotateMatrix(Vector3(0.f, 0.f, 1.f), atan(p.x / p.y) * fade) * mat;
			mat = CreateRotateMatrix(Vector3(-1.f, 0.f, 0.f), atan(p.z / p.y) * fade) * mat;
			return mat;
		}
		
		void Draw2D() {
			BasicViewWeapon::Draw2D();
		}
		
		void AddToScene() {
			Matrix4 mat = CreateScaleMatrix(0.033f); //DEFAULT 0.033
			mat = GetViewWeaponMatrix() * mat;
			
			bool reloading = IsReloading;
			float reload = ReloadProgress;
			Vector3 leftHand, rightHand;
			
			leftHand = mat * Vector3(1.f, 8.f, -0.85f);			//(x,y,z) (x+left/-right, y+further/-closer, z+down/-up)
			rightHand = mat * Vector3(0.75f, 2.25f, -1.f);			//(x,y,z) (x+left/-right, y+further/-closer, z+down/-up)
			
			Vector3 leftHand2 = mat * Vector3(5.f, -10.f, 4.f); //release magazine
			Vector3 leftHand3 = mat * Vector3(1.5f, 4.f, -5.f);	//move hand from player, center of screen
			Vector3 leftHand4 = mat * Vector3(4.0f, -5.f, -3.f); //move hand to player, to left-down corner
						
			if(AimDownSightStateSmooth > 0.8f){
				mat = AdjustToAlignSight(mat, Vector3(0.f, 5.f, -4.9f), (AimDownSightStateSmooth - 0.8f) / 0.2f);
			}
			
			ModelRenderParam param;
			Matrix4 weapMatrix = eyeMatrix * mat;
			param.matrix = weapMatrix * CreateScaleMatrix(0.5f) *
			CreateTranslateMatrix(-0.5f, 0.f, 0.f);
			param.depthHack = true;
			renderer.AddModel(gunModel, param);
			
			// draw sights
			Matrix4 sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.05f, 5.f, -4.85f);
			sightMat *= CreateScaleMatrix(0.0f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel1, param); // front-NOT.USED
			
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.025f, 11.f, -4.85f);
			sightMat *= CreateScaleMatrix(0.05f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel3, param); // front pin
			
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.025f, -5.f, -4.9f);
			sightMat *= CreateScaleMatrix(0.1f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel2, param); // rear
			
			// magazine/reload action
			mat *= CreateTranslateMatrix(0.f, 3.f, 1.f);
			reload *= 2.5f;
			if(reloading) 
			{
				if(reload < 0.7f)
				{
					// magazine release
					float per = reload / 0.7f;
					mat *= CreateTranslateMatrix(0.f, 0.f, per*per*50.f);
					leftHand = Mix(leftHand, leftHand2, SmoothStep(per));
				}
				else if(reload < 1.5f) 												//1.4
				{
					// insert magazine
					float per = (1.5f - reload) / 0.5f;								//1.4; 0.7
					if(per < 0.3f) 
					{
						// non-smooth insertion
						per *= 4.f; per -= 0.4f;
						per = Clamp(per, 0.0f, 0.3f);
					}
					
					mat *= CreateTranslateMatrix(0.f, 0.f, per*per*10.f);
					leftHand = mat * Vector3(0.f, 0.f, 4.f);
				}
				else if(reload < 2.f)
				{
					// move the left hand to the original position
					// and start doing something with the "right" hand-INCORRECT
					float per = (reload - 1.5f) / 0.5f;								//1.4
					leftHand = mat * Vector3(0.f, 0.f, 4.f);
					leftHand = Mix(leftHand, leftHand3, SmoothStep(per));
				}
				else if(reload < 2.2f)
				{
					float per = (reload - 2.f) / 0.3f;
					leftHand = Mix(leftHand3, leftHand4, SmoothStep(per));
				}
				else
				{
					float per = (reload - 2.2f) / 0.3f;
					leftHand = Mix(leftHand4, leftHand, SmoothStep(per)); //bring back to original position
				}
			}
			
			param.matrix = eyeMatrix * mat; //* CreateScaleMatrix(0.5f);
			renderer.AddModel(magazineModel, param);
			
			LeftHandPosition = leftHand;
			RightHandPosition = rightHand;
			
			//NEW ANIMATION--------------------------------------------------------#-#-#-#-#
			//IGNORE LINES LIKE THIS - they are just comments
			//sightMat = weapMatrix;
			//sightMat *= CreateTranslateMatrix(1.f, 1.f, 1.f) * CreateScaleMatrix(0.5f);
			param.matrix = weapMatrix * CreateTranslateMatrix(-0.25f, 0.f, 0.f) * CreateScaleMatrix(0.5f);
			param.depthHack = true;
			if(reloading) 
			{
				if(reload < 0.7f)
				{
					//magazine release - this actually does nothing,
					//but i'm afraid that removing this might break something :D
					float per = reload / 0.7f;
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 1.4f) 												//1.4
				{
					// insert magazine - does nothing
					float per = (1.4f - reload) / 0.7f;								//1.4; 0.7
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 1.9f)
				{
					// does nothing
					float per = (reload - 1.4f) / 0.5f;								//1.4
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 2.2f)
				{
					float per = (reload - 2.f) / 0.3f;
					param.matrix *= CreateTranslateMatrix(0.f, per*-8.f, 0.f);
					//finally starts moving my WeaponMove.kv6 model
					//moves it closer to eye.
				}
				else
				{
					param.matrix *= CreateTranslateMatrix(0.f, -8.f, 0.f);		
					//somehow the model resets while executing every else { },
					//so i make the game return the model to needed place
					//(with first line)
					//and THEN tell game to return it slowly to the default place 
					//(with the last line).
					float per = (reload - 2.2f) / 0.3f;
					param.matrix *= CreateTranslateMatrix(0.f, per*8.f, 0.f);
				}
			}
			
			if (ReadyState < 1.f)
			{
				if (ReadyState < 0.5f)
				{
					float per = (0.5f - ReadyState) / 0.5f;
					param.matrix *= CreateTranslateMatrix(0.f, per*-8.f, 0.f);
				}
				if (ReadyState < 1.0f)
				{
					param.matrix *= CreateTranslateMatrix(0.f, -8.f, 0.f);
					float per = (1.0f - ReadyState) / 0.5f;
					param.matrix *= CreateTranslateMatrix(0.f, per*8.f, 0.f);
				}
			}
			
			//param.matrix = eyeMatrix * sightMat;
			renderer.AddModel(movemodel, param);
		}
		
	}
	
	IWeaponSkin@ CreateViewSMGSkin(Renderer@ r, AudioDevice@ dev) {
		return ViewSMGSkin(r, dev);
	}
}
OpenSpades.12b View.as:
Spoiler:
Code: Select all
/*
 Copyright (c) 2013 yvt
 
 This file is part of OpenSpades.
 
 OpenSpades is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 OpenSpades is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with OpenSpades.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
 namespace spades {
	class ViewSMGSkin: 
	IToolSkin, IViewToolSkin, IWeaponSkin,
	BasicViewWeapon {
		
		private AudioDevice@ audioDevice;
		private Model@ gunModel;
		private Model@ magazineModel;
		private Model@ sightModel1;
		private Model@ sightModel2;
		private Model@ sightModel3;
		private Model@ movemodel;
		
		private AudioChunk@[] fireSounds(4);
		private AudioChunk@ fireFarSound;
		private AudioChunk@ fireStereoSound;
		private AudioChunk@ reloadSound;
		
		ViewSMGSkin(Renderer@ r, AudioDevice@ dev){
			super(r);
			@audioDevice = dev;
			@gunModel = renderer.RegisterModel
				("Models/Weapons/SMG/WeaponNoMagazine.kv6");
			@magazineModel = renderer.RegisterModel
				("Models/Weapons/SMG/Magazine.kv6");
			@sightModel1 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight1.kv6");
			@sightModel2 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight2.kv6");
			@sightModel3 = renderer.RegisterModel
				("Models/Weapons/SMG/Sight3.kv6");
			@movemodel = renderer.RegisterModel
				("Models/Weapons/SMG/WeaponMove.kv6");
				
			@fireSounds[0] = dev.RegisterSound
				("Sounds/Weapons/SMG/FireLocal1.wav");
			@fireSounds[1] = dev.RegisterSound
				("Sounds/Weapons/SMG/FireLocal2.wav");
			@fireSounds[2] = dev.RegisterSound
				("Sounds/Weapons/SMG/FireLocal3.wav");
			@fireSounds[3] = dev.RegisterSound
				("Sounds/Weapons/SMG/FireLocal4.wav");
			@fireFarSound = dev.RegisterSound
				("Sounds/Weapons/SMG/FireFar.wav");
			@fireStereoSound = dev.RegisterSound
				("Sounds/Weapons/SMG/FireStereo.wav");
			@reloadSound = dev.RegisterSound
				("Sounds/Weapons/SMG/ReloadLocal.wav");
				
		}
		
		void Update(float dt) {
			BasicViewWeapon::Update(dt);
		}
		
		void WeaponFired(){
			BasicViewWeapon::WeaponFired();
			
			if(!IsMuted){
				Vector3 origin = Vector3(0.4f, -0.3f, 0.5f);
				AudioParam param;
				param.volume = 8.f;
				audioDevice.PlayLocal(fireSounds[GetRandom(fireSounds.length)], origin, param);
				
				param.volume = 4.f;
				audioDevice.PlayLocal(fireFarSound, origin, param);
				param.volume = 1.f;
				audioDevice.PlayLocal(fireStereoSound, origin, param);
				
			}
		}
		
		void ReloadingWeapon() {
			if(!IsMuted){
				Vector3 origin = Vector3(0.4f, -0.3f, 0.5f);
				AudioParam param;
				param.volume = 0.2f;
				audioDevice.PlayLocal(reloadSound, origin, param);
			}
		}
		
		float GetZPos() {
			return 0.2f - AimDownSightStateSmooth * 0.038f;
		}
		
		// rotates gun matrix to ensure the sight is in
		// the center of screen (0, ?, 0).
		Matrix4 AdjustToAlignSight(Matrix4 mat, Vector3 sightPos, float fade) {
			Vector3 p = mat * sightPos;
			mat = CreateRotateMatrix(Vector3(0.f, 0.f, 1.f), atan(p.x / p.y) * fade) * mat;
			mat = CreateRotateMatrix(Vector3(-1.f, 0.f, 0.f), atan(p.z / p.y) * fade) * mat;
			return mat;
		}
		
		void Draw2D() {
			if(AimDownSightState > 0.8)
				return;
			BasicViewWeapon::Draw2D();
		}
		
		void AddToScene() {
			Matrix4 mat = CreateScaleMatrix(0.033f);
			mat = GetViewWeaponMatrix() * mat;
			
			bool reloading = IsReloading;
			float reload = ReloadProgress;
			Vector3 leftHand, rightHand;
			
			leftHand = mat * Vector3(1.f, 8.f, -0.85f);
			rightHand = mat * Vector3(0.75f, 2.25f, -1.f);
			//leftHand = mat * Vector3(1.f, 6.f, 1.f);
			//rightHand = mat * Vector3(0.f, -8.f, 2.f);
			
			Vector3 leftHand2 = mat * Vector3(5.f, -10.f, 4.f);
			Vector3 leftHand3 = mat * Vector3(1.5f, 4.f, -5.f);
			Vector3 leftHand4 = mat * Vector3(4.0f, -5.f, -3.f);
			//Vector3 leftHand2 = mat * Vector3(5.f, -10.f, 4.f);
			//Vector3 leftHand3 = mat * Vector3(1.f, 6.f, -4.f);
			//Vector3 leftHand4 = mat * Vector3(1.f, 9.f, -6.f);
			
			if(AimDownSightStateSmooth > 0.8f){
				mat = AdjustToAlignSight(mat, Vector3(0.f, 5.f, -4.9f), (AimDownSightStateSmooth - 0.8f) / 0.2f);
			}
			
			ModelRenderParam param;
			Matrix4 weapMatrix = eyeMatrix * mat;
			param.matrix = weapMatrix * CreateScaleMatrix(0.5f) *
			CreateTranslateMatrix(-0.5f, 0.f, 0.f);
			param.depthHack = true;
			renderer.AddModel(gunModel, param);
			
			/*Comment begin
			ModelRenderParam param;
			Matrix4 weapMatrix = eyeMatrix * mat;
			param.matrix = weapMatrix;
			param.depthHack = true;
			renderer.AddModel(gunModel, param);
			Comment end*/
			
			// draw sights
			Matrix4 sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.05f, 5.f, -4.85f);
			sightMat *= CreateScaleMatrix(0.0f);
			//sightMat *= CreateScaleMatrix(0.1f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel1, param); // front
			
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.025f, 11.f, -4.85f);
			sightMat *= CreateScaleMatrix(0.05f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel3, param); // front pin
			
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.025f, -5.f, -4.9f);
			sightMat *= CreateScaleMatrix(0.1f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel2, param); // rear
			
			/*Comment begin
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.025f, 5.f, -4.85f);
			sightMat *= CreateScaleMatrix(0.05f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel3, param); // front pin
			
			sightMat = weapMatrix;
			sightMat *= CreateTranslateMatrix(0.04f, -9.f, -4.9f);
			sightMat *= CreateScaleMatrix(0.08f);
			param.matrix = sightMat;
			renderer.AddModel(sightModel2, param); // rear
			Comment end*/
			
			// magazine/reload action
			mat *= CreateTranslateMatrix(0.f, 3.f, 1.f);
			reload *= 2.5f;
			if(reloading)
			{
				if(reload < 0.7f)
				{
					// magazine release
					float per = reload / 0.7f;
					mat *= CreateTranslateMatrix(0.f, 0.f, per*per*50.f);
					leftHand = Mix(leftHand, leftHand2, SmoothStep(per));
				}
				else if(reload < 1.5f) 
				{
					// insert magazine
					float per = (1.5f - reload) / 0.5f;
					if(per < 0.3f) 
					{
						// non-smooth insertion
						per *= 4.f; per -= 0.4f;
						per = Clamp(per, 0.0f, 0.3f);
					}
					
					mat *= CreateTranslateMatrix(0.f, 0.f, per*per*10.f);
					leftHand = mat * Vector3(0.f, 0.f, 4.f);
				}
				else if(reload < 2.f)
				{
					// move the left hand to the original position
					// and start doing something with the right hand
					float per = (reload - 1.5f) / 0.5f;
					leftHand = mat * Vector3(0.f, 0.f, 4.f);
					leftHand = Mix(leftHand, leftHand3, SmoothStep(per));
				}
				else if(reload < 2.2f)
				{
					float per = (reload - 2.0f) / 0.3f;
					leftHand = Mix(leftHand3, leftHand4, SmoothStep(per));
				}
				else
				{
					float per = (reload - 2.2f) / 0.3f;
					leftHand = Mix(leftHand4, leftHand, SmoothStep(per));
				}
			}
			
			param.matrix = eyeMatrix * mat;
			renderer.AddModel(magazineModel, param);
			
			LeftHandPosition = leftHand;
			RightHandPosition = rightHand;
			
			//NEW ANIMATION--------------------------------------------------------#-#-#-#-#
			//IGNORE LINES LIKE THIS - they are just comments
			//sightMat = weapMatrix;
			//sightMat *= CreateTranslateMatrix(1.f, 1.f, 1.f) * CreateScaleMatrix(0.5f);
			//RELOAD ANIMATION--------------------------------------------------------#-#-#-#-#
			param.matrix = weapMatrix * CreateTranslateMatrix(-0.25f, 0.f, 0.f) * CreateScaleMatrix(0.5f);
			param.depthHack = true;
			if(reloading) 
			{
				if(reload < 0.7f)
				{
					//magazine release - this actually does nothing,
					//but i'm afraid that removing this might break something :D
					float per = reload / 0.7f;
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 1.4f) 												//1.4
				{
					// insert magazine - does nothing
					float per = (1.4f - reload) / 0.7f;								//1.4; 0.7
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 1.9f)
				{
					// does nothing
					float per = (reload - 1.4f) / 0.5f;								//1.4
					//sightMat *= CreateTranslateMatrix(0.f, 0.f, 0.f);
				}
				else if(reload < 2.2f)
				{
					float per = (reload - 2.f) / 0.3f;
					param.matrix *= CreateTranslateMatrix(0.f, per*-8.f, 0.f);
					//finally starts moving my WeaponMove.kv6 model
					//moves it closer to eye.
				}
				else
				{
					param.matrix *= CreateTranslateMatrix(0.f, -8.f, 0.f);		
					//somehow the model resets while executing every else { },
					//so i make the game return the model to needed place
					//(with first line)
					//and THEN tell game to return it slowly to the default place 
					//(with the last line).
					float per = (reload - 2.2f) / 0.3f;
					param.matrix *= CreateTranslateMatrix(0.f, per*8.f, 0.f);
				}
			}
			//SHOOT ANIMATION--------------------------------------------------------#-#-#-#-#
			if (ReadyState < 1.f)
			{
				if (ReadyState < 0.5f)
				{
					float per = (0.5f - ReadyState) / 0.5f;
					param.matrix *= CreateTranslateMatrix(0.f, per*-8.f, 0.f);
				}
				if (ReadyState < 1.0f)
				{
					param.matrix *= CreateTranslateMatrix(0.f, -8.f, 0.f);
					float per = (1.0f - ReadyState) / 0.5f;
					param.matrix *= CreateTranslateMatrix(0.f, per*8.f, 0.f);
				}
			}
			
			//param.matrix = eyeMatrix * sightMat;
			renderer.AddModel(movemodel, param);
		}
		
	}
	
	IWeaponSkin@ CreateViewSMGSkin(Renderer@ r, AudioDevice@ dev) 
	{
		return ViewSMGSkin(r, dev);
	}
}
You need to replace the current code in view.as file because I've added shooting animation.

https://www.dropbox.com/s/79z2druqjly85ut/Thomspon.zip
https://www.mediafire.com/?8pc7opetfx8767p
Last edited by Chameleon on Sat Jul 05, 2014 6:51 pm, edited 5 times in total.
Chameleon
Modder
Modder
Posts: 601
Joined: Thu Nov 22, 2012 6:41 pm


http://buildandshoot.com/viewtopic.php?f=57&t=11460
http://buildandshoot.com/viewtopic.php?f=12&t=10790
Some howto:
Spoiler:
You might have noticed that my WeaponNoMagazine has twice the detail - that has been done by adding "CreateScaleMatrix(0.5f)" and doubling the size of model in Slab6. Then I cloned WeaponNoMagazine.kv6, added moving parts and erased the rest of weapon, saved as WeaponMove.kv6. Then I added these lines under "ViewSMGSkin(...){addhere}" in View.as
"@movemodel = renderer.RegisterModel
("Models/Weapons/SMG/WeaponMove.kv6");"
Game will find another model called WeaponMove.kv6, located in /Models/Weapons/SMG/ directory. Simple.
Skip to "void AddToScene() {". Here you can see I modified positions and scale of arms, weapon and sight models. Eliminated the drawing of front ring sight.
Skip to "//NEW ANIMATION"
RELOAD
I changed the left hand coordinates so the hand "moves" my WeaponMove.kv6 model - so it doesn't move by itself.
Then I started off by declaring my model's coordinates, scale & other parameters (see below).
After that, I checked if reloading has started. If true, it waits until reload progress is = 1.9 and starts moving my weapmove model backwards. When reload progress reaches 2.2, weapmove model starts moving back to original position, 2.5 being the end of reload progress.
SHOOTING
I checked if user has fired a bullet by checking if he is NOT ready to fire one YET. i know its stupid, but hey, its working ("float ReadyState", see below). weapmove model moves backwards until half of next bullet is loaded. then from half to finish weapmove model moves forwards. by automatic fire you wil ensure that weapmove model is never idle, working 30 rounds per magazine.

Now lets get into what variable does what and what values of that variable will do what.
"param" or "param.matrix" stores data about current weapon model. etc. Scale, XYZ coordinates and some idk stuff (below).
"weapMatrix" tells that that model should behave like a weapon part (for sprinting animations).
"bool reloading" false=not reloading, true=reloading.
"float reload" tells the progress of current reload. when you press R, you start with 0.f. Search for "reload *= 2.5f;".
"float per" tells the progress of current stage of reload. used to smoothen out the action for animation.
"CreateTranslateMatrix(1.f, -0.1f, 2*0.0f);" tells the coordinates of model. let me get more in-depth.
CreateTranslateMatrix(x.f, y.f, z.f) - (x,y,z) (x+left/-right, y+further/-closer, z+down/-up). do i need to tell you what is + and -?
"CreateScaleMatrix(0.5f)" is used for scaling models up and down, up and down. current value is 2:1 scale
"float ReadyState" you have to declare it first in order to be able to use it!!! it is in grenade and block script. it is 0.f right after shooting and 1.f when you are ready to shoot/throw/build/spade next bullet/grenade/block.
"renderer.AddModel(movemodel, param);" tells renderer to finally add our moving model with "param"eters we entered.
Please give feedback, point out spelling mistakes (and give me a badge) EDIT: check that sweet badge >>>>
Last edited by Chameleon on Sat Jul 05, 2014 3:09 pm, edited 1 time in total.
2 posts Page 1 of 1 First unread post
Return to “OpenSpades Discussion”

Who is online

Users browsing this forum: No registered users and 9 guests