BackPack Script - I give up

Post » Tue Jun 19, 2012 3:39 am

hi all, first I apologize for my bad English, I'll start with what I've tried to do, make all the equipment visible. so i make this script on the player's actor

Spoiler

Scriptname DesequiparArco extends Actor{Accion al desequipar el arco}import gameimport utility;Tipo de arma que el jugador pondraInt TipoArmaMLInt TipoArmaMRInt TipoArmaG;Arma que se cargara al jugadorObjectReference Property ORDL Auto HiddenObjectReference Property ORDR Auto HiddenObjectReference Property ORArmaML Auto HiddenObjectReference Property ORArmaMR Auto HiddenObjectReference Property ORArmaG Auto HiddenObjectReference Property ORArco Auto Hidden;Arma equipada del jugadorWeapon CurrentWeaponLWeapon CurrentWeaponR;Armas usadasweapon WDLweapon WDRweapon WArmaMLweapon WArmaMRweapon WArmaGweapon WArco;Tipo de arma equipadaint PlayersEquippedWeaponTypeLint PlayersEquippedWeaponTypeR;Jugadoractor playerFunction placeFakeWeapon(bool HandEquip)ORDL.delete()ORDR.delete()ORArmaML.delete()ORArmaMR.delete()ORArmaG.delete()ORArco.delete()ObjectReference  ORPlayer = Game.GetPlayer()if ( WDL !=  None ) || (PlayersEquippedWeaponTypeR != 2)  ORDL = player.PlaceAtMe(WDL, 1, true)  ORDL.MoveToNode(player, "WeaponDagger")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponDagger", ORDL, "ElvenDagger")endifif ( WDR !=  None ) || (PlayersEquippedWeaponTypeR != 4)  ORDR = player.PlaceAtMe(WDR, 1, true)  ORDR.MoveToNode(player, "WeaponMace")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponMace", ORDR, "ElvenDagger")endifif ( WArmaMR !=  None ) || (PlayersEquippedWeaponTypeR != 3)  ORArmaMR = player.PlaceAtMe(WArmaMR, 1, true)  ORArmaMR.MoveToNode(player, "WeaponAxe")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponAxe", ORArmaMR, "ElvenWarAxe")endifif ( WArmaML !=  None ) || (PlayersEquippedWeaponTypeR != 1)  ORArmaML = player.PlaceAtMe(WArmaML, 1, true)  ORArmaML.MoveToNode(player, "WeaponSword")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponSword", ORArmaML, "ElvenSword")endifif ( WArmaG !=  None ) || (PlayersEquippedWeaponTypeR != 5) || (PlayersEquippedWeaponTypeR != 6) || (PlayersEquippedWeaponTypeR != 8)  ORArmaG = player.PlaceAtMe(WArmaG, 1, true)  ORArmaG.MoveToNode(player, "WeaponBack")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponBack", ORArmaG, "ElvenGreatSword")endifif ( WArco !=  None ) || (PlayersEquippedWeaponTypeR != 7)  ORArco = player.PlaceAtMe(WArco, 1, true)  ORArco.MoveToNode(player, "WeaponBow")  Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponBack", ORArco, "ElvenBowSkinned.nif")endifif (handEquip == False)  if (PlayersEquippedWeaponTypeR == 1)	ORArmaML = player.PlaceAtMe(WArmaML, 1, true)	ORArmaML.MoveToNode(player, "WeaponAxe")	Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponAxe", ORArmaML, "ElvenSword")  elseif (PlayersEquippedWeaponTypeR == 2)	ORDL = player.PlaceAtMe(WDL, 1, true)	ORDL.MoveToNode(player, "WeaponAxe")	Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponAxe", ORDL, "ElvenDagger")  elseif (PlayersEquippedWeaponTypeR == 4)	ORDR = player.PlaceAtMe(WDR, 1, true)	ORDR.MoveToNode(player, "WeaponAxe")	Game.AddHavokBallAndSocketConstraint(ORPlayer, "WeaponMace", ORDR, "ElvenDagger")  endifendifendFunctionEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference)if akBaseObject as Weapon  player = Game.GetPlayer()  PlayersEquippedWeaponTypeL = player.GetEquippedItemType(0)  PlayersEquippedWeaponTypeR = player.GetEquippedItemType(1)  CurrentWeaponL = player.GetEquippedWeapon(true)  CurrentWeaponR = player.GetEquippedWeapon()  int CountItem = player.GetItemCount(akBaseObject)  if (PlayersEquippedWeaponTypeL == 1) || (PlayersEquippedWeaponTypeL == 3) || (PlayersEquippedWeaponTypeL == 4)   if(WArmaML == None) || (WArmaML != None)  && (WArmaML != CurrentWeaponL)	Debug.MessageBox("estas usando un ARMA MEDIANA en la mano izquierda " + PlayersEquippedWeaponTypeL + " y tienes " + CountItem)	TipoArmaML = PlayersEquippedWeaponTypeL	WArmaML = CurrentWeaponL	PlaceFakeWeapon(true)   endif  elseif (PlayersEquippedWeaponTypeL == 2)   if(WDL == None) || (WDL != None) && (WDL != CurrentWeaponL)	Debug.MessageBox("estas usando una DAGA en la mano izquierda")	WDL = CurrentWeaponL	PlaceFakeWeapon(true)   endif  elseif (PlayersEquippedWeaponTypeL == 5) || (PlayersEquippedWeaponTypeL == 6) || (PlayersEquippedWeaponTypeL == 8)   if(WArmaG == None) || (WArmaG != None) && (WArmaG != CurrentWeaponL)	Debug.MessageBox("estas usando un ARMA GRANDE " + PlayersEquippedWeaponTypeL)	WArmaG = CurrentWeaponL	TipoArmaG = PlayersEquippedWeaponTypeL	PlaceFakeWeapon(true)   endif  elseif (PlayersEquippedWeaponTypeL == 7)   if(WArco == None) || (WArco != None) && (WArco != CurrentWeaponL) && (WArco != CurrentWeaponR)	Debug.MessageBox("estas usando un ARCO " +  PlayersEquippedWeaponTypeR + PlayersEquippedWeaponTypeL)	WArco = CurrentWeaponL	PlaceFakeWeapon(true)   endif  endif  if (PlayersEquippedWeaponTypeR == 1) || (PlayersEquippedWeaponTypeR == 3) || (PlayersEquippedWeaponTypeR == 4)   if(WArmaMR == None) || (WArmaMR != None) && (WArmaMR != CurrentWeaponR)	Debug.MessageBox("estas usando un ARMA MEDIANA en la mano derecha " + PlayersEquippedWeaponTypeR)	WArmaMR = CurrentWeaponR	TipoArmaMR = PlayersEquippedWeaponTypeR	PlaceFakeWeapon(false)   endif  elseif (PlayersEquippedWeaponTypeR == 2)   if(WDR == None) || (WDR != None) && (WDR != CurrentWeaponR)	Debug.MessageBox("estas usando una DAGA en la mano derecha")	WDR = CurrentWeaponR	PlaceFakeWeapon(false)   endif  elseif (PlayersEquippedWeaponTypeR == 5) || (PlayersEquippedWeaponTypeR == 6) || (PlayersEquippedWeaponTypeR == 8)   if(WArmaG == None) || (WArmaG != None) && (WArmaG != CurrentWeaponR)	Debug.MessageBox("estas usando un ARMA GRANDE" + PlayersEquippedWeaponTypeR)	WArmaG = CurrentWeaponR	TipoArmaG = PlayersEquippedWeaponTypeR	PlaceFakeWeapon(false)   endif  elseif (PlayersEquippedWeaponTypeR == 7)   if(WArco == None) || (WArco != None) && (WArco != CurrentWeaponR) && (WArco != CurrentWeaponL)	Debug.MessageBox("estas usando un ARCO" +  PlayersEquippedWeaponTypeL)	WArco = CurrentWeaponR	PlaceFakeWeapon(false)   endif  endifendIfendEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer)player = Game.GetPlayer()  if (player.GetItemCount(akBaseItem) == 0)   if(WArmaML != None) && (WArmaML == akBaseItem)	WArmaML = None	 Debug.MessageBox("Te quedaste sin ARMA MEDIANA en la mano izquierda")   endif   if(WArmaMR != None) && (WArmaMR == akBaseItem)	WArmaMR = None	 Debug.MessageBox("Te quedaste sin ARMA MEDIANA en la mano derecha")   endif   if(WDL != None) && (WDL == akBaseItem)	WDL = None	 Debug.MessageBox("Te quedaste sin DAGA en la mano derecha")   endif   if(WDR != None) && (WDR == akBaseItem)	WDR = None	 Debug.MessageBox("Te quedaste sin DAGA en la mano derecha")   endif   if(WArco != None) && (WArco == akBaseItem)	WArco = None	 Debug.MessageBox("Te quedaste sin ARCO")   endif   if(WArmaG != None) && (WArmaG == akBaseItem)	WArmaG = None	 Debug.MessageBox("Te quedaste sin ARMA GRANDE")   endif  endifendevent


works well for a second, then fall like any object. but if you combine it with the skeleton.nif this link https://skydrive.live.com/redir.aspx?cid=3bccba04977408d0&resid=3BCCBA04977408D0!356&parid=root , some weapons are attached, the problem is that they move with havok physics attached at a point. only works with the Elven Set, this is where my problem begins.


first of all, why change the skeleton.nif, I realized that the .AddHavokBallAndSocketConstraint () function works only with rigid nodes, so that was the only thing I added to the weapon nodes in the file. which took from a weapon nif file. (if you want use this function on the dynamic nodes such hands and legs, you should add this line before .ForceAddRagdollToWorld() and this after .ForceRemoveRagdollFromWorld(), although you probably already know that )

the reason it only works on the Elven set, is because the .AddHavokBallAndSocketConstraint () function, call the nodes of the objects, here it gets interesting, each weapon has a different node name, that is why i just set the Elven nodes to prove my point. so the most obvious solution for me is finding a way to add rigid nodes on the weapon nif files( node would be the same for all weapons, such as PointA, so the script would need to seek a single node ). sounds easy, but for me it is not, I have tried in many ways, I made the script read the nodes, but does not work. if this is solved i see two possible ways:

1.- having the node A in each weapon, would only need to find a way to stiffen the weapon attached, and is not .SetMotionType, I've tried, but perhaps you have better luck

2.- have three nodes A, B and C. to form a flat triangle serve to stiffen the weapon whit .AddHavokBallAndSocketConstraint () on each node, the triangle also be in the weapon nodes.

to have this resolved, would only need to find a way to disable the weapons, when the player is wielding, for which I have not found an event like OnDraw or something.

I'm posting this because I got tired of trying many ways, I just want it to work, if anyone is interested and wants to continue it, I think this is a start. I hope this serves as something. and if it is impossible to do, please do not tell me, I remain hopeful xD
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Return to V - Skyrim