jimhsu Posted February 25, 2012 Share Posted February 25, 2012 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? ; home [Flight]FlapKey=0xA0bAutoFlap=1 These two lines are default values: int iFlightTimeMax = IniReadInt(CONFIG_FILE, "Flight", "iFlightTimeMax", 5000);float fFlightSpeed = IniReadInt(CONFIG_FILE, "Flight", "fFlightSpeed", 1000); Currently I'm using poorone's script, so this part of the code is on hold until I figure more stuff out. Link to comment Share on other sites More sharing options...
jimhsu Posted February 25, 2012 Share Posted February 25, 2012 Notes: - I think SendAnimationEvent only works if called every frame. Hence, it doesn't work in my Script Dragon code. You could make it every frame if you wanted...- As far as translation speed ... should I just use a constant? I think that will probably work better.- Might look later into making a placeholder anim for JumpFall using the wings skeleton. (argh - I don't want to open up 3ds max for the 20th time already). Link to comment Share on other sites More sharing options...
Korodic Posted February 25, 2012 Share Posted February 25, 2012 Honestly I would use the shout button to activate flying. As well as the shout button to stop flying. Reason being is it will make it compatible with controllers, and the shout button is already your special button for special stuff to happen ;) Link to comment Share on other sites More sharing options...
Skyes666 Posted February 26, 2012 Share Posted February 26, 2012 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. There is a sex mod which managed to add a new animation without replacing anything. Quote from the mod::Idle's Replaced...NONE... Ma ha ha, Skyrim anim ARE posible, just HARD to get working.It works buy "Hot Swaping" the player/npc race to a tempery Race(One for each Defult Race) and Replacing that Race's anims, So All Vinlla anims still work but I can play my "New" Anim's when needed. I'm not sure if it's allowed to link to adult mods but here it is: http://skyrim.nexusmods.com/downloads/file.php?id=10748 Link to comment Share on other sites More sharing options...
Galacticat42 Posted February 26, 2012 Share Posted February 26, 2012 (edited) Just got myself a 23", 1080p, HDMI capable, LED monitor so now it's gunna be all awesome playing now. Back on topic, I've been working on your modifications Jimhsu, so I'll be putting something out by monday. NOTE: I don't really like the max flight time limit you've put on there, I'm gunna make it a conditional argument. Edited February 26, 2012 by Budz42 Link to comment Share on other sites More sharing options...
Skyes666 Posted February 26, 2012 Share Posted February 26, 2012 Just got myself a 23", 1080p, HDMI capable, LED monitor so now it's gunna be all awesome playing now. Back on topic, I've been working on your modifications Jimhsu, so I'll be putting something out by monday. NOTE: I don't really like the max flight time limit you've put on there, I'm gunna make it a conditional argument. Just wondering but can I beta test some of the dragon mods you guys have created? I'm looking forward to seeing what you guys will create. Link to comment Share on other sites More sharing options...
Korodic Posted February 26, 2012 Share Posted February 26, 2012 Hey guys I saw this and it looked semi-relevant, not sure if you guys saw it or not. http://forums.bethsoft.com/topic/1348962-setplayercontrols-and-papyrus/ Link to comment Share on other sites More sharing options...
xyks Posted February 26, 2012 Share Posted February 26, 2012 I was just watching the new Skyrim mods episode and it seems it has a hover animation in it. Check it out: http://skyrim.nexusmods.com/downloads/file.php?id=10809 (5:26) Though it is for females, but I think for the start its better than a falling animation even for males... Link to comment Share on other sites More sharing options...
Galacticat42 Posted February 26, 2012 Share Posted February 26, 2012 That's not a hover anim, it's just the havok engine trying to match her feet with the rock she's standing on. Link to comment Share on other sites More sharing options...
xyks Posted February 26, 2012 Share Posted February 26, 2012 (edited) Are you sure? It really looks like shes moving up and down. Even if she was standing she would only touch the ground with her toe tips. The closest animation to hovering for player models I have seen so far though. Just a suggestion anyway ;) Edit: Just tested it and yeah it is a standing animation though only her left food aligns to the ground :( Edited February 26, 2012 by xyks Link to comment Share on other sites More sharing options...
Recommended Posts