Difference between revisions of "User talk:RedFault"

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search
imported>RedFault
imported>RedFault
(Adding example)
Line 6: Line 6:
===Are Static Objects Scriptable?===
===Are Static Objects Scriptable?===
:One of my biggest concerns, especially comparing this with the Neverwinter Nights Aurora Toolset, is that it seems there's no way to attach scripts to static world objects.  Am I wrong?  I had a brilliant idea to make an Archery Target script that would really increase your Marksmanship Skill (at a slower rate than in combat), and I wrote a rough script that I thought would get me started, only to discover that the TargetHeavy01 object doesn't have a "Script" field.  Is there a workaround for this?  If so, I think it deserves an entry in this Wiki.  Unless I'm overlooking something obvious, and it's completely possible, and very easy to do.  Being able to script placeable objects is a fundamental ability for good modding.
:One of my biggest concerns, especially comparing this with the Neverwinter Nights Aurora Toolset, is that it seems there's no way to attach scripts to static world objects.  Am I wrong?  I had a brilliant idea to make an Archery Target script that would really increase your Marksmanship Skill (at a slower rate than in combat), and I wrote a rough script that I thought would get me started, only to discover that the TargetHeavy01 object doesn't have a "Script" field.  Is there a workaround for this?  If so, I think it deserves an entry in this Wiki.  Unless I'm overlooking something obvious, and it's completely possible, and very easy to do.  Being able to script placeable objects is a fundamental ability for good modding.
:The script I had started was as follows:
<pre>
  ScriptName ArcheryPractice
  ref ammoRef
  ref shooter
  short distance
  Begin OnTrigger
  Set ammoRef to GetActionRef
    ;When something collides with me, capture the colliding object's
    ;reference so I can check to see if it's an ammo object
  If (ammoRef.IsAmmo == false)
    Return
    ;I have been hit by something other than ammo, don't waste processor
    ;power with the rest of the script
  Endif
  If (ammoRef.IsOwner != 1)
    Message "A shot was fired at an Archery Target by someone other than
            the Player."
      ;This would want to be removed after testing, of course.
    Return
    ;If this works as intended, then the script does not continue to execute
    ;if the shot was not fired by the player.
  Endif
  Set shooter to Player
    ;This should only be possible if the shooter was the Player.  There
    ;is probably a more elegant solution.
  Set distance to GetDistance shooter
    ;Capture the distance between myself and the shooter
  shooter.IncrementPlayerSkillUse Marksmanship 1 1
    ;I don't know how the integers work here.  How much am I increasing?
  Message "You are about %.0f feet from the target." distance
    ;If I'm using this right, it should display the "distance" variable in
    ;an integer format.
  End
</pre>
:Obviously not a finished product, and probably not even correctly written.  I don't know how some of the functions work until I can try them, and since this script was written to be attached to the target itself, I can't test it.  It seems strange to me that you wouldn't be able to interact with something as straightforward as an archery target.  So.  Am I overlooking something, or can static objects really not be scripted?

Revision as of 15:33, 4 January 2008

Well, as I have mentioned on my user page, I am just starting with the TESCS, so I don't have much to discuss as of yet. I just don't like the broken link in my nav menu.

Questions

As I start messing around with the CS, I'm finding a bunch of what I thought would be simple questions, but sometimes finding specific answers to simple questions is not so simple. Here I will ask a few of them, if I think they may be relevant to people other than myself, in the hopes that other noobs can learn something as well.

Are Static Objects Scriptable?

One of my biggest concerns, especially comparing this with the Neverwinter Nights Aurora Toolset, is that it seems there's no way to attach scripts to static world objects. Am I wrong? I had a brilliant idea to make an Archery Target script that would really increase your Marksmanship Skill (at a slower rate than in combat), and I wrote a rough script that I thought would get me started, only to discover that the TargetHeavy01 object doesn't have a "Script" field. Is there a workaround for this? If so, I think it deserves an entry in this Wiki. Unless I'm overlooking something obvious, and it's completely possible, and very easy to do. Being able to script placeable objects is a fundamental ability for good modding.
The script I had started was as follows:
  ScriptName ArcheryPractice
 
  ref ammoRef
  ref shooter
  short distance
 
  Begin OnTrigger
   Set ammoRef to GetActionRef
     ;When something collides with me, capture the colliding object's
     ;reference so I can check to see if it's an ammo object
 
   If (ammoRef.IsAmmo == false)
    Return
     ;I have been hit by something other than ammo, don't waste processor
     ;power with the rest of the script
   Endif
 
   If (ammoRef.IsOwner != 1)
    Message "A shot was fired at an Archery Target by someone other than 
             the Player."
      ;This would want to be removed after testing, of course.
    Return
     ;If this works as intended, then the script does not continue to execute
     ;if the shot was not fired by the player.
   Endif
 
   Set shooter to Player
     ;This should only be possible if the shooter was the Player.  There 
     ;is probably a more elegant solution.
   Set distance to GetDistance shooter
     ;Capture the distance between myself and the shooter
   shooter.IncrementPlayerSkillUse Marksmanship 1 1
     ;I don't know how the integers work here.  How much am I increasing?
   Message "You are about %.0f feet from the target." distance
     ;If I'm using this right, it should display the "distance" variable in 
     ;an integer format.
  End
Obviously not a finished product, and probably not even correctly written. I don't know how some of the functions work until I can try them, and since this script was written to be attached to the target itself, I can't test it. It seems strange to me that you wouldn't be able to interact with something as straightforward as an archery target. So. Am I overlooking something, or can static objects really not be scripted?