View unanswered posts | View active topics It is currently Sat Dec 15, 2018 3:45 pm



Reply to topic  [ 4 posts ] 
 Spawn Ratios (and other, lesser questions for the lua savvy) 
Author Message
User avatar

Joined: Sat Sep 08, 2012 2:57 pm
Posts: 28
Reply with quote
Post Spawn Ratios (and other, lesser questions for the lua savvy)
Hello! This is a relatively simple question that I have no idea how to phrase. Is there any way to get a specific actor (or groups of actors) to be created, as a rare event? See what I'm trying to do is get a non-zombified group of AHumans to spawn randomly amidst the zombie horde in my Braindead scenario.

If you answered that with relative ease, please try your hand at the following:
1.) Is it possible to make it so that, in the Harvester activity, you have to leave in a craft after mining enough gold to win?
2.) For Braindead, is it possible to take away direct player control from the friendlies? Like, they don't attack you, but you can't control them?
3.) Also for Braindead, can I make it so the mission ends if a certain friendly dies?

For each question that's answered thoroughly, I will give that person seven Persian dollars worth of internet hugs.


Sun Nov 04, 2012 3:30 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 657
Location: Halifax, Canada
Reply with quote
Post Re: Spawn Ratios (and other, lesser questions for the lua savvy)
Hoo boy, this turned out pretty lengthy, hope it answers everything okay.
math.random or RangeRand would be what you want. I'd suggest setting up a timer with a pretty long interval and after that timer has hit its interval, do something like:
Code:
if math.random() < 0.25 then
   self:SpawnStuff etc.
end

math.random by default goes from 0 to 1 (though I don't think it can actually be zero) so 0.25 would be a quarter chance. You can also just use the math.random by itself and check if it's < something a lot lower or greater than something a lot higher (remember 1 is max). For what it's worth, RangeRand is similar to math.random except that when you put in arguments for math.random to set a max and min, it will only give integers, where RangeRand will always give numbers with decimals (and I think it always needs to have arguments put in, though I'm not 100% sure of this).

Next:
1) Look at maginot mission for how to do this, or look at many of the shield missions. If you need a more full explanation don't hesitate to ask, but it's relatively lengthy and I'm sure you can figure it out with examples.

2) Yes, there are a few ways to do this depending on what you want. The easiest one is to simply switch back to the actor you want to keep controlled when it's not controlled like so:
Code:
if not self.DesiredActor:IsPlayerControlled() then
   for player = 0, self.PlayerCount - 1 do
      self:SwitchToActor(self.DesiredActor, player, self.PlayerTeam);
   end
end
self.DesiredActor and self.PlayerTeam need to be defined ahead of time of course.
You can also keep the player from scrolling away at all (i.e. holding down q or e and looking around) with
Code:
for player = 0, self.PlayerCount - 1 do
   SceneMan:SetScrollTarget(self.DesiredActor.Pos, 0.02, true, player);
end
The second argument is the speed it scrolls at, 1 being instantly, which is unimportant here. The third checks for scenewrapping I think.
I can't remember the other way to do this off the top of my head, but you should be able to simply make it so the other actors don't have the selection circle at all, and the wouldn't show up at all as a selectable actor when holding q or e. I can look into it if you want (and should for my own knowledge either way).

3. Here you go:
Code:
if not MovableMan:IsActor(self.DesiredActor) or self.DesiredActor.Health == 0 then
      if self.ActivityState ~= Activity.OVER then
         self.WinnerTeam = self.PlayerTeam;
         ActivityMan:EndActivity();
         AudioMan:StopAll();
         for player = 0, self.PlayerCount - 1 do
            self.braindead[player] = true;
         end
      end
   end


Sun Nov 04, 2012 4:23 am
Profile
User avatar

Joined: Sat Sep 08, 2012 2:57 pm
Posts: 28
Reply with quote
Post Re: Spawn Ratios (and other, lesser questions for the lua savvy)
Bad Boy wrote:
If you need a more full explanation don't hesitate to ask, but it's relatively lengthy and I'm sure you can figure it out with examples.

Well I do have several questions, but I'll save the ones about Evac for later. Mostly, I need to know where to place these things. I got one of them to run without any errors, but it's just the fact that it's not working. I tried defining self.DesiredActor pretty early on and placing the lose conditions for 3 under the default ones but it didn't work when the desired actor died.

Aside from that, I have no idea where to start. I tried multiple places for each "answer" and each time it created an error. And for the Evac, I tried taking a look at those missions, but they're all heavily scripted and use FightStages that make them hard to understand and apply "triggers" to. Still, dude, thanks for being so helpful and putting up with what I'm sure are my "noob-ish" questions.


Mon Nov 05, 2012 2:35 am
Profile

Joined: Fri Sep 10, 2010 1:48 am
Posts: 657
Location: Halifax, Canada
Reply with quote
Post Re: Spawn Ratios (and other, lesser questions for the lua savvy)
Anywhere in the update function or in a function called by the update. With the losing one for example, if you put it in the normal victory/loss function, you'll have the problem that it's only called when that function is called, i.e. when the brain dies, so it's pointless.

In general I think what you need is more experience experimenting with making missions, and that's not something that's easy to teach. If you haven't already, you should try weegee's mission tutorials (at least 1 - 4) since they're probably the best way to start. Other than that I found that the best way to learn is to piece together bits from other missions until you know how it all works well enough to not have to (and even then, it's usually more convenient to just copy paste from stuff you've already made). That said, you may not learn well that way, I don't know. There are tutorials for lua in general online that you can find to familiarize yourself with the language. And feel free to pm any specific questions since it's ultimately kind of hard to answer something so general.

Keep at it though, in a little while it'll come pretty naturally to you :)


Mon Nov 05, 2012 3:43 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Baidu [Spider]


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.019s | 18 Queries | GZIP : Off ]