Enemies dropping items/powerups
butterbean
Member Posts: 4,315
Has anyone already done this on their game? If so, can you explain how you did yours?
I was wondering for my situation, what would be the best way to implement this:
So I have random enemies flying from the top of the screen to the bottom... when they reach the bottom, I have the destroy behavior, so they don't reappear at the top again and keep cycling. And my player is at the bottom of the screen shooting the enemies above... if the player misses them, they are destroyed once they reach Y axis below zero.
I was originally going to create a global game attribute called "I am enemy number" and keep track of how many enemies were destroyed, and drop items randomly according to how many enemies were destroyed (a percentage of items)
The problem with this is that I have the destroy behavior when the enemies reach the bottom screen, so that is being accounted into the equation, and items are being dropped on the floor once the enemies are destroyed.
I only want items to drop according to how many enemies are destroyed by myself
Could I implement this based on score? Like everytime the score reaches 5,000 points, 10,000 points, an item drops?
Just trying to figure out the easiest way to implement this, if anyone has done this, I appreciate your help
I was wondering for my situation, what would be the best way to implement this:
So I have random enemies flying from the top of the screen to the bottom... when they reach the bottom, I have the destroy behavior, so they don't reappear at the top again and keep cycling. And my player is at the bottom of the screen shooting the enemies above... if the player misses them, they are destroyed once they reach Y axis below zero.
I was originally going to create a global game attribute called "I am enemy number" and keep track of how many enemies were destroyed, and drop items randomly according to how many enemies were destroyed (a percentage of items)
The problem with this is that I have the destroy behavior when the enemies reach the bottom screen, so that is being accounted into the equation, and items are being dropped on the floor once the enemies are destroyed.
I only want items to drop according to how many enemies are destroyed by myself
Could I implement this based on score? Like everytime the score reaches 5,000 points, 10,000 points, an item drops?
Just trying to figure out the easiest way to implement this, if anyone has done this, I appreciate your help
Comments
or as jgary said. see whats best for your game, but both ways would work.
the "advantage" about using the score, is that you already have that working. so you will only use a attribute that already exists to spawn the items.
when enemy kills = Random(1,25) spawn powerup
change attribute enemy kills = 0
This should work in theory, it may need a bit of tweakin. I'm not at home to try it, but this way it would be random. This would spawn the powerup & then randomly pick a new number & spawn again after those kills. Lemme know if this works (if you try it) Again it may need to be tweaked.
So I could create a global game attribute, "enemy kills" as integer
Should I then place a rule under the main actor that kills the enemies, that for every kill, it's +1
Then create another rule, when enemy kills= Random (1,25) spawn powerup- or just play with the numbers
If I put Random (1,25), what percentage of enemies will drop items? Does that mean between 1 and 25 enemy kills, that an item will drop?
And then by putting a change attribute to enemy kills=0 after item drops, is that resetting the count for enemy kills so it starts over again at random?
Thanks guys!
Also I must stress this is only some guidelines, you may need another rule or 2 to make it work. Try it & lemme know what happens. I can help if it needs tweaking.
Also, I tried creating a rule, and said when enemy kills = number, it won't let me insert a random (n,n) function, do I need to use a different attribute to do this?
Make sure to hit the "e" (for expression editor) then click arrow for drop down. Then under insert function. is random.
I went under the powerup item itself, and tried to create the rule like you said, when any conditions are valid, an attribute changes: Game.Enemykils equals:( number,number random) It only allows me to put one number or variable in there... there isn't a checkbox that allows you to enter : Random (n,n) I even tried manually entering it, but it erases the info.
So how would I go about doing this? Do I create this rule somewhere else? Let me know if you figure out a way, in the meantime I'm going to keep trying different things
I know it is simple, I'm just not seeing it!
I think there's another way of doing it, and it's to create 3 attributes, (codemonkey helped me with this)
Create 3 game attributes:
Spawn X, Spawn Y, and RandomDrop, Spawn X and Spawn Y are of Real attributes, and RandomDrop is of integer I believe
Under the destroy behavior for the enemy:
Put in these rules
Change attribute: Game.Spawn X to self position X
Change attribute: Game.Spawn Y to self position y
Change attribute: Game.randomdrop to Random (n,100) where N can be used for the percentage of drops
Then you could expand the rule by creating this:
These rules could be added into the spawn weapon behavior:
> Rule 1.1: If 'RandomDrop' is greater than 0 and less than 11 (2 conditions)
-> -> Change Attribute: 'game.RandomDrop' to 0.
-> Rule 1.2: If 'RandomDrop' is greater than 10 and less than 21
-> -> Spawn Actor: '9mm' at position 'game.SpawnX' and 'game.SpawnY' relative to scene.
-> -> Change Attribute: 'game.RandomDrop' to 0.
Well I did all this, and it worked, (courtesy of Codemonkey), but do you have to reset an attribute if an item does in fact drop? Or does this keep cycling?
In other words, do I need a respawn weapon or powerup rule?
I think after all this, I may just release weapons or powerups on a timer, which would be much easier, require less rules, and works for me, but we shall see