Jump to content

Two Scripting Problems


Abramul

Recommended Posts

First script: GoneLoadingMessage

Intended purpose: Open a MessageBox when a new cell is loaded, since load times can be...excessive.

Used On: Ring, included in player's inventory (in finished version, I'll probably put it on the prison table)

Why it's on the ring: It seems like it would be impolite to add a script to the player.

Alternate Method: Trigger when an Autosave is created. There doesn't seem to be a function of this sort.

 

ScriptName GoneLoadingMessage

begin OnLoad

MessageBox "Cell has loaded."

end

 

Second script: GauntletH2H

Intended Purpose: Boost Hand to Hand skill when any character is wearing gauntlets.

Used On: All vanilla gauntlets

Alternate Method: Place script on a token, trigger when player equips or unequips gauntlets, and use GetEOV instead of GetOV

ScriptName GauntletH2H
short GauntletAR
begin OnEquip
set GauntletAR to GetObjectvalue 150;  GauntletAR is now set to the gauntlet's Armor Rating
if(GauntletAR==0)
return
elseif(GauntletAR>0)
AddSpell H2HGauntL1
elseif(GauntletAR<=200)
AddSpell H2HGauntL2
elseif(GauntletAR<=300)
AddSpell H2HGauntL3
elseif(GauntletAR<=500)
AddSpell H2HGauntL4
elseif(GauntletAR<=750)
AddSpell H2HGauntL5
endif
end 

begin OnUnequip
RemoveSpell H2HGauntL1
RemoveSpell H2HGauntL2
RemoveSpell H2HGauntL3
RemoveSpell H2HGauntL4
RemoveSpell H2HGauntL5
end

Link to comment
Share on other sites

Question about the first script... What purpose does this message serve? The reason why that specific block doesn't want to work is because it triggers when the object that it is attached to gets loaded. Since this is on a ring, this block doesn't get triggered until the ring is dropped in the world, or it loads with a cell that it was placed in. Without knowing what purpose this message serves (other than constantly telling the player when they change areas (even though they would probably already know this from the dozens of other cues)) I can't really help you figure out another way of doing this.

 

As for the second script, you might be better off attaching a script to an ability, then giving that ability to the player. This way the script will constantly run and check for equipment changes. The problem with this is that without using OBSE, you can't really do this in any way which works well. The main reason why your current script doesn't work is because it uses the function "GetObjectvalue" and this doesn't work without OBSE, even with OBSE, you would need to detect what was worn first, then get the objectvalue for that reference. Something like:

Scn Gauntleth2hscript

ref wgauntlets
short gauntletar
short effectactive
short doonce

Begin scripteffectupdate
if wgauntlets != player.getequippedobject 4
set wgauntlets to player.getequippedobject 4
set gauntletar to wgauntlets.getobjectvalue 150
set doonce to 1
else 
set doonce to 0
endif
if doonce != 0
if(GauntletAR==0)
set effectactive to 2
elseif(GauntletAR>0)
AddSpell H2HGauntL1;need to replace these with form IDs
set effectactive to 1
elseif(GauntletAR<=200)
AddSpell H2HGauntL2;need to replace these with form IDs
set effectactive to 1
elseif(GauntletAR<=300)
AddSpell H2HGauntL3;need to replace these with form IDs
set effectactive to 1
elseif(GauntletAR<=500)
AddSpell H2HGauntL4;need to replace these with form IDs
set effectactive to 1
elseif(GauntletAR<=750)
AddSpell H2HGauntL5;need to replace these with form IDs
set effectactive to 1
endif
set doonce to 0
endif

if effectactive == 2 && doonce == 1
RemoveSpell H2HGauntL1;need to replace these with form IDs
RemoveSpell H2HGauntL2;need to replace these with form IDs
RemoveSpell H2HGauntL3;need to replace these with form IDs
RemoveSpell H2HGauntL4;need to replace these with form IDs
RemoveSpell H2HGauntL5;need to replace these with form IDs
set effectactive to 0 
endif
end

 

Should do it, but it requires having OBSE loaded as a masterfile. Anyone using this mod would also need OBSE to use it. As noted, you also need to replace the spell names with the form IDs (string of 8 characters, 0-F (hexidecimal)). Without OBSE, you're have to have the script checking for each individual gauntlet to see if it is worn, then adding a spell based on this. The problem with that is that it becomes rather long and complicated, making the whole thing not work so well.

Link to comment
Share on other sites

For the first one, the intent is to stop time once the cell is loaded. Shouldn't OnLoad work on an article of clothing, provided its model shows on the player?

 

For the second, I AM running OBSE, although it isn't a plugin, but rather a program that launches the CS or Oblivion. According to the Wiki, using the spell ID is fine.

 

GetEquippedObjectValue is a combination of GetEquippedObject and GetObjectValue.

 

Described Here

GetEquippedObjectValue

From The Elder Scrolls Construction Set Wiki

 

A command for Oblivion Script Extender

 

Syntax:

 

GetEquippedObjectvalue ValueType SlotID

GetEOV Valuetype SlotID

 

Returns the requested value for the object in the specified slot of the calling reference. Returns 0 if the value type doesn't match (asking a weapon for an armor rating or clothing for a health value)

 

Going to add a test message to make sure the script is actually executing when I equip gauntlets.

Link to comment
Share on other sites

Nope, onload only runs when the object is first loaded, or when it has been cleared from memory, then loaded again. The entire blocktype might not even work on anything that isn't a persistant reference. Instead what you might want to do is make a quest script that always runs, and use something like

ScriptName GoneLoadingMessage

ref currentcell

begin gamemode

if currentcell != player.getparentcell
set currentcell to player.getparentcell
MessageBox "Cell has loaded."

end

 

Should return a message every time the player changes cells. The nice part is that you don't need to attach it to any piece of equipment, and could control it all through other scripting functions.

 

Even if the Wiki claims that spell IDs are fine, you should just get into the habit of using the form IDs for everything. It becomes harder for errors to occur due to two things being named the same, and since you have to use it everywhere else, you might as well use it here too.

 

As for GetEquippedObjectValue While yes, that does combine them, I went with the way I did because it seemed to be more processor friendly as it only updates when equipment changes, so will update less frequently. If using GetEquippedObjectValue any time the AR changed due to durbility being lowered, the script would have to detect what the new AR is, and then make the changes accordingly. Now since this can happen 20+ times in a minute, and usually when you're being attacked, this didn't seem to be the most player friendly solution.

 

The problem with attaching this script to a piece of equipment is because onequip/onunequip only runs once, when the object the script is attached to gets worn or taken off. It doesn't update at any other time. This means that the detections for the gauntlets will only occur when that token in equiped, if you remove the gauntlets while that token is still equiped, there is no check, so the effect wil remain. Within an ability, you can have the script constantly checking for a change in equipment, so that once they're removed, the additional bonus that goes with those gauntlets also gets removed.

Link to comment
Share on other sites

A problem with Vagrant0's method is that it would also happen everytime you go between cells on the worldmap, which would get very anoying after a while. I can't think of anything that would work that wouldn't do this (other than using Vagrant0's method with the GetWorldSpace function, which doesn't exsit). But that's me, someone else may think of something.

 

Omegano

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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