Monster spawning help

Not favoritedFavorited Favorited 0 favourites
  • 9 posts
From the Asset Store
Game with complete Source-Code (Construct 3 / .c3p) + HTML5 Exported.
  • Hey,

    I'm trying to figure out a monster spawning method, where on condition the Spawner sprite creates monsters (based on its variables) at one of its specific image points.

    Question is, how could I simplify this with a Monster family and not repeat the event for each monster type...

    Not sure how to pass the moster type to the spawning function... Should I repeat a condition for each Monster there? Or there is a more elegant simplification?

    Thank You!

  • Spawner var can be a string for the name of the monster object then use system 'Create object by name' with value spawner.var

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Unfortunately 'Create object by name' is not available in C2, afaik.

    I've read about Rex's Nickname plugin/behavior, maybe that's a proper substitution to it?

  • Repeat conditions within one spawn function seems fine, based on a monster name parameter sent through. Really it depends on the gameplay design for spawning. What are some examples of variables on a spawner and expectation of what it will spawn?

  • Sorry I was away a while.

    Here is a simplified .capx file, hope it helps:

    drive.google.com/file/d/17KH3PG6vN4y2rbL1DH5RZHOp3g9DSmX5/view

    So Spawners may have 2 triggers: 'collision' or 'remote'.

    When player collides (now it's just a mouseclick in the demo) with a 'collision' spawner, it spawns the 1-7 monsters listed in the spawner's variables, at image points 1-7.

    When player collides with a 'remote' spawner, the 1-7 monsters spawn at the 1-X spawnPoints' coords.

    This works fine now, just trying to figure out a more simple version of this, because i'll have more than 60 different monsters.

    Thanks for help, lemme know if you have further questions...

  • What a blast from the past with these functions. I had a look and I think based on how the spawner is set up and because it's Construct 2 there isn't much you can do. You don't need a function for each monster, you could pass through the spawner.monster variable each time into a single function that has conditions if param(0)="bug" then spawn bug etc and also a second param(1) for the trigger type if collide etc, but without create object by name there isn't a lot you can do to minimize the code beyond this, you would still need a condition for each monster. Construct 2 is really old though, maybe time to upgrade? :)

  • Thank you sir, you helped ruling out the simplification, I can live with some repetition.

    And good suggestion with passing thru variables, maybe I should give a try with Rex Rainbow's Nickname plugin?

    Yes 'create object by name' by C3 would be great, but honestly not a fan of subscription models in general :/

    Thanks again

  • Yes if that plugin is available it does look suitable as a kind of 'create object by name' of the Construct 2 era. With this you may be able to chop it down a lot as you would with create by object, where you send the monster.var through as a parameter and spawn object type 'nickname'.

  • Hey,

    I'm trying to figure out a monster spawning method, where on condition the Spawner sprite creates monsters (based on its variables) at one of its specific image points.

    Question is, how could I simplify this with a Monster family and not repeat the event for each monster type...

    Not sure how to pass the moster type to the spawning function... Should I repeat a condition for each Monster there? Or there is a more elegant simplification?

    Thank You!

    Hi, I'm a little late, but better late than never :D.

    As I understand your problem, you have an indefinite number of monsters that appear randomly within certain parameters, and you want to simplify the process. Well, what I did was create an 8x8 spritesheet with a total of 64 monsters, and I put them all within a single sprite (although you could also use a family). Then I stopped the animation (value 0) and told the mouse that when you click each sprite (SingleMonsterBox), it should spawn a monster sprite and randomly select a frame from within the range of 0 to the total number of frames.

    With the MultiMonsterBox sprite, this is a single sprite with 7 image points. The same thing happens, except here I run a "for" loop with a loop index, telling it to iterate through the maximum number of image points and place a monster sprite at each one.

    I hope this method simplifies things for you and is useful for your project or a future one. Learning new things is always great.

    DEMO:https://demomonsterspawner.netlify.app/

    .CAPX:https://www.mediafire.com/file/7ybyrfqvsh76x85/demomonsterspawner.capx/file

Jump to:
Active Users
There are 0 visitors browsing this topic (0 users and 0 guests)