Thacker Posted February 22, 2011 Share Posted February 22, 2011 Hello all, I was curious if I could get some help with a script for those who know more than I. The intent is to make a script that gives a chance for you to fall over when you have a crippled leg. Here is the code: scn JTCrippledLimbsKnockDown Begin GameMode If Player.HasMagicEffect MorphineEffect == 1 EndIf ElseIf player.getav LeftMobilityCondition == 0 || player.getav RightMobilityCondition == 0 If GetRandomPercent <= 5 player.pushactoraway player 3 EndIf EndIf ElseIf player.getav LeftMobilityCondition == 0 && player.getav RightMobilityCondition == 0 If GetRandomPercent <= 10 player.pushactoraway player 3 EndIf EndIf End The intent is to have it ignore the script if you are under the effects of Morphine (in modded it to include the "ignore crippled limbs" effect). If you have your left or right leg crippled you have an X% chance to be knocked down; both legs crippled and the chance goes up to Y%. After lots of work, I finally got the GECK to let me save this script, so at least on face value, it should be good. However after trying a debug version of it (exchanged the knockdown effect for a message effect), I couldn't get any response. My thought is I shouldn't have it listed as an Object script, though from my understanding Object scripts could apply to the player/actor. Alternatively I could be missing something completely obvious but just don't know it. Any input would be greatly appreciated, thanks! Link to comment Share on other sites More sharing options...
davidlallen Posted February 22, 2011 Share Posted February 22, 2011 I am a little surprised this script compiles, because it has several extra endif's. I suggest you read about the scripting language at cipscis.com. Here is a version which seems more correct, but I did not test: Begin GameMode If Player.HasMagicEffect MorphineEffect == 0 If (player.getav LeftMobilityCondition == 0) || (player.getav RightMobilityCondition == 0) If GetRandomPercent <= 5 player.pushactoraway player 3 EndIf ElseIf (player.getav LeftMobilityCondition == 0) && (player.getav RightMobilityCondition == 0) If GetRandomPercent <= 10 i player.pushactoraway player 3 EndIf EndIf Endif end Also, you did not say what object this is attached to. If you want it always running, you may have to make it a quest script. Link to comment Share on other sites More sharing options...
Thacker Posted February 22, 2011 Author Share Posted February 22, 2011 I appreciate the quick response. It's funny you mention the extra "endif"s cause I couldn't get the damn thing to compile without including them (lot of trial an error there). I'm heading off to bed shortly, so not sure if I'll have a chance to test it tonight, but wanted to thank you for the effort. Are the explanations at cipscis.com worthwhile? I've been wanting to learn more about the scripting language, but haven't had the time/energy to do it until this latest modding attempt. The explanation of the "Object" script at the GECK wiki made it sound like (at least to me) that the "object" could be an actor (in this case the player). Not sure if that's doable or not. Though ideally I'd like this to apply to all actors, so not sure how I'd have to change it to do that. Link to comment Share on other sites More sharing options...
davidlallen Posted February 22, 2011 Share Posted February 22, 2011 Cipscis tutorials are good for non-programmers, so you should start there. You should install geck powerup to see syntax errors; "saves or doesn't save" is not very helpful when learning about scripting. Applying this to all actors, from all weapons, may be challenging; I recommend to get it working for the player first. Probably you have thought of this, but it will be easier to test if the percent chance is 100%. Link to comment Share on other sites More sharing options...
Thacker Posted February 22, 2011 Author Share Posted February 22, 2011 I did not now of this "GECK Powerup", I'll have to grab that. Really seems to be a hindsight to have lost that innate error checking going from FO3 to NV. Getting it to work on the player is the first step indeed, I was more thinking out loud when I commented on applying to actors. The values listed are really just place holders for now. Since my GECK abilities are so limited, I generally have been including some obscene value in my work as debug to make sure the mechanics are working. As an aside, the "Begin GameMode" is described in the wiki as "running every frame". Are these "frames" related to the games actual displayed FPS (which would seem odd) or are the frames the referencing some other unit? Link to comment Share on other sites More sharing options...
davidlallen Posted February 22, 2011 Share Posted February 22, 2011 As an aside, the "Begin GameMode" is described in the wiki as "running every frame". Are these "frames" related to the games actual displayed FPS (which would seem odd) or are the frames the referencing some other unit?No, it is the same type of frame. This is key to understanding how scripts work. A gamemode script is executed 60 times per second. If you have a lot of different ones, it will use up a lot of CPU time. It is better, when possible, to write scripts that trigger only on certain events, such as "onhit" or "onadd". Link to comment Share on other sites More sharing options...
Thacker Posted February 22, 2011 Author Share Posted February 22, 2011 Huh, interesting. So is it hardcoded to run at 60fps? What if your actual game frames are lower (say 30) does it run at that or still at 60? Apologies for the rapid fire questions :( Link to comment Share on other sites More sharing options...
davidlallen Posted February 22, 2011 Share Posted February 22, 2011 The script executes once for each graphical frame drawn, regardless of what your fps is. Link to comment Share on other sites More sharing options...
Glowcat Posted February 22, 2011 Share Posted February 22, 2011 As an aside, the "Begin GameMode" is described in the wiki as "running every frame". Are these "frames" related to the games actual displayed FPS (which would seem odd) or are the frames the referencing some other unit?No, it is the same type of frame. This is key to understanding how scripts work. A gamemode script is executed 60 times per second. If you have a lot of different ones, it will use up a lot of CPU time. It is better, when possible, to write scripts that trigger only on certain events, such as "onhit" or "onadd". Are you sure about the GameMode script itself being executed 60 times per second? I was under the impression that Quest scripts were limited to how quickly the quest was set to update. I'd like to know more about what you mean by that. @Thacker: It might seem odd but it makes sense if you understand how a game's main loop works with the rendering process. Link to comment Share on other sites More sharing options...
Cipscis Posted February 22, 2011 Share Posted February 22, 2011 @Glowcat:You're correct that GameMode blocks in quest scripts will not necessarily run every frame, although they will for effect and object scripts. By default, quest scripts are processed once every 5 seconds (specified in the ini file), although this can be overridden on a quest-by-quest basis. By specifying a very small number, such as 0.01, you can all but guarantee a GameMode block will be executed every frame, but this is rarely a necessity. I think I remember someone mentioning that quest scripts with delay times shorter than the time between frames could be executed multiple times per frame, but I haven't confirmed this. @ThackerAs I mentioned above, GameMode blocks will run every frame in which the script is processed, which will cause them to run less frequently at lower framerates. If you want to keep something steady with respect to time, I recommend you use GetSecondsPassed to keep track of the time passed between frames. Even with the indispensable GECK PowerUp, the GECK's compiler will still miss certain errors such as extra endif statements. It might be a good idea for you to run your scripts through my script validator until you get more accustomed to the syntax, as it will detect a few errors the the GECK's compiler may miss, as well as other potential issues. Cipscis Link to comment Share on other sites More sharing options...
Recommended Posts