Please use "code
" or "codebox
" tags when posting scripts, as this conserves indentation and causes them to be shown in a fixed-width font. Since you say you have some experience with VB
I'm sure you know how to indent your scripts, but just in case you're not entirely sure here is a utility that can do it for you, as well as check for several structural errors - Script Validator
Changing "speedmult" will not affect the player until you change their equipment (and you can't reasonably do that in a script without FOSE).
While it's true that changing "SpeedMult
" is more problematic than making changes to other AV
s, it is still feasible without FOSE
. As far as I know, these are the events that will cause an actor's speed to be recalculated:
- Drawing or holstering a weapon
- Toggling sneak mode
- Any changes to one of the two mobility AVs: "LeftMobilityCondition" and "RightMobilityCondition"
Given that drawing or holstering a weapon can cause a recalculation of an actor's speed, and that AV
should be changed whenever this event occurs, extra code may not be required.
Does the GECK have an If __ and __ statement? Nested If statements are fugly :|
You can use a logical AND for this via the "&&
" operator. However, whenever possible it is best to use nested conditions in Fallout 3 script for efficiency reasons. Conditions in Fallout 3 scripts are not very well optimised, so if the first part in a condition utilising a logical AND evaluates to false, the rest of the condition will still be evaluated. Because of this, nested conditional statements are more efficient. However, when using more complicated blocks of conditional statements (i.e. those utilising "else
" statements) use of the "&&
" operator may be unavoidable.
At the moment, because you're using a OnEquip
block, your script will only run once
whenever the weapon is equipped by an actor. Instead, you'll want to use three blocks:
- An OnEquip block to set the value of a variable that stores information on whether or not the weapon is equipped
- An OnUnequip block to reset the value of the same variable
- A GameMode block to run code that depends on conditions such as whether or not the weapon is drawn
In Fallout 3 scripts, variables should be declared at the the top of the script, outside of any Begin/End blocks, so you'll want to move your declaration of the "Math
" variable on line 18 to the top of the script with your other variable declarations. It's also worth noting that, when checking boolean values such as the return value of IsWeaponOut
, the "== 1
" is unnecessary and actually makes the script less efficient. It is also more efficient to use the following structure in the place of "== 0
else; if <condition> == 0
It's also worth noting that when dealing with exactly opposite conditions, "else
" statements should be used instead of "elseif
" statements. For example, the second example below is more efficient than the first:
elseif <condition> == 0
I'm not sure if you can ensure that there will only ever be one instance of this weapon, and that only the player will ever be able to equip it, then you don't need to worry about this, but otherwise there are a few changes that you should make. Basically, you should generalise most of the script by using a "ref
" variable to store the return value of GetContainer
so that the functions that you call will be applied to the actor that has equipped the weapon. If you do this, then you'll obviously want to make a few changes so that the same code doesn't run on the player as on NPC
s. Basically you'll want to change the speed handling so that the speed of the game only changes when the player equips the weapon, and the ImageSpace Modifier will only be applied if the player equips the weapon.
Sorry if I've made any typos or if this post is difficult to follow. I've been watching a movie while I wrote it so there might be a few instances of qwertial aphasia
mixed in there.