Jump to content

[WIP] Working visible weapon mod


slevin92

Recommended Posts

Wow, that simple? I've been making things way too complicated it seems haha, thank-you mate, I'll try your solution today thank-you very much mate! ^.^

 

As for cloning weapons - I think the script will need a little adjustment but I asked last night and DieFeM the genius wrote me a solution - check it out :)

 

https://forums.nexusmods.com/index.php?/topic/7441996-clonecopy-weapon-by-script/?p=68154286&do=findComment&comment=68154286

 

My idea is to have a cloned weapon on the back rather than the players actual gun (just incase it disappears, and that way there should be no transition time where the weapon is not found in the inventory :)

Link to comment
Share on other sites

My mod work the same way, The weapon on the back is not the real weapon but a copy of it with all mods. And that copy disappear when you draw or change weapon. Put the real weapon on the back make it nearly impossible to get it back.

 

Thanks for the script, it really help to find a solution for int / ext cell transition. It look like the OnPlayerTeleport event dont work well or i miss something.

Link to comment
Share on other sites

Hey again mate, no problem :smile: happy to help any way i can especially considering that were working on the same kind of idea :smile:

Mind if i take a look and see what i can do with it?

 

This is what i have so far as a test... Bearing in mind that i only got it to start working this morning, and it doesnt work well yet...

((and the only reason i put the time into making it work was because you confirmed that place at node works, before seeing this thread i only had theories about the place at node function, like i say, i just couldnt get it working, and i bet i couldnt get it working before because the script wasnt attached to a quest.))

Scriptname Weapon_SM_Equip extends Quest

FormList Property SM_WeaponList Auto Mandatory Const

Event OnQuestInit()
    RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
    If SM_WeaponList.Find(akBaseObject) >= 0
        UnregisterForRemoteEvent(akActor, "OnItemEquipped")
            Debug.Notification("something equipped")
	    RegisterForRemoteEvent(akActor, "OnItemEquipped")

	    If akActor.HasNode("RArm_Hand")
		Debug.Notification("Found Node")
		Weapon MyEquippedWeapon = game.getplayer().getequippedweapon(0)
		    Debug.Notification("got equipped weapon")

		    ObjectReference MyNewItem = Game.GetPlayer().PlaceAtNode("RArm_Hand", Mynewweapon, aiCount = 1, abForcePersist = True, abInitiallyDisabled = false, abDeleteWhenAble = False, abAttach = True)
			Debug.Notification("weapon placed at node")
	    EndIf
    EndIf
EndEvent

But for some reason even though i have "Bool abAttach = True" the weapon just floats in mid air at the original place where the node was... when i walk around the weapon is not attached to the player and doesnt follow me around... i have no idea why it wont attach?

 

so i tried forcing the weapon to have a reference id first before placing at node... i tried "drop()" and "PlaceAtMe" like in the script bellow, but then the weapon stays on the floor where place at me put it, it doesnt move to the node when using place at node...

Scriptname Weapon_SM_Equip extends Quest

FormList Property SM_WeaponList Auto Mandatory Const

Event OnQuestInit()
    RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
    If SM_WeaponList.Find(akBaseObject) >= 0
        UnregisterForRemoteEvent(akActor, "OnItemEquipped")
            Debug.Notification("something equipped")
	    RegisterForRemoteEvent(akActor, "OnItemEquipped")

	    If akActor.HasNode("RArm_Hand")
		Debug.Notification("Found Node")
		Weapon MyEquippedWeapon = game.getplayer().getequippedweapon(0)
		    Debug.Notification("got equipped weapon")

		    ObjectReference MyNewItem = Game.GetPlayer().PlaceAtMe(MyEquippedWeapon)

		    ObjectReference MyNewItem2 = Game.GetPlayer().PlaceAtNode("RArm_Hand", Mynewitem, aiCount = 1, abForcePersist = True, abInitiallyDisabled = false, abDeleteWhenAble = False, abAttach = True)
			Debug.Notification("weapon placed at node")
			MyNewItem2.AttachTo(Game.GetPlayer())
 			    Debug.Notification("weapon attached")
	    EndIf
    EndIf
EndEvent

So i also tried a "AttachTo" command at the bottom to see if that forces the weapon to attach to anything... but unfortunately it still doesnt attach.

((i wonder if its because im using a default node instead of a custom node?))

 

 

so an idea for your problem mate - can you use "IsTeleportAreaLoaded" to pick up the teleporting event? it should pick up nicely after all 3d is loaded :smile: https://www.creationkit.com/fallout4/index.php?title=IsTeleportAreaLoaded_-_ObjectReference

Edited by SandMouseAnarchy
Link to comment
Share on other sites

After a lot of tries, I'll leave this feature for now. Apparently the problem wasn't the Event (confirmed by a debug.notification) but the container reference. I tried with container and an human actor as container. Both don't add the duplicated weapon on drop so i can't get the previous copy back after changing cell >_<

 

The AttachTo feature seems to not work with the player. I had to make it follow the player as a replacer. So technically, it's not attached to the player, with a low script latency, it's barely noticeable.

Link to comment
Share on other sites

Lol that's what I mean, what is a "replacer"? Ooooooh do you mean that you re-place the weapon using "MoveTo"? Or are you using "PathToReference"?
((I'm going to test pathtoreference next, as I just can't think of another way to do things.))

 

*EDIT*

So it turns out that "PathToReference" wont work, or atleats i cant get it to work on anything that isnt an actor and i dont think we can make a weapon an actor. Maybe "TranslateTo" and/or "SetMotionType(7, True)" might work? (still trying to figure out how to get the weapon to follow the player ^.^)

Edited by SandMouseAnarchy
Link to comment
Share on other sites

So, ive been experimenting with "TranslateTo", "SplineTranslateToRef" and "SplineTranslateToRefNode" but with only limited sucsess...

This is what i have working so far -

Scriptname Weapon_SM_Equip extends Quest

FormList Property SM_WeaponList Auto mandatory Const

Event OnQuestInit()
    RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
    If SM_WeaponList.Find(akBaseObject) >= 0
	UnregisterForRemoteEvent(akActor, "OnItemEquipped")
	    Debug.Notification("something equipped")
	RegisterForRemoteEvent(akActor, "OnItemEquipped")
	If akActor.HasNode("RArm_Hand")
	    Debug.Notification("Found Node")
	    Weapon MyEquippedWeapon = game.getplayer().getequippedweapon(0)
		Debug.Notification("got equipped weapon")
;-----------------------------------------------------------------------------------
ObjectReference MyNewItem = Game.GetPlayer().PlaceAtNode("RArm_Hand", MyEquippedWeapon, aiCount = 1, abForcePersist = True, abInitiallyDisabled = false, abDeleteWhenAble = False, abAttach = True)
    Debug.Notification("weapon placed at node")
	MyNewItem.TranslateToRef(Game.GetPlayer(), 100)
	    Debug.Notification("translating to...")
	EndIf
    EndIf
EndEvent

Function TranslateToRef(ObjectReference arTarget, float afSpeed, float afMaxRotationSpeed = 0.0) ; TranslateTo(arTarget.X, arTarget.Y, arTarget.Z, arTarget.GetAngleX(), arTarget.GetAngleY(), arTarget.GetAngleZ(), afSpeed, afMaxRotationSpeed) 
    Debug.Notification("function = translating...")
	registerForRemoteEvent(Game.GetPlayer(), "OnTranslationComplete")
endFunction

Event ObjectReference.OnTranslationComplete(ObjectReference arTarget)
    Debug.Trace("Translation Done!")
EndEvent

So at this point the weapon is placed in the world, but it isnt placed exactly at node anymore, it places to the side of the player, and then the weapon slowly moves over to the player. which isnt bad for a test...

 

Im trying to pick up the OnTranslationComplete Event to loop the "translateTo" command, but that isnt giving me the debug, even when i register for "onTranslationComplete" so im not sure whats going on there...

 

Here is what i tried with "splineTranslateToRefNode" instead...

Scriptname Weapon_SM_Equip extends Quest native

FormList Property SM_WeaponList mandatory

Event OnQuestInit()
    RegisterForRemoteEvent(Game.GetPlayer(), "OnItemEquipped")
EndEvent

Event Actor.OnItemEquipped(Actor akActor, Form akBaseObject, ObjectReference akReference)
    If SM_WeaponList.Find(akBaseObject) >= 0
	UnregisterForRemoteEvent(akActor, "OnItemEquipped")
	    Debug.Notification("something equipped")
	RegisterForRemoteEvent(akActor, "OnItemEquipped")
	If akActor.HasNode("RArm_Hand")
	    Debug.Notification("Found Node")
	    Weapon MyEquippedWeapon = game.getplayer().getequippedweapon(0)
		Debug.Notification("got equipped weapon")
;-----------------------------------------------------------------------------------
ObjectReference MyNewItem = Game.GetPlayer().PlaceAtNode("RArm_Hand", MyEquippedWeapon, aiCount = 1, abForcePersist = True, abInitiallyDisabled = false, abDeleteWhenAble = False, abAttach = True)
    Debug.Notification("weapon placed at node")
       MyNewItem.SplineTranslateToRefNode(Game.GetPlayer(), "RArm_Hand", 100, 100)
	    Debug.Notification("translating to...")
	EndIf
    EndIf
EndEvent

 
Function SplineTranslateToRefNode(ObjectReference arTarget, string arNodeName, float afTangentMagnitude, float afSpeed, float afMaxRotationSpeed = 0.0) native
    Debug.Notification("function = translating...")
	registerForRemoteEvent(Game.GetPlayer(), "OnTranslationComplete")
endFunction

Event ObjectReference.OnTranslationComplete(ObjectReference arTarget)
    Debug.Trace("Translation Done!")
EndEvent

I thought this would work well, but i get a ton of compile errors saying the script has to be tagged as native etc,

and im unsure if im calling the "onTranslationComplete" event right, im going to guess not because this way i still cant get the debug from it and if i remove the "ObjectReference" part from the beggining of "Event ObjectReference.OnTranslateComplete()" it gives errors saying type mismatch, and if i dont put "(ObjectReference arTarget)" at the end of the event then i get an error saying that the event needs atleast one paramitor in it... but the wiki only gives "Event OnTranslationComplete()" as an example with no paramitors.

 

So all in all, i think "TranslateTo" is going to be the one to use, i just need to find away to keep the weapon constantly Translating to player.

Link to comment
Share on other sites

I think i'll release the mod tomorrow as a beta. I'll upload it with the source script so you can see how i made it work for now. There's probably some others way to build something like this. It definitely need Fo4 hotkeys to favorite any weapons. the vanilla favorite system bug as hell :/ and it was the cause of my fire at the PlaceAtNode then CTD.

 

I used the SplineTranslateToRefNode with a high speed so the weapon move faster than the player. It's the only things I found to keep the weapon close to the player. This and a lot of globalvariable to work between multiple scripts.

Edited by slevin92
Link to comment
Share on other sites

It's really great work mate! Have you thought about posting this project to the creation kit bit of the forum? I've been chatting to some of the guys there and I bet they would love to see this if they haven't seen it already ^.^

 

Cool, well no need to rush anything for my sake mate ^.^ I'm setting this approach to the side for now and looking at other ways to do things, I would be happy to help out in any way I can though :)

Seeing as you're so close to release, can I make a massssssssive request? Grenades... Grenades... Grenades ^.^ and a mini nuke ;)

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...