increasing chance of creating monster

Get help using Construct 2

Post » Fri Sep 13, 2013 5:38 am


I have 75 monsters in my game that are randomly created in an area each level
I want to make it so that that level 1 picks from monster 1-2 to create, level 2 picks from monster 1-3 to create, level 3 picks from monster 1-4 to create, level 4 monsters 1-5 and so on through the first 75 levels.
I could create individual events for all this but that would be hundreds of events and seems a little overkill.
I tried playing around with rex's nickname plugin but I'm either getting just monster 1, or all 75 monsters, any help or ideas would be appreciated.
B
6
S
1
Posts: 20
Reputation: 815

Post » Fri Sep 13, 2013 7:55 am

Pretty easy:

- I hope your monsters have an Id or are they a part of an animation ? If you haven just:

Right click on family
Add an instance variable id = 0
Set for every monster the correct id (1-75)

- You need to have your actual level saved in a global variable, if you haven't done this yet just do:

+ On start of Layout
- Set Level to 1-75

+ Every tick //Im not sure how often you spawn them, so change this line how you like
++ family.id = random(1, level)
- spawn family

if you want to spawn all the choosen monsters at the same time do:
+ Every tick
++ for from 1 to level
+++ family.id = loopindex("")
- spawn family

+ = event
++ = subevent
- = actionDarklinki2013-09-13 07:59:17
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Fri Sep 13, 2013 8:12 am

Thanks for the question. Really had to think a bit. Here is another way of doing it without using families. You can use the animation frames and set each frame as a monster. Had fun making this capx for you. If you need your monsters animated then you can select an animation instead, and let the animation run.

https://dl.dropboxusercontent.com/u/79803565/RandomMonsterGenerator.capx

Credit must go to @Yann in this post http://www.scirra.com/forum/random-object-selection_topic47519.html. I was a little stumped and so went looking for help and found the idea there.

Happy creating
B
13
S
4
Posts: 67
Reputation: 1,270

Post » Fri Sep 13, 2013 8:26 am

I also asked him if he uses animation frames, but the most newbies using families instead of animation frames. Cause Animation Frames are better for the performance but they are harder to understand and instances need to be defined over loops.
B
15
S
6
G
6
Posts: 512
Reputation: 5,555

Post » Fri Sep 13, 2013 8:28 am

You had already created a topic on this. http://www.scirra.com/forum/scaled-chance-of-creating-sprite-from-family_topic75745_post452891.html

Anyway here's an example using rexrainbow nickname to create from what I suggested on your earlier topic.

rexrainbow plugin and behaviour:
http://www.scirra.com/forum/plugin-nickname-behavior-nickname_topic57943.html

Example:
https://www.dropbox.com/s/u7bwc93mcu47ity/NicknameSpawnEnemy.capx
B
17
S
8
G
4
Posts: 93
Reputation: 3,190

Post » Fri Sep 13, 2013 10:47 am

Wow, great replies guys...anyway I can give you reputation or thank you?

Going to go with darklinki's solution I think as I aready assigned i'ds 1-75 to the monsters so all I have to do it assign the 'level' global variable to use as the top figure in the random spawn (feel kinda an idiot for not figuring that out myself) I can also assign 'levellower' global so the weaker monster are removed as the game continues.

Thank you all again, so nice to see such active and helpful forum members.
B
6
S
1
Posts: 20
Reputation: 815

Post » Fri Sep 13, 2013 2:53 pm

Inserting levellower sounds very good to remove weaker monster ;)
B
15
S
6
G
6
Posts: 512
Reputation: 5,555


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 31 guests