Random loot drops

Get help using Construct 2

Post » Wed Aug 28, 2013 8:57 pm

Hi all! First post from a newbie here and really hoping you can help.

I've tried doing this myself but don't seem to be making headway. I try to do as much as I can before bothering anyone else but this really has me stuck.

I have 2 Families:
1) Monsters
2) Loot

Goal:
When a Monster dies, it creates Loot from a "loot table". Different Monsters will create different loot and some loot will be rarer than others.

Of course, I could do it like this (in pseudo code):

ON DEATH: Goblin
IF Random = 1-10 ----> loot: gold (1-5)
          = 11-15 ----> loot: gold (5-10)
          = 16-17 -----> loot: dagger
          = 18 ----> loot: potion
ON DEATH: Orc
IF Random = 1-5 ----> loot: gold (5-10)
          = 6-10 ----> loot: sword
          = 11-15 -----> loot: armor
          = 16-20 ----> loot: shield

But as you can see, with a lot of Monster and Loot types, the event list will get really long!
B
13
S
3
Posts: 17
Reputation: 984

Post » Wed Aug 28, 2013 9:08 pm

Just use a function:

ON DEATH: call function "functionLoot"

And inside FUNCTIONLOOT run the random numbers
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Post » Wed Aug 28, 2013 10:18 pm

Hi ghost, thanks for the reply!

Wouldn't that function have the same problem of not having a loot table though? I mean, the loot should be different for each Monster type e.g. an Orc will not have the same loot as a goblin. It's my fault for not clarifying that. I hope this clarifies things a bit:

Example:
Possible Loot:
1) Gold
2) Dagger
3) Boots
4) Pelt
5) Potion

Thus Monster types like the orc and goblin can choose from any of the list but a Wolf Monster can't have daggers or potions. The chances for getting a particular item will also differ whereas my understanding is doing it through a function like you suggested will have similar results and I will end up with all Monsters being able to give all kinds of loot (such as a wolf giving a dagger) with the same chances regardless of monster type.
B
13
S
3
Posts: 17
Reputation: 984

Post » Wed Aug 28, 2013 11:19 pm

I don't see a problem here, what do you need help with? Just keep the functions tidy and all is good!
B
45
S
15
G
73
Posts: 2,008
Reputation: 43,398

Post » Wed Aug 28, 2013 11:52 pm

@Plinkie

If I have 20 different Monsters who can spawn different Loot combos, won't I eventually have a very long event list? Would seem to be quite redundant too.

Thanks for taking the time to reply! :)
B
13
S
3
Posts: 17
Reputation: 984

Post » Thu Aug 29, 2013 12:02 am

If Goblin dies set Goblin_Died to true > Run rand

Function rand
> If rand = 1-10 > Function Loot_Common
> If rand = 11-15 > Function Loot_Rare
> If rand = 16-17 > Function Loot_VeryRare
> If rand = 18 > Function Loot_ UltraRare

Function Loot_Common
> If Goblin_Died OR
> If Orc_Died > Spawn Gold
> If ???

Function Loot_Rare
> If Goblin_Died > Spawn Gold
> If Orc_Died > Spawn Sword
> If ???

Function Loot_VeryRare
> If Goblin_Died > Spawn Dagger
> If Orc_Died > Spawn Armor
> If ???

lots of ways..plinkie2013-08-29 00:11:20
B
45
S
15
G
73
Posts: 2,008
Reputation: 43,398

Post » Thu Aug 29, 2013 12:37 am

Or put instance variables in a family that contains all the monsters.
each monster would have it's ranges, and the function could read the list off the family.

(unless you are using the free version, which doesn't have families.)
B
226
S
60
G
33
Posts: 902
Reputation: 39,989

Post » Thu Aug 29, 2013 12:59 am

@Plinkie

I will try that but it really seems to me that will still give me a very long list of events. The examples I gave are very basic and simple but the aim is many more Monster and Loot types.

@Paradox

Can you give pseudo code examples for that? I do have instance variables in the families. The way I have it now is something like:

Monster family with instance var LootMin and LootMax
Loot Family with Instance var LootType (e.g. Gold is type 1, dagger is 2, etc)

I'm aiming for (but not getting ):

If Monster with instance vars: LootMin 1 and LootMax 4 dies
> set "bootyVar" to random between LootMin and LootMax
> create Loot with LootType "bootyVar"
Norbingel2013-08-29 01:03:56
B
13
S
3
Posts: 17
Reputation: 984

Post » Thu Aug 29, 2013 1:06 am

Couldn't you use an array to hold the list?
B
72
S
25
G
9
Posts: 383
Reputation: 10,661

Post » Thu Aug 29, 2013 4:43 am

[QUOTE=Norbingel] Hi ghost, thanks for the reply!

Wouldn't that function have the same problem of not having a loot table though? I mean, the loot should be different for each Monster type e.g. an Orc will not have the same loot as a goblin. It's my fault for not clarifying that. I hope this clarifies things a bit:

Example:
Possible Loot:
1) Gold
2) Dagger
3) Boots
4) Pelt
5) Potion

Thus Monster types like the orc and goblin can choose from any of the list but a Wolf Monster can't have daggers or potions. The chances for getting a particular item will also differ whereas my understanding is doing it through a function like you suggested will have similar results and I will end up with all Monsters being able to give all kinds of loot (such as a wolf giving a dagger) with the same chances regardless of monster type.[/QUOTE] remember than functions can pass parameters, (you could pass parameter "monsterType" for example)
B
12
S
3
G
1
Posts: 347
Reputation: 2,866

Next

Return to How do I....?

Who is online

Users browsing this forum: vegapomme27, Yahoo [Bot] and 9 guests