Data Realms Fan Forums http://868000.nnhp.asia/ |
|
Setting actor activities http://868000.nnhp.asia/viewtopic.php?f=73&t=14556 |
Page 1 of 1 |
Author: | Darlos9D [ Sat May 09, 2009 4:27 am ] |
Post subject: | Setting actor activities |
Seems like it should be something simple to do, but I can't seem to find the proper functions. Problem: I just want to make a simple lua-controlled scene where I can test stuff, yet all actors I spawn start off in patrol mode, when I want them in sentry mode. Its kinda hard to test things when my actors run each other over as soon as I get done with the build phase. More specifically, I want to set all my actors to sentry mode when the main play phase begins, but not anymore after the first time. |
Author: | TheLastBanana [ Sat May 09, 2009 4:51 am ] |
Post subject: | Re: Setting actor activities |
Just put this in your StartActivity function: Code: self.StartTimer = Timer(); self.ActivitySet = false; And then this in the UpdateActivity function: Code: if self.StartTimer:IsPastSimMS(10) and self.ActivitySet == false then for actor in MovableMan.Actors do actor.ActivityState = Actor.AIMODE_SENTRY; end end The reason it goes in the UpdateActivity function is that when the StartActivity function runs, none or only few of the actors have spawned yet, so it skips the rest. This way, it waits a few milliseconds first. |
Author: | Darlos9D [ Sat May 09, 2009 4:50 pm ] |
Post subject: | Re: Setting actor activities |
So what is self.ActivitySet == false for? You check it but never do anything to it, so when does it change to true in order to keep the if statement from triggering later on? Oh, and also, this doesn't seem to be working... they still start in patrol mode. |
Author: | TheLastBanana [ Sat May 09, 2009 5:13 pm ] |
Post subject: | Re: Setting actor activities |
Oops, forgot to switch that off afterward. Try this. Code: if self.StartTimer:IsPastSimMS(100) and self.ActivitySet == false then for actor in MovableMan.Actors do actor.ActivityState = Actor.AIMODE_SENTRY; self.ActivitySet = true; end end ActivitySet tells the script to stop changing their activity mode after it's done it once. And I switched the milliseconds to 100, maybe that was the problem? |
Author: | Darlos9D [ Sat May 09, 2009 6:14 pm ] |
Post subject: | Re: Setting actor activities |
Here's a problem: I have it starting in edit mode, but I think the timer starts at the beginning of edit mode. By the time I leave edit mode (or even set down the first actor) the timer has probably already finished. I need the timer to start once edit mode is over. Had I a decent API to look at I could probably figure it out myself, but the wiki has little to no info. |
Author: | TheLastBanana [ Sat May 09, 2009 6:18 pm ] |
Post subject: | Re: Setting actor activities |
That is most definitely the problem. Here's your code then. StartActivity: Code: self.ActivitySet = false; UpdateActivity: Code: if self.ActivityState ~= Actvity.EDITING and self.ActivitySet == false then self.ActivitySet = true; for actor in MovableMan.Actors do actor.ActivityState = Actor.AIMODE_SENTRY; end end |
Author: | Darlos9D [ Sat May 09, 2009 7:53 pm ] |
Post subject: | Re: Setting actor activities |
So I guess ~= is like != in most other languages. And here I was hoping to find out what the constant for the regular gameplay mode is called... This still isn't working. Now, it seems to be finding all of the actors right after editing finishes fine, since I threw in an actor:GibThis() and everything immediately exploded upon starting regular gameplay. It seems like actor.ActivityState = Actor.AIMODE_SENTRY isn't working right. |
Author: | piipu [ Sat May 09, 2009 8:44 pm ] |
Post subject: | Re: Setting actor activities |
Code: self.ActivitySet = false; UpdateActivity: Code: if self.ActivityState ~= Activity.EDITING and self.ActivitySet == false then self.ActivitySet = true; for actor in MovableMan.Actors do actor.ActivityState = Actor.AIMODE_SENTRY; end end There was an i missing from Activity.EDITING |
Author: | Darlos9D [ Sat May 09, 2009 9:16 pm ] |
Post subject: | Re: Setting actor activities |
No, thats not it, I typed it in by hand anyway, I didn't copy and paste. Like I said, everything works fine except for actor.ActivityState = Actor.AIMODE_SENTRY. The actors clearly aren't being set to sentry mode, even though that line is being reached in the code. And a quick FYI: I have a degree in computer science. You don't have to assume I'm clueless as far as minor errors go. Like I said, I'd be doing this all myself easily if I had access to a decent API for CC Lua scripting. |
Author: | piipu [ Sat May 09, 2009 9:20 pm ] |
Post subject: | Re: Setting actor activities |
Hey, it's supposed to be actor.AIMode, not actor.ActivityState. Duh, why didn't I notice that. |
Author: | Darlos9D [ Sat May 09, 2009 10:23 pm ] |
Post subject: | Re: Setting actor activities |
Excellent, that worked. |
Author: | TheLastBanana [ Sat May 09, 2009 11:19 pm ] |
Post subject: | Re: Setting actor activities |
Boy do I feel stupid now. Sorry about that. |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |