Guest Messenjah Posted June 10, 2011 Share Posted June 10, 2011 Ok, since my last topic kind-of vanished off the map, I figured I better start a new one. Yes, I am still continuing my efforts to overcome the wall I am trying to climb my way over and it is a very large wall at that. Basically, I'm trying to understand how to get the AI packages to work properly. I have been working almost non-stop when I have time but I do have to take time off for school, work, and family, not to mention I managed to overwrite my lighting scripts by accident so I had to re-write them and yes, they are now all working correctly and flawlessly again. Anyway, moving on. My goal is to get 3-4 dancers to rotate shifts on a pole. I have a pole set up as a furniture with custom animations linked to it. I have re-written how the animations are attached and the issue has been discovered to not be the pole itself. However, the pole does have an alignment issue that has yet to be resolved. However, I need to get all basic functionality of the AI scripts and packages working first before I work all the rest of the little kinks out. So, what the issue is at current is that the first dancer will lock onto the pole and will exit correctly at this point, but it seems so far that if I link 4 different npcs to the pole via script and AI packages, that nothing happens. If I just link them to the pole nothing happens. I've also had the issue of the first dancer interacting but never leaving the pole for some strange reason. It seems that any way I try to link all the dancers together in one script or just give them all AI packages, they will all stop working or one dancer will go up and use the pole but won't stop animating. I do know that evp, evaluates the package and that resetAI will reset the AI. It also seems that if you check the continue with PC near, will cause the AI to not leave the pole animation as well. My latest attempt that I will try to fully test sometime tomorrow night, is to write a quest script and link it to a custom quest. The first script is a bunch of variables that I have set as conditions for my AI packages. The first script looks like so: scn WEDanceSCRIPT short TreasureShowStart short TreasureShowEnd Short and sweet but I will be adding the other variables later. A second script is then written to call on those variables in order to set a conditions to the variables called upon and then use the variables in the AI packages. This script is attached to the npc. scn WETreasureSCRIPT begin gamemode ;******Treasure On Stage********** if GameHour >= 14 && GameHour <= 18 set WEDancers.TreasureShowEnd to 0 set WEDancers.TreasureShowStart to 1 evp elseif GameHour < 14 && GameHour > 18 set WEDancers.TreasureShowEnd to 1 set WEDancers.TreasureShowStart to 0 evp endif end It works so far with one dancer npc but it seems that there is a new bug. The evp seems to be looping over and over again as the npc will stutter while walking and then just simply stare at the pole. I need the npc to evaluate the package when it is time to leave so that they will start the next AI package but I need them to do this in a way that doesn't keep looping. Any ideas or suggestions? Link to comment Share on other sites More sharing options...
Skevitj Posted June 10, 2011 Share Posted June 10, 2011 (edited) Your current script (the last one posted) will carry out it's contents every frame, so that evp is being called every frame, hence the stuttering. You only want evp to call once when the "switching boundary" occurs. The easiest way to do this is to use a state variable, ie, The actual implementation would be almost identical to the lighting sequence script with one block determining the state and changing it if need be, and another which carries out the functions for that state if the state has changed. On that note, did you get the lights switching between spot and time to work? Edited June 10, 2011 by Skevitj Link to comment Share on other sites More sharing options...
Guest Messenjah Posted June 10, 2011 Share Posted June 10, 2011 To be honest, that script example you wrote, really confused me. Reading it several times and being inexperienced just caused me to understand the timer scripts a lot less. I worked around it, using the other guy's script logic and it worked out, especially since everything was triggered via GameHour. :) Perhaps you could explain it a bit better? I understand that my evp is checking over and over. I just want to know how to use DoOnce to stop it. Now, I know what floats are, and short and long, variables, references, ecs are but what is int? IE: int iDoOnce From what I could see with your old timerscript, you were overriding the first event, then doing something with iDoOnce by telling it that if it is at 0 to set it to 1? Then telling the script to count to 120 before the first event would start, then subtracting 120 from the timer to take it back to zero? Perhaps if I can understand what you did with iDoOnce, I could figure out how to go about fixing this script? I'm really hoping that once I fix this bug, she will complete the dance and check the next package, while the next dancer with a similar script will use the same type of variables to dance. If not, then I will assume that multiple NPC's can not be assigned to the same furniture or animation marker? Maybe it is because I have all of their packages for the furniture item set to Must Complete so the game sets all of them at the same priority so they are having an argument over who completes it first? BTW: For quick reference to my lighting thread:http://www.thenexusforums.com/index.php?/topic/392899-need-help-scripting-and-ai-packages-continued/ Also, I'm looking at addscriptpackage and removescriptpackage. Are these adding/removing a script or a normal AI package? If they refer to a normal AI package, I could possibly use this to tell them directly which package I want them to use at what GameHour? Link to comment Share on other sites More sharing options...
Skevitj Posted June 11, 2011 Share Posted June 11, 2011 I think you're confusing me with the other guy who was helping you (Well I hope anyway, would be impressed if my explanations are capable of reducing someone's understanding of a topic). I didn't use DoOnce blocks as I integrated them directly into the logic I used. Lighting Topic since your link just heads back here. scn ... short OldState short StateVar begin gamemode if (GameHour>=14)&&(GameHour<=18)&&(StateVar!=1) set StateVar to 1 elseif ((GameHour<14)||(GameHour>18))&&(StateVar!=2) set StateVar to 2 endif if StateVar==OldState return endif if StateVar==1 set WEDancers.TreasureShowEnd to 0 set WEDancers.TreasureShowStart to 1 evp elseif StateVar==2 set WEDancers.TreasureShowEnd to 1 set WEDancers.TreasureShowStart to 0 evp endif set OldState to StateVar end The condition for the second if test is wrong and will never activate, as a number can't be simultaneously above 18 and less than 14. Changing the and (&&) to an or (||) will fix that. That's most probably why it looks to you like only one can use it, since the first one will never receive the "stop command". This is your final script using the same logic as for the lighting timer. Just like the lights it can be extended to add/remove anything at any time. For questions about variables, or pretty much anything else the GECK Wiki has you covered. AI isn't my strong point, but I've got a feeling you shouldn't be using evp, but instead be adding and removing the AI packages from the npcs directly, using the AddScriptPackage and related remove. Link to comment Share on other sites More sharing options...
stevie70 Posted June 11, 2011 Share Posted June 11, 2011 would be impressed if my explanations are capable of reducing someone's understanding of a topic). i'd SO hire you, there's loads of stuff i'd need un-explained... :-)=) Link to comment Share on other sites More sharing options...
Guest Messenjah Posted June 11, 2011 Share Posted June 11, 2011 Yeah, I had you two confused hehe. I was getting ready for work when I wrote that and very tired. It's hard for me to script right now. I get a maximum of 2-3 hours of sleep a week. I'm doing an internship for my Information Technology college course, working, and taking care of my wife along with modding right now. :) But this Summer will be the best and easiest time to work on my project. I agree that addscriptpackage is probably a good way to go but a lot of people recommend evp as it just checks the packages for the correct conditions to be set. BTW, I use GECK wiki frequently. I just need some better clarification at times on how to use the information on the wiki. :) Link to comment Share on other sites More sharing options...
stevie70 Posted June 11, 2011 Share Posted June 11, 2011 I do know that evp, evaluates the package and that resetAI will reset the AI. It also seems that if you check the continue with PC near, will cause the AI to not leave the pole animation as well.if 'continue with pc near' is checked, the package won't end as long as the player is near, but as soon as he's gone, it will. anyhow, you shouldn't use this if you ever want a package to change while the pc is standing by.and from what i understand, resetai shouldn't be used for package changes, because it resets all ai in the cell, not only one actors (somebody please correct me if i'm wrong about that). this might as well be a reason why it doesn't work with 4 dancers (if they run a package making them go to the pole and you resetai, they'd drop that package (if what i wrote about resetai above is correct that is)) another theory about why it don't work with 4 dancers: if you, at the same time, move dancer D1 from and dancer D2 to the pole, maybe D2 kind of considers the pole still occupied because D1 hasn't moved away from it yet (that's really nothing more than blind guessing though), so have you tried to first move D1 to, well, anywhere else, and don't tell D2 to go to the pole before D1 has arrived there? Link to comment Share on other sites More sharing options...
Skevitj Posted June 12, 2011 Share Posted June 12, 2011 (edited) another theory about why it don't work with 4 dancers: if you, at the same time, move dancer D1 from and dancer D2 to the pole, maybe D2 kind of considers the pole still occupied because D1 hasn't moved away from it yet (that's really nothing more than blind guessing though), so have you tried to first move D1 to, well, anywhere else, and don't tell D2 to go to the pole before D1 has arrived there?That was going to be my second guess. Since you're getting them to play an animation at the pole, the AI package will end before the pole becomes unoccupied, maybe killing the AI package on the second. Although I'm reasonably sure it won't matter unless #2 reaches the pole before the animation for #1 is finished. Ok, after a quick brush up on AI: evp should actually be fine for your purposes. If you give each dancer 2 AI packages, an Idle one and the dancer one, and have the condition that "StateVar==X" for each dance package, where X starts at 1 for the first dancer, 2 for the 2nd etc. That would allow you to use only the first section of the script I wrote, assuming it is attached to the custom quest you have. The rest of the script would just simplify to:if OldState!=StateVar evp set OldState to StateVar endif Basically: Because it would be a quest script the variables would be available externally... All that's obvious, but it makes it very easy to control the individual dancers as you just need to link each dancer's AI dance package to a value of StateVar using a single "Conditions" statement in the AI package. The Idle package for the dancers (when they're not dancing) doesn't need any conditions, as long as it is below the Dancer one as it should be selected by default if the dancer condition fails. If that doesn't work however it's a simple matter to add "StateVar!=X" as a condition to ensure the two are mutually exclusive. EDIT: Why I would put a return statement 1 line above where the script would naturally terminate we'll never know... /facepalm. Cheers for indirectly pointing out an error in the script. Edited June 12, 2011 by Skevitj Link to comment Share on other sites More sharing options...
stevie70 Posted June 12, 2011 Share Posted June 12, 2011 if OldState!=StateVar evp set OldState to StateVar else return endifuhm, just a stupid question, what's that "return" you're both using...? Link to comment Share on other sites More sharing options...
tunaisafish Posted June 12, 2011 Share Posted June 12, 2011 'return' exits the script - no more commands are run until next time, where it would start at the top again. Link to comment Share on other sites More sharing options...
Recommended Posts