View unanswered posts | View active topics It is currently Thu Dec 12, 2024 9:32 pm



Reply to topic  [ 12 posts ] 
 Setting actor activities 
Author Message
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Sat May 09, 2009 4:27 am
Profile YIM
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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.


Sat May 09, 2009 4:51 am
Profile WWW
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Sat May 09, 2009 4:50 pm
Profile YIM
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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?


Sat May 09, 2009 5:13 pm
Profile WWW
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Sat May 09, 2009 6:14 pm
Profile YIM
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post 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


Sat May 09, 2009 6:18 pm
Profile WWW
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Sat May 09, 2009 7:53 pm
Profile YIM
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post 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


Sat May 09, 2009 8:44 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post 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.


Sat May 09, 2009 9:16 pm
Profile YIM
User avatar

Joined: Mon Jun 30, 2008 9:13 pm
Posts: 499
Location: Finland
Reply with quote
Post Re: Setting actor activities
Hey, it's supposed to be actor.AIMode, not actor.ActivityState. Duh, why didn't I notice that.


Sat May 09, 2009 9:20 pm
Profile
User avatar

Joined: Mon Jul 16, 2007 9:50 am
Posts: 1512
Location: Tallahassee, FL
Reply with quote
Post Re: Setting actor activities
Excellent, that worked.


Sat May 09, 2009 10:23 pm
Profile YIM
DRL Developer
DRL Developer
User avatar

Joined: Wed Dec 13, 2006 5:27 am
Posts: 3138
Location: A little south and a lot west of Moscow
Reply with quote
Post Re: Setting actor activities
Boy do I feel stupid now. Sorry about that.


Sat May 09, 2009 11:19 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 12 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.028s | 15 Queries | GZIP : Off ]