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

0 favourites
  • 8 posts
From the Asset Store
Perfect, complete, easy to use to use, out-of-the-box inventory system
  • 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?

  • 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:

    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[/code:2yzyitwm]
    
    I hope you'll understand my vision of this.
  • 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.

  • 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?

  • I would be interested in seeing this example if you could.

  • So would I!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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!

  • Wonderful! Thanks so much for that.

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