Jump to content

Script help


senterpat

Recommended Posts

Thanks, that's exactly what I needed. My script compiles, but it doesn't work in game. If anyone can help me out I'd greatly appreciate it.


 

 

 

ScriptName PatProneScript
 
begin gamemode
 
short isProne
 
short oldscale
 
if iskeypressed 56 == 1 && isprone != 1 && player.issneaking == 1
 
	set oldscale to player.getscale
 
	set isprone to 1
 
	disableplayercontrols 0 0 0 1
 
	player.setscale .2
 
	player.addperk patproneperk
 
endif
 
if iskeypressed 56 == 1 && isprone == 1
 
	enableplayercontrols
 
	player.setscale oldscale
 
	player.removeperk patproneperk
 
	endif
 
if isprone == 1 && player.issneaking != 
1
 
set isprone to 0
 
endif
 
end
 
Link to comment
Share on other sites

ScriptName PatProneScript
 
short isProne
short oldscale

begin gamemode
 
if iskeypressed 56 && isprone != 1 && player.issneaking
 
    set oldscale to player.getscale

    player.setscale .2
 
    player.addperk patproneperk

    disableplayercontrols 0 0 0 1

    set isprone to 1
 
endif
 
if iskeypressed 56 && isprone == 1

    player.setscale oldscale
 
    player.removeperk patproneperk
 
    enableplayercontrols 0 0 0 1
 
    endif
 
if isprone == 1 && player.issneaking != 1
 
set isprone to 0
 
endif
 
end
 

Variables should be ALWAYS set first in a script.

 

So the variable 'short isprone' has to be previous to the gamemode block.

 

If something is still not working, please write what happens instead.

Edited by nonplusultra
Link to comment
Share on other sites

It's not working, nothing happens. The perk and setscale are simple enough, so I think the problem is in IsKeyPressed, I'm not sure it's the right command. I've been at this for awhile, I appreciate the help.

 

The perk just lowers move speed, improve gun spread and sneak. I'm using a quest to get it into the game, tho I may be doing it wrong.

Edited by senterpat
Link to comment
Share on other sites

ScriptName PatProneScript
 
short isProne
short oldscale

begin gamemode
 
if isprone != 1 && (iskeypressed 51) && player.issneaking
 
    set oldscale to player.getscale

    player.setscale .2
 
    player.addperk patproneperk

    disableplayercontrols 0 0 0 1

    set isprone to 1
 
endif
 
if isprone == 1 && (iskeypressed 51)

    player.setscale oldscale
 
    player.removeperk patproneperk
 
    enableplayercontrols 0 0 0 1
 
    endif
 
if isprone == 1 && player.issneaking == 0
 
set isprone to 0
 
endif

end
 
 

 

Try this one out, 51 is the comma button.

Normally everything looks fine, even the iskeypressed command.

NVSE should be installed, otherwise you would get an error when saving.

 

Where do you use the script, in an actor, activator or quest?

 

If you are using it in a quest, you have to set the questdelay down, with the command: 'setquestdelay 0.1', but NOT in the quest itself, the setquestdelay command has to be used in an other quest or activator.

 

If the default quest delay is marked, the game will just update the frames every (5 secs?), so you have to hit the button exactly in that time, almost unpossible if not spamming the button.

 

So if you are using it in a quest, set the quest delay down!

 

Link to comment
Share on other sites

I'm using it in a quest at the moment, but am not sure if that is the best way. Or if I have it set up right. Is there a better way to attach it to the player? It's supposed to simulate going prone. I'll try that out after work tomorrow, but need to get some sleep for now. Thanks again for all your help.

Link to comment
Share on other sites

You should do two quests, one quest to set the delay for the other and the second for the main script.

 

The script of the first quest should look like:

 

 

scn MySetUpQuestSCRIPT

short setonce

begin GameMode

if setonce == 0
setquestdelay MyMainQuest 0.1
set MyMainQuest.Stage to 1
set setonce to 1
endif

end
 

The quest can have the default delay and the Start Game Enabled should be checked.

 

Now the main quest:

 

 

ScriptName PatProneScript
 
short isProne
short oldscale
short stage

begin gamemode

if stage == 1
StopQuest MySetUpQuest
set stage to 2
endif
 
if isprone != 1 && stage == 2 && (iskeypressed 51) && player.issneaking
 
    set oldscale to player.getscale

    player.setscale .2
 
    player.addperk patproneperk

    disableplayercontrols 0 0 0 1

    set isprone to 1
 
endif
 
if isprone == 1 && stage == 2 && (iskeypressed 51)

    player.setscale oldscale
 
    player.removeperk patproneperk
 
    enableplayercontrols 0 0 0 1
 
    endif
 
if isprone == 1 && stage == 2 && player.issneaking == 0
 
set isprone to 0
 
endif

end
 

 

So all you need is one more quest, the first small script and the problem should be solved.

Link to comment
Share on other sites

I get an error when compiling it, it says line 9 (set patProneQuest.Stage to 10)

it says unknown variable "stage"

 

edit: I got it to compile by changing it to (setstage patProneQuest 10), not sure if that will work but I'm going to test it now.

 

editx2: It's still not working :( It has to be something I'm doing wrong. I have both quests start game enabled, the setup quest has a stage, the prone quest has two stages, the priority on both is 100. I didn't change anything other than that info. What am I missing?

Edited by senterpat
Link to comment
Share on other sites

No, setstage is setting the quest stages you can read in your pipboy, 'set patProneQuest.Stage to 10' < this one is correct, did you also copy the second script?

 

First copy the main script and then the first script, if you do it the wrong way round the short variable 'stage' is not set, so the first script will show an error.

 

Instead of 'Stage' you can also use doonce or whatever, it's just a variable and has nothing to do with the setstage.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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