How to add custom ammo to a bow

Post » Mon Feb 14, 2011 5:42 am

I'm making a crossbow model but I don't want it to fire normal arrows.. just my custom made "bolts". Any ideas on how this works would be greatly appreciated. Thanks
User avatar
Barbequtie
 
Posts: 3410
Joined: Mon Jun 19, 2006 11:34 pm

Post » Mon Feb 14, 2011 9:51 am

I'm making a crossbow model but I don't want it to fire normal arrows.. just my custom made "bolts". Any ideas on how this works would be greatly appreciated. Thanks


Attach a script to the crossbow that automatically equips your bolts when the crossbow is equipped. You could also set it up to unequip the crossbow if no bolts are in the Player's inventory. Something like:

scn ScriptNameHereBegin OnEquip playerif player.getitemcount CrossbowBoltID >= 1  player.equipitem CrossbowBoltIDelseif player.getitemcount CrossbowBoltID < 1  messagebox "You have no usable ammunition."  Player.unequipitem CrossbowIDendifend

User avatar
joannARRGH
 
Posts: 3431
Joined: Mon Mar 05, 2007 6:09 am

Post » Mon Feb 14, 2011 5:26 pm

Attach a script to the crossbow that automatically equips your bolts when the crossbow is equipped. You could also set it up to unequip the crossbow if no bolts are in the Player's inventory. Something like:

scn ScriptNameHereBegin OnEquip playerif player.getitemcount CrossbowBoltID >= 1  player.equipitem CrossbowBoltIDelseif player.getitemcount CrossbowBoltID < 1  messagebox "You have no usable ammunition."  Player.unequipitem CrossbowIDendifend



Excellent thanks =D

Ah okay works brilliant and all but would it be possible to prevent the PC from equiping other ammo. As It equips the bolts just fine but then you can just switch.
The only way I can think of doing it is to add a bit onto every arrow script but is there a simpler less messy way?
User avatar
JERMAINE VIDAURRI
 
Posts: 3382
Joined: Tue Dec 04, 2007 9:06 am

Post » Mon Feb 14, 2011 7:00 am

Excellent thanks =D

Ah okay works brilliant and all but would it be possible to prevent the PC from equiping other ammo. As It equips the bolts just fine but then you can just switch.
The only way I can think of doing it is to add a bit onto every arrow script but is there a simpler less messy way?

Well, AFAIK, that would require "mentioning" every single arrow's FormID in the script, so the first suggestion is a really rational and easy solution. Besides, if someone ever used your mod with custom made arrows from another mod, they would be equipped because you can't put something in a script you don't know of.
User avatar
Kyra
 
Posts: 3365
Joined: Mon Jan 29, 2007 8:24 am

Post » Mon Feb 14, 2011 3:33 pm

Excellent thanks =D

Ah okay works brilliant and all but would it be possible to prevent the PC from equipping other ammo. As It equips the bolts just fine but then you can just switch.
The only way I can think of doing it is to add a bit onto every arrow script but is there a simpler less messy way?


As Sami_ said, adding a bit to the script for every arrow would be beyond tedious (you would have to include every type of enchanted arrow in the game) and would do nothing for mod added arrows. A simpler method would be to add a GameMode block to the script forcing the player to equip the custom ammo. Something like:

scn ScriptNameHereBegin OnEquip playerif player.getitemcount CrossbowBoltID >= 1  player.equipitem CrossbowBoltIDelseif player.getitemcount CrossbowBoltID < 1  messagebox "You have no usable ammunition."  Player.unequipitem CrossbowIDendifendBegin GameMode If player.getequippeditem CrossbowID == 1  If player.getequippeditem CrossbowBoltID == 0 && Player.getitemcount CrossbowBoltID > 0    Messagebox "You must use the correct ammunition for this weapon."    player.equipitem CrossbowBoltID  Endif EndifEnd


That should fix the issue. Also, you may want to give the crossbow an enchantment of some kind. Otherwise, the Player could enchant the crossbow, which would remove the script from it.
User avatar
Anna S
 
Posts: 3408
Joined: Thu Apr 19, 2007 2:13 am

Post » Mon Feb 14, 2011 9:45 pm

OBSE's getequippedobject in gamemode script, use it to check if any arrows are equipped that are not your bolts (!= 0 && != BoltID) rather than having to check all specific arrows. Simple.
User avatar
Rachel Eloise Getoutofmyface
 
Posts: 3445
Joined: Mon Oct 09, 2006 5:20 pm

Post » Mon Feb 14, 2011 12:35 pm

Thanks everyone, the knowledge of the forumers fails to disappoint once again.

Quick question though, how do I get OBSE script commands to save in CS as CS tells me they are unrecognized (I have OBSE).
User avatar
stephanie eastwood
 
Posts: 3526
Joined: Thu Jun 08, 2006 1:25 pm

Post » Mon Feb 14, 2011 4:36 pm

Quick question though, how do I get OBSE script commands to save in CS as CS tells me they are unrecognized (I have OBSE).

You need to launch the CS via OBSE, just like launching the game, but with the -editor switch. I launch everything from Wrye Bash, with the OBSE box checked, which is even easier. Also very convenient if you have to esmify/espify dependent mods a lot.
User avatar
Steve Smith
 
Posts: 3540
Joined: Sat Jun 30, 2007 10:47 am

Post » Mon Feb 14, 2011 8:49 pm

You need to launch the CS via OBSE, just like launching the game, but with the -editor switch. I launch everything from Wrye Bash, with the OBSE box checked, which is even easier. Also very convenient if you have to esmify/espify dependent mods a lot.


You can also use http://tesnexus.com/downloads/file.php?id=27672 utility.
User avatar
James Smart
 
Posts: 3362
Joined: Sun Nov 04, 2007 7:49 pm

Post » Mon Feb 14, 2011 8:37 pm

Cheers guys =] Everything's working top bannana now. Now I've just got to work out how to make my custom ammo actually fire and I'll be cooking with gas.. That was just a statement btw I'm not asking for any help with it =D

Okay thanks :foodndrink:
User avatar
Danel
 
Posts: 3417
Joined: Tue Feb 27, 2007 8:35 pm


Return to IV - Oblivion