Page 1 of 2
Create an actor 1 time each actor
Posted:
Tue Apr 17, 2007 5:53 am
by littlekruser
I would like for an actor (tree) to make an actor one time once it gets to a certain wood lvl. How can I do this so it only makes the actor one time?
Posted:
Tue Apr 17, 2007 7:04 am
by Caaz Games
you could use a wait for frame actoin, or if it's multiple actors use a create actor event.
p.s. are you making a game like the ones at
http://www.eyezmaze.com/
Posted:
Tue Apr 17, 2007 10:10 pm
by littlekruser
lol, it's not really like those. It's more of a village sim type of game where the people expand their village and evolve their technology from cavemen to modern day tech. Or at least that's what I'd like to do
lol. But with the trees, I need them to make a baby tree just 1 time for each tree at a random location +/- around their x/y. ne ideas on how to do this? (don't need to know about the random position, just how to make the tree create a new tree one time) also I have the wood going up 1 time each game tick and would like to make the tree when it reaches a certain wood lvl.
Posted:
Wed Apr 18, 2007 1:43 am
by Sgt. Sparky
could you describe that a bit better so I can help you?
Posted:
Wed Apr 18, 2007 3:06 am
by littlekruser
k, so at the beginning of the game it starts out with about 5 trees. Then every game tick the woodlvl var for the tree goes up 1 until it reaches 60 where it maxes out. It also changes animation for the different wood lvls. the wood lvls are pretty much like the trees age, how big it is and how much wood the people will be able to get from it when they chop it down. But once the trees mature to about 40 woodlvl i want that tree to make a new tree, but only one time. ne ideas? I already have everything i need to make the tree at a random x/y location around the old tree, i just need to know how i can do it so that the tree will only make one new tree within its lifetime.
Posted:
Wed Apr 18, 2007 3:15 am
by Sgt. Sparky
make a actor var called X, one called Y,
and one called time,
if woodlvl is allready an actor var or a variable use this code on the draw actor event of the tree,
- Code: Select all
if(woodlvl >= 40 && time == 0)
{
int step;
step = 100;
time = 1;
X = - step;
Y = - step;
X += rand(step*2);
Y += rand(step*2);
CreateActor("tree", "icon", "(none)", "(none)", X, Y, false);
}
to make the distance greater all you need to do is make step a larger number at the start of the code.
I hope that helps.
Posted:
Wed Apr 18, 2007 4:30 am
by Sgt. Sparky
Here is a tree generator I made,
it does what it sounds like...
generates trees.
it just puts some more use of the rand function and generates more trees when the trees are full grown.
Posted:
Wed Apr 18, 2007 5:43 am
by littlekruser
hey man, thanks a lot! I really appreciate it.
Posted:
Wed Apr 18, 2007 6:30 am
by littlekruser
alright, new problem lol. how can I make it so that it creates a new actor with a wood lvl of 0? cause with that code, it makes an actor with the same wood lvl as the other trees.
Posted:
Wed Apr 18, 2007 3:34 pm
by Sgt. Sparky
if the woodlvl is an actor variable use this script on the create actor event:
- Code: Select all
woodlvl = 0;
Posted:
Fri Apr 20, 2007 9:49 pm
by littlekruser
Then it changes all of the tree's wood lvl to 0. Do you know how I can make variables that are each independent of the other actors of the same type?
Posted:
Fri Apr 20, 2007 10:19 pm
by pixelpoop
when you create a variable using the GE menu the default is a Global Integer. You need to change it to an Actor variable Integer.
Posted:
Fri Apr 20, 2007 11:59 pm
by Sgt. Sparky
I allready told em' to make it an actor variable.
(second time you've got here before I did.
)
Posted:
Sat Apr 21, 2007 6:51 am
by littlekruser
lol, my bad. thnx though.
Posted:
Sat Apr 21, 2007 4:40 pm
by Sgt. Sparky
you're welcome.