senterpat Posted June 21, 2012 Share Posted June 21, 2012 (edited) I wrote this script, an attempt to make a "random" encounter, I did copy the base of the script from a perk effect script, and I still don't understand what the "short rv" does. Anyways when I go into game to try this out, it doesn't work (I set it up to try and make it a sure thing that they'd spawn with the below script) no npcs spawn. Can someone help me figure out this randompercent or point me to a good script to look at, or a tutorial. script type: effect Scn myscript Short rv Begin gamemode If player.isinterior == 0Set rv to getrandompercentEndif If rv>0Player.placeatme (npc name) 1Elseif rv<=0 Player.placeatme (npc name) 1EndifEnd Edited June 21, 2012 by senterpat Link to comment Share on other sites More sharing options...
senterpat Posted June 21, 2012 Author Share Posted June 21, 2012 (edited) From what I can make out "rv" means whatever the script writer wants it to, which sets it to become a random number in this script. Can someone confirm this, I looked at the geck page about declaring variables, but don't really understand it. I'm also wondering if there is something I can put in that mean do nothing, i.e. :If rv>0(do nothing) Edited June 21, 2012 by senterpat Link to comment Share on other sites More sharing options...
pluramon Posted June 21, 2012 Share Posted June 21, 2012 (edited) In 'Effect' type scripts, you should only use ScriptEffectStart / ScriptEffectUpdate / ScriptEffectFinish block types.By what way are you calling this script? A token? An equipped item? I would suggest you create a 'dummy' quest to call the script. Something like: script type: Quest Scn myscript Short rv short doonce Begin gamemode if (doonce == 0) && (player.isinterior == 0) set doonce to 1 // you'd have to reset this if you wish the encounter to happen more than once Set rv to getrandompercent If rv > 0 Player.placeatme (npc name) 1 elseif rv <= 0 Player.placeatme (npc name) 1 Endif Endif End Edited June 21, 2012 by pluramon Link to comment Share on other sites More sharing options...
senterpat Posted June 22, 2012 Author Share Posted June 22, 2012 (edited) Thanks, I'll try that out once I get home, I do want it to happen more than once, so how would I reset the doonce? Rest of script EndifReset doonce End? Edited June 22, 2012 by senterpat Link to comment Share on other sites More sharing options...
Cyberlazy Posted June 22, 2012 Share Posted June 22, 2012 set doonce to 0 also, 'Short rv' declares a local variable, named rv, of type 'short' (-32,000 to +32,000 or so). Without that, trying to access RV just gives an error as geck would not know what you mean by rv, Or it would, if geck gave errors. Link to comment Share on other sites More sharing options...
senterpat Posted June 22, 2012 Author Share Posted June 22, 2012 Awesome, that script worked perfectly and taught me some stuff I didnt know. Kudos to both of you. I do have a couple other questions I could fun out about with trial and error, but if you have the time it'd save me some hours. 1. Is there a limit to how many times you can use && to add additional conditions?2. If two mods have a script on an object I.e. both have a script on a magazine, would that be a serious conflict, or would it be resolved in the load order?3. I'm currently using (player.additem f 0) to tell the script "do nothing" is there a better command to use for that? Will this affect performance?Thanks again for all yalls help. Link to comment Share on other sites More sharing options...
Cyberlazy Posted June 22, 2012 Share Posted June 22, 2012 1) No, Only the limit of 32,000 characters in a scripts source.2) No, it would be a minor conflict, the last loaded mod would have its script attached to the misc item while the other mod would be overridden. This would likey just make whatever feature the other mod had not work, your game will still likey run fine. 3) ... Why are you telling a script to 'do nothing'? One would assume that.. nothing would work just as well. You can also just return from a script early... Link to comment Share on other sites More sharing options...
senterpat Posted June 23, 2012 Author Share Posted June 23, 2012 (edited) I need to tell the script to do nothing when I use random percent, I.e.:Scn myscript Short rnd Begin gamemode Set rnd to getrandompercent If rnd > 1(do nothing)if rnd <= 1Player.placeatme stuff 1 Is leaving the space empty optional? I assumed that the geck needed a function after stating a condition. Edit: o I think I see what your saying, just don't use the rnd>1 line at all. Which I should have figured out sooner. Anyways, thanks a lot for all your help. Edited June 23, 2012 by senterpat Link to comment Share on other sites More sharing options...
Cyberlazy Posted June 23, 2012 Share Posted June 23, 2012 (edited) Yea, you don't need the if > 1also, you need endif after an if if rnd <= 1Player.placeatme stuff 1endif Also note get random precent returns 0 to 99 so that only has a 2% chance at passing. Edited June 23, 2012 by Cyberlazy Link to comment Share on other sites More sharing options...
senterpat Posted June 23, 2012 Author Share Posted June 23, 2012 Ya I have the script working, I just didn't bother to add Endif or end right there. Ya I needed it to be a low percent as it spawns a random encounter, So I want it to be a pretty rare occurrence. Link to comment Share on other sites More sharing options...
Recommended Posts