Can I giv monster loot to highest dmg player in multiplayer?

Get help using Construct 2

Post » Wed Mar 04, 2015 6:43 am

This is gameplay that would be simple in a single-player context; you kill a monster, the monster drops loot, you pick up the loot.

In multiplayer, it's tougher if you want only the highest-damage-dealing player to get the loot. My best guess is that the monster object needs to create an instance variable for every player connected, which increases when that player damages it; when the monster dies, it compares all such variables, selects the player associated with the highest number, and then when that player interacts with the corpse of the monster they get the loot.

...is that possible with the C2 multiplayer object? If so, how?
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Wed Mar 04, 2015 9:55 am

Maybe it will be more efficiently to make it like this

Monster has 2 instances:
1) RecievedDmg = 0 (default)
3) PlayersName = "" (default)

Now let's simulate the situation:

Code: Select all
1. Player Deals damage DMG
2. If (DMG > Monster.Received DMG) then
   2.1 Monster.ReceivedDmg = DMG
   2.2 Monster.PlayersName = Player.Name
3. If (Monster.Health < 0) then
   3.1 Pick Player by comparison [Player.Name == Monster.PlayersName]
   3.2 Give loot to picked Player


I hope you'll understand my vision of this.
B
8
S
1
Posts: 72
Reputation: 606

Post » Wed Mar 04, 2015 2:45 pm

Nick, that's a very interesting solution! The only issue is that it measures who's scored the biggest hit, not who did the most damage overall. But it does have the major virtue of elegance!

If storing the damage of each player is difficult, here's a solution that could work well, perhaps: a slight modification of your plan so that if a player hits and he's already the 'top damager', the new damage he's done is added to his total, creating a progressively higher 'bar' for other players to clear. This would even work well to discourage kill-stealing, and should be possible to do with an easy additional comparison of name variables! Exciting, thanks.
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Wed Mar 04, 2015 3:15 pm

well, I missed that moment about overall damage..
the problem is that you can't create object instance variables through runtime, just modify existing ones

maybe you need to create a special array for this? store player's names (only those who deal a damage) and a damage they dealt (add with every hit).

you can use array indexes according to monster UID, it will guarantee their uniqueness and creates a simple link between monter instance and array data.

need an example?
Last edited by NickRimer on Fri Mar 06, 2015 9:46 am, edited 1 time in total.
B
8
S
1
Posts: 72
Reputation: 606

Post » Wed Mar 04, 2015 4:46 pm

I would be interested in seeing this example if you could.
I must not fear. Fear is the mind killer.
B
10
S
1
G
1
Posts: 22
Reputation: 966

Post » Thu Mar 05, 2015 12:08 am

So would I! :)
B
6
S
1
G
1
Posts: 91
Reputation: 900

Post » Thu Mar 05, 2015 12:14 pm

Hello men!
This is your capx-source.
I hope that it will be easy for you to understand all its mechanics.

There are some comments inside, but if you want more - write me a personal message or post your questions right here! I'll give you all support on my capx-source.

Attached image shows array structure.
X-axis means monsters, Y-axis means heroes. Each index is a proper instance of monster/hero.
Value on (X,Y) coordinates means == hero with (IID = Y) deal Value damage to monster with (IID = X)

After monster death we search for maximum Value in a column with number equal to this monster IID.
Y coordinate of this Value will be IID of hero who dealt max damage.

Enjoy!
You do not have the required permissions to view the files attached to this post.
B
8
S
1
Posts: 72
Reputation: 606

Post » Thu Mar 05, 2015 4:16 pm

Wonderful! Thanks so much for that. :)
B
6
S
1
G
1
Posts: 91
Reputation: 900


Return to How do I....?

Who is online

Users browsing this forum: s3eKn, SoldjahBoy, Zjahel0001 and 10 guests