Jump to content

Simple Script problem


Skree000

Recommended Posts

Hiya y'all. This pertains to a mod im working on that isnt exactly for oblivion (its for Fo3) but it uses the same script language, basically...

I have a really simple concept im trying to get working but i cant seem to figure it out cos im a scripting nub.

 

The idea is i have 2 knives, the J2 Combat Knife, and a dummy placeholder.

I want the J2Combat Knife to behave normally until it is sheathed, at which point a dummy placeholder appears in the place of the sheathed weapon.

When that dummy is drawn, the J2Combat Knife comes back into your hand instead.

 

(all this is to alleviate the problem i created when i made a dagger with reverse grip, since when you hold it reversed, it sheathes reversed too, and sticks up in the air and outwards. (i just flipped it in nifskope)

So my plan was to have an original (unflipped) version, that it swaps to whenever you sheath it. And if that weapon is ever drawn, the reverse one, comes back

 

so, i implemented 2 codes, one attached to either weapon, and now Fallout3 freezes up when i try to equip the J2 knife from my bags.

here are the two code blocks

 

J2CombatKnife script:

Begin Gamemode
player.removeitem 2142WeapDummy 1 1					;remove any pre-existing dummies		
If player.IsWeaponOut == 0					;if weapon is Sheathed/Holstered...
	player.additem 2142WeapDummy 1 1			  ;add and equip the dummy knife
	player.equipitem 2142WeapDummy 1 1
endif
End

 

Dummyknife Script:

begin onequip  
if player.IsWeaponOut == 1								;if weapon IS drawn
	player.equipitem 2142WeapJ2CombatKnife 0 1				;replace it with the J2 knife
endif 
end


begin onunequip
player.removeitem 2142WeapDummy 1 1									;if dummy is ever unequipped, destroy it so it doesnt show up in bags, etc.
end

 

 

(PS. Also, if there is a way to hide things from the inventory window, that would be ideal, since Dummy object is not meant to be seen in there ... =(

 

 

Thankyou SO much if any of you Oblivion modding veterans can help little ol me out with this problem. You will get big hugs and credits when the mod is done :)

 

Thankyou again if you can help at all!

Link to comment
Share on other sites

Try putting a timer on the script so that the dummy knife is equipped a few frames after the 1st knife gets un-equipped.

 

Or it might help if just one script handles the knife changes. Maybe a quest script?

 

Or have the J2 knife call on the dummy knife when it gets sheathed and that's it. Then have the dummy knife call on the J2 when it get un-sheathed. So...

 

Something like this would go in the J2

 

begin gameMode
if player.isWeaponout == 1
	return
else
player.equipitem dummyKnife								 
end

 

And this goes in the dummy knife

 

begin gameMode
if player.isWeaponout == 0
	return
else
player.equipitem J2CombatKnife						
end

 

 

try it and let me know if it works.

Link to comment
Share on other sites

Thanks very much :)

 

i tried it out and it says first that there was some syntax errors with the if statement, so i ended them with endifs...

then i found that it would run the scripts whenever ANY weapon was out, so i added a conditional to make it only happen when those specific weapons are drawn...

 

now the problem is, when i equip the J2 knife, it freezes up...

 

here are my two codes as they stand now with your modifications.

 

 

scriptname J2CombatKnife

begin gameMode
if player.GetEquippedObject 5 == "2142WeapJ2CombatKnife" 
if player.isWeaponout == 0
	player.additem 2142WeapDummy 1 1
	   player.equipitem 2142WeapDummy 0 1								
endif
endif
end

 

scriptname BF2142DummyWeaponSheathFixer

begin gameMode
if player.GetEquippedObject 5 == "2142WeapDummy" 
if player.isWeaponout == 1
	player.equipitem 2142WeapJ2CombatKnife 0 1						
endif
endif
end

 

i tried it with the returns and it still froze up... so i omitted them, no change.

 

does 'return' simply do nothing and move to the next line in the script?

Link to comment
Share on other sites

ok changed the scripts to

(J2 script)

begin onequip
player.removeitem 2142WeapDummy 100 1
if player.GetEquippedObject 5 == "2142WeapJ2CombatKnife" 
if player.isWeaponout == 0
	player.additem 2142WeapDummy 1 1
	   player.equipitem 2142WeapDummy 0 1								
endif
endif
end

 

 

(dummyscript)

 

scriptname BF2142DummyWeaponSheathFixer

begin onequip
if player.GetEquippedObject 5 == "2142WeapDummy" 
if player.isWeaponout == 1
	player.equipitem 2142WeapJ2CombatKnife 0 1	 
else
	return				   
endif
endif
end

 

however now whenever i equip the J2 combat knife, it auto equips the dummy, nomatter what... (i added the remove command at the beginning of the J2 code to remove accumulated dummies that were piling up)

 

also it wont let me unequip the J2 combat knife, when i try from pipboy, i hear 2 equip noises back to back and its equipped again. (that might be because i had the weapon out while i was trying?)

Link to comment
Share on other sites

BTW this site: http://cs.elderscrolls.com/constwiki/index.php/EquipItem

 

Says that the equipitem command may not work when used with aditem in the same script without some delay between the two actions.

 

..."This function does not always work when used to equip items which have been added to an inventory using addItem, unless you provide a delay between adding the items and equipping them. For instance:..."

 

Let me know if you get it to work. Cuz you may have solved a problem i was facing with a weapon mod i'm planning on making. It's something like a small black orb that turns into a huge f*#@en sword when it's un-sheathed. I wanted to animated the orb turning into the sword, but you can't run different animations on weapons.

Link to comment
Share on other sites

yup read that a few mins ago and added a delay between the add and equip on the j2... to help diagnose i put a ShowMessage of 'J2 holstered' in there, whenever the conditions were met to holster it and add/equip the other... but the message never popped up when i used the timer...

 

i just noticed that weapons auto-holster when you open the pipboy to manage your inventory, so, for example, when you equip the J2, it starts out holstered, but the pipboy is also up.... i think this can be checked with a command called GetControlsDisabled (which Returns true if any of the player's controls are currently disabled. )

 

maybe i can adapt that as an additional conditional, to ensure the dummy is never swapped while players controls are disabled?

 

 

 

edit: no luck with the GetControlsDisabled... it always seems to give 0.00, that all functions are enabled, even when the pipboy is open... i dont get that at all

Link to comment
Share on other sites

  • Recently Browsing   0 members

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