Jump to content

Proof that a player can fly in Skyrim well may be more like swimming


hex_ratt

Recommended Posts

I just want a cool animation damned, otherwise I would had release it long time ago, right now I think its nothing else than a scripted TCL, I dont think its worth releasing, but if the community wants it, feel free, the code is open for modifications, applying it to other mods, anything, I posted that code so we could make it better togheter, and we did, now we just need an animator to join us and make us a couple of cool animations, one for taking off and another to fly around.
Link to comment
Share on other sites

  • Replies 304
  • Created
  • Last Reply

Top Posters In This Topic

I have no idea if it is working, but their are fyling/hovering humanoids in Skyrim. Maybe you could use the lich's or nocturnal's animations for flight. I know it is a different model, but well maybe there are people out there that could port the animations since I guess the model's should use a similar skeleton as the player model.
Link to comment
Share on other sites

I have no idea if it is working, but their are fyling/hovering humanoids in Skyrim. Maybe you could use the lich's or nocturnal's animations for flight. I know it is a different model, but well maybe there are people out there that could port the animations since I guess the model's should use a similar skeleton as the player model.

That would be perfect, only I look into it, and you need to rename the damn bones in 3dsmax, plus most of those animations dont allow running, most of them dont, the only ones I found that let me run / sprint is "HorseEnter", "JumpFall" and some other, I tried also with the Whirlwind Sprint animation, that didnt work either, I just dont know what to do anymore.

Link to comment
Share on other sites

Mostly we need a wing flapping animation, which will require use of that skeleton posted up + some work editing the JumpFall animation. If someone wants to work on takeoff/landing, that's fine, but realize none of the previous flying mods had even that (nor Bethesda's work for the DICE thing). (I don't believe the Beth demo (flying vampire lord) even had wing animations, AFAIK). Edited by jimhsu
Link to comment
Share on other sites

Looking at the vampire lord clip, the wings ONLY animated on idles which was a replacer. Right now in the animation section of modding we're currently trying to find a way to add in new animations since Skyrim doesn't allow new animations, just replacers. There are however, some prototype sex mods that are currently researching ways to add in new anims. The biggest possible way is to just have a dynamically changing pathing system to point to different animations for the same animation entry. As far as taking off and landing goes, we will need NEW animations since the default ones by Bethsoft are completely scripted and hardcoded thus the reason the animations cause people to CTD whenever they try to manually trigger it.
Link to comment
Share on other sites

Yea I dont think they had flying rideable dragons either, they just show a scene where a player is riding a dragon, so far I can do that aswell, problem comes when you try to control those animations since the animations arent just plain animations, they define the movement aswell. When you do SendAnimationEvent(Dragon,"FlyStartCruise") to put an example, the dragon starts flying around in a 500 radius, and yea you are mounted, but you are far from controling it, its actually kind of fun if you think about it, you are riding your dragon which goes around killing ppl, if at least you could control it. Edited by porroone
Link to comment
Share on other sites

Ugh, enough of working over this tonight.

A lot of stuff is still commented out as I'm still testing.

 

Features:

- Control of flight speed

- Control of maximum flight duration

- "Drifting" after maximum flight duration

- Height based on Z axis (i.e. look up to go up)

- Time step control (adjust this how you see fit)

 

Overall, the flight does work, but the animations are wonky.

 

I still need a way to get PlayIdle to work in Script Dragon. Ideas?

 

/* 
       THE DRAGONBORN LEGACY Script Dragon
	Code modified by jimhsu
*/

#include "common\skyscript.h"
#include "common\obscript.h"
#include "common\types.h"
#include "common\enums.h"
#include "common\plugin.h"
#include <math.h>

#define CONFIG_FILE "FlightTest.ini"
#define SCR_NAME "FlightTest"
#define PI 3.14159265


void flySim(BYTE *FlapKey, PlayerCharacter *ref, bool bAutoFly, int *iFlapCD, float *fFlightSpeed, float *fSpeed, int *iFlightTimeMax, float fTimeStep)
{
       float fPosX = ObjectReference::GetPositionX((TESObjectREFR *)ref);
       float fPosY = ObjectReference::GetPositionY((TESObjectREFR *)ref);
       float fPosZ = ObjectReference::GetPositionZ((TESObjectREFR *)ref);
       float fAngX = ObjectReference::GetAngleX((TESObjectREFR *)ref); //East - West?
       float fAngY = ObjectReference::GetAngleY((TESObjectREFR *)ref); //North - South?
       float fAngZ = ObjectReference::GetAngleZ((TESObjectREFR *)ref); //Up - Down
       float fDragonForm = 3; //0 = regular player race, 1 = first shout level, 2 = 2nd shout word, 3 = 3rd shout word
       float fThrust = 0;
       float fPeakThrustTime;
	float fAngleFactor = 3;
	bool isFlying = false;

       if (fDragonForm > 1){
			// Roughly W = F*d
			// d = vt where t = iFlapCD and v is flight speed.
               if (GetKeyPressed(*FlapKey)){
					if (*iFlapCD < *iFlightTimeMax)
					{
						*iFlapCD += (int)(1000 * fTimeStep);
					}
					isFlying = true;
               }
               if(*iFlapCD > 0 && isFlying && *iFlapCD < *iFlightTimeMax){ //timestep
					Utility::SetINIFloat("fInAirFallingCharGravityMult:Havok",0.0);
					*fSpeed = *fFlightSpeed;
					//*fSpeed = *fFlightSpeed * ((float)(*iFlightTimeMax-*iFlapCD) / (float)*iFlightTimeMax); // for 1 second
					//fPeakThrustTime = *iFlapCD/2; //Times the amount of thrust given by the wings
					float newAngle = fAngleFactor*fAngX;
					if (fAngX > 0)
					{
						newAngle = 0;
					}
					if (fAngX < (-90/fAngleFactor))
					{
						newAngle = -90;
					}
					fPosZ += *fSpeed * (fTimeStep) * sin(-newAngle*PI/180.0);
					//fPosX += *fSpeed * (fTimeStep) * sin(fAngZ*PI/180.0);
					//fPosY += *fSpeed * (fTimeStep) * cos(fAngZ*PI/180.0);
					//PrintNote("Flap: Speed: %f; X: %f; Y: %f; Z: %f; angle: %f", *fSpeed, fPosX, fPosY, fPosZ, fAngZ);
					ObjectReference::SetMotionType((TESObjectREFR *)ref, 0, false);
					ObjectReference::TranslateTo((TESObjectREFR *)ref,fPosX,fPosY,fPosZ,fAngX,fAngY,fAngZ,(int)(1000 * fTimeStep),90.0);
					//Actor::PlayIdle((CActor *)ref, (TESIdleForm *)Game::GetFormById(686366));
					// *iFlapCD -= (int)(1000 * fTimeStep)/2;
					// PrintNote("Flap CD reached: %i.", *iFlapCD);
					//*iFlapCD -= (int)(1000 * fTimeStep);
               }else if(isFlying) {
				//ObjectReference::StopTranslation((TESObjectREFR *)ref);
				ObjectReference::TranslateTo((TESObjectREFR *)ref,fPosX,fPosY,fPosZ,fAngX,fAngY,fAngZ,(int)(1000 * fTimeStep),90.0);
				Utility::SetINIFloat("fInAirFallingCharGravityMult:Havok",0.2);
				//Actor::PlayIdle((CActor *)ref, (TESIdleForm *)Game::GetFormById(686366));
				
			}
			else{
				ObjectReference::StopTranslation((TESObjectREFR *)ref);
				Utility::SetINIFloat("fInAirFallingCharGravityMult:Havok",1.35);
				if (*iFlapCD > 0) {
					*iFlapCD -= (int)(1000 * fTimeStep);
					if (*iFlapCD < 0) {
						*iFlapCD = 0;
					}
					if (*iFlapCD == 0) {
						PrintNote("Flap CD reset: %i.", *iFlapCD);
					}
				}
               }
       }
}

void main()
{
       BYTE FlapKey = IniReadInt(CONFIG_FILE, "Flight", "FlapKey", 0);
       bool bAutoFly = IniReadInt(CONFIG_FILE, "Flight", "bAutoFlap", 0);
	int iFlightTimeMax = IniReadInt(CONFIG_FILE, "Flight", "iFlightTimeMax", 5000);
	float fFlightSpeed = IniReadInt(CONFIG_FILE, "Flight", "fFlightSpeed", 1000);
       PrintNote("[%s] started, press '%s' to use", SCR_NAME, GetKeyName(FlapKey).c_str());
       int iFlapCD = 0;
	float fSpeed = 0.0;
	float fTimeStep = 0.5;
       while (TRUE)
       {
               if (true){
                       CActor *player = Game::GetPlayer(); 
                       flySim(&FlapKey, (PlayerCharacter *)player, bAutoFly, &iFlapCD, &fFlightSpeed, &fSpeed, &iFlightTimeMax, fTimeStep);
               }
               Wait(fTimeStep*1000);
       }
}

 

what are your numbers in the config file?

Link to comment
Share on other sites

Collision Idea time! How about filling a dungeon with "flight" trigger prefab refs (trap triggers) where you want the player to be ALLOWED to fly. Then you use the OnTranslateAlmostComplete() event to check that the player is inside one of the prefabs. If he leaves the box, StopTranslation() will cancel the movement and keep him in the prefab. Then all you have to do is overlap prefabs throughout your dungeons where you want the player to be allowed to fly. The problem with this is obviously having to cover every inch of viable space in your dungeon with prefabs, because if the player were to activate flying outside the prefab you would have the no clipping problem again.

 

My only uncertainty is whether or not you can check if a player is in a prefab object and not just a specific object ref.

 

Alternatively you could "cage" your dungeon area with triggers and StopTranslation() if the player enters a "no flight" trigger.

 

What you all think? The big question is will an actor toggle trap prefabs using TranslateTo()...

 

edit: I take back the no clipping problem. The player simply wouldn't be able to move at all while flying since StopTranslation() would always get called outside the trigger area.

Edited by dontkeepscore
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...