Jump to content

Basic Scripting Help


talion

Recommended Posts

Hello everyone. I recently released a weapon mod both here and at Planet Elder Scrolls. While reading the comments on both sites, a post at PES made me realize that for a vanilla game, the weapons, which are equivalent to the Daedric Longsword in power, are very easy to get for a low level character. Rather than nerfing the sword, I decided to challenge myself by finding a way to make the swords inaccessible at lower levels. A quick check of the leveled lists suggested that Daedric weapons will appear around level 20, so I successfully added a condition to the conversation that each NPC has that will result in the player getting the weapon one way or the other. The condition makes it so the NPC has to be level 22 or 23 (with player level offsets I defined of the NPCs, this will mean the player has to be level 20) before they will start this conversation.

 

My next step is the make the NPCs essential and make a script so they lose the essential tag once the player is level 20 (again, making the NPC 22 or 23, depending on the NPC). This is to keep players from simply killing the NPCs for their swords since they can't start the conversation. The following is my script so far:

 

ScripName ARGSwordBearer01Script

 

Begin GameMode

if (01000CF0.GetLevel >= 22)

SetEssential 01000CF0 0

endif

End

 

When I try to save this script, I get the error message:

 

Script 'ARGSwordBearer01Script', line 4:

Non-persistent reference 'CF0' cannot be used in a script.

 

With this, I thought maybe it's because I'm using the base NPC ID rather than the ID of the NPC reference in the game world. However when I replace it with that, I get the error:

 

Script 'ARGSwordBearer01Script', line 5:

Invalid actor base "0003103D' for parameter Actor Base.

Compiled script not saved!

 

Since the error is on line 5, I thought that maybe I was correct to use the reference ID in the if condition and then must need the base id for the statement, but when I do that, I get:

 

Script 'ARG SwordBearer01Script', line 7:

Unknown referenced object 'D'.

 

So, if anyone out there can help me figure this out, it would be greatly appreciated. Thanks in advance!

Link to comment
Share on other sites

Just a quick update. I figured out what I was doing wrong to get the errors that I was getting. What I thought was the reference ID for my NPC was actually the ID for the cell I placed the NPC in. Now the script saves with no errors. I added the script to the NPC, but when I test it in game, the NPC never becomes essential. I tried marking the NPC essentail in the NPC's window first, then I tried addiing a line to the script that should make the NPC essential if it's below level 22, but neither method works. Posted below is my new script:

 

ScriptName ARGSwordBearer01Script

 

Begin GameMode

if (0100485A.GetLevel < 22)

SetEssential 01000CF0 1

endif

if (0100485A.GetLevel >= 22)

SetEssential 01000CF0 0

endif

End

Link to comment
Share on other sites

Owk, is it necessarily to put that script on the sword? Cause that would go wrong if the player would have like 100 swords..

Cause every script is saved on the player, (I was told)

Cause if you placed it on the npc nothing would go wrong...

And is there a particular reason why you don't check the players level?

 

Something like this would suffice then (placed on the npc)

 

ScripName ARGSwordBearer01Script

 

short done

 

Begin GameMode

if done == 0

if (GetLevel >= 22)

SetEssential 0

set done to 1

endif

endif

End

 

Or

ScripName ARGSwordBearer01Script

 

short done

 

Begin GameMode

if done == 0

if (Player.GetLevel >= 20)

SetEssential 0

set done to 1

endif

endif

End

Link to comment
Share on other sites

Thanks for the reply. The script was intended to be placed on the NPC, not the sword. The reason why I had it set to check the NPC level as opposed to the player's level is because I was unable to find a command to have it check the character's level, but was able to find one to check NPC level.

 

I'll keep the script you came up with handy, as I'm sure I'll have a use for it in the future, but I actually came back here to say that I found a simpler solution that didn't require the write out a full script. I simply added the line setessential (Form ID) 0 to each topic of the NPC's dialogue that would result in combat or in the NPC giving the player the sword. This way, the NPC loses its essential tag right before combat begins or if the player talks the NPC out of the sword, since I don't see where it would be necessary to keep the NPC essential afterward. Thanks for your help.

Link to comment
Share on other sites

Set essential works on the base actor, not the reference. Meaning that in order to call it you either need to specify a base within the script, or attach the script to the base.

 

Attaching scripts to items you give to NPCs is generally not suggested since these scripts are never removed from memory, and can create bloating if that NPC is used repeatedly, or is respawned.

Link to comment
Share on other sites

The script was added to the NPC, Vagrant0.

 

Here's a tip Talion. When you put an object into Cyrodill and you want to have scripts use that object, add a word into the referenceID box instead of using the hexadecimal ID added next to that box. I have heard that that ID can sometimes get duplicated, swapped or lost under different circumstances. This leaves your script with nothing to use.

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...