Jump to content

A few scripting questions


Nadin

Recommended Posts

A:

This is going to sound...odd, but how do I force an object type script to quit once the object has been unequipped?

B:

Is there a way to batch-reference object scripts? As the case in point, I have a script that creates recoil. Instead of adding it to each individual weapon, is there a way I could just have it applied to each without hand-adding it?

Maybe by adding an if/then/else with a form list?

C: Is there a simpler way to add multiple script to an object instead of editing the object's script and tacking on the new script to the end of the old's syntax?

Link to comment
Share on other sites

A: One way is to set up the script so that it only runs while the object is equipped, such as:

if player.getequipped yourobject == 0
  return
else
  ;do stuff
endif

 

B: How exactly are you creating this recoil? Are you editing the weapon records?

 

C: You can only have one script per object. What exactly are you trying to do with the object? There might be some kind of workaround you can use, like using a token or quest script instead.

Link to comment
Share on other sites

Th recoil is based off of a modder's resource. Here's an example for weak recoil:

scn 00RecoilWeak

 

short active

 

begin onequip player

 

set active to 1

 

end

 

begin gamemode

 

if RecoilBool == 0 && active == 1

 

set RecoilConX to 1.0 ; constant angle the gun will kick up.

set RecoilRanX to 1.0 ; random value range for vertical recoil. for example if set to 0.5, the range will be from -0.5 to 0.5.

set RecoilIncX to 0.1 ; how much the global miltiplier increases per shot when firing a automatic weapon. i advise to set the value relatively low, somewhere between 0.05 and 0.02 for example.

set RecoilIncXMax to 2.0 ; the maximal value the incremental multiplier can have.

 

set RecoilConZ to 0.0 ; the same as RecoilConX but to the sides. note that positive values angle to the right and negative left.

set RecoilRanZ to 0.0 ; the same as RecoilRanX but to the sides.

set RecoilIncZ to 0.0 ; again the same as RecoilIncX but to the blah blah blah.

set RecoilIncZMax to 0.0 ; as you guessed it, the same blah blah blah.

 

set RecoilBool to 1

set active to 0

endif

 

end

I suspected the third, but thanks.

 

The script might work, but is there a way to return a type of object rather than a specific object?

Link to comment
Share on other sites

So this script is only for the player? If all those recoil variables are globals then a quest script should work fine, assuming you're using FOSE and assuming the rest of your resource actually does something with these globals. Make a quest, attach your script, and make sure the quest runs fairly often (like every second or less) so you can catch any weapon changes fairly quickly.

 

Instead of the onequip block, you can stick in some code at the beginning of your gamemode block to check if the player equipped a new weapon, and check if the weapon's a gun. If it passes both checks, then set active to 1. Something like this should work:

 

 
short active
ref oldweapon
ref currentweapon

begin gamemode
set currentweapon to player.getequippedobject 5
if currentweapon == oldweapon
  return
else
  if currentweapon
     if currentweapon.getweapontype == ;choose the weapon types you want, refer to FOSE command docs
        set active to 1
     endif
  endif
  set oldweapon to currentweapon
endif

;stick the rest of your script here

end

Link to comment
Share on other sites

  • Recently Browsing   0 members

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