Results 1 to 8 of 8
  1. #1
    Mister_Raccoon's Avatar
    Join Date
    Jul 2016
    Gender
    male
    Posts
    42
    Reputation
    22
    Thanks
    16
    My Mood
    Amused

    ((NR Core)) Need a RIG for new seasonal events

    ^thread title^

    I'm sure I can handle the "Player.UseItem.cs" and "Activate Effect" portion of it but I need help with the guts of this thing.
    Basically a consumable that generates a random item from it's own pool of loot that I can use for my upcoming xmas events. Bonus if some items are rarer than others in the same box.

    The one we had with FSoD source literally gave an equal shot at any item in it's pool. If we can make some of them more rare than others, that'd be swell. Otherwise don't sweat it.

    Any help appreciated. Thanks much in advance.

  2. #2
    Riigged's Avatar
    Join Date
    Jan 2013
    Gender
    male
    Location
    no
    Posts
    3,846
    Reputation
    401
    Thanks
    10,254
    My Mood
    Devilish
    you want different chance percentages of each possible reward which sadly this method does not support but there are ways to force it in, like dissecting it into 2 functions, one containing the shit items, and one containing the good items, and wherever you call those 2 functions have it roll a number 1-100 for example, if its 1-10 then it calls the function containing the good items, but 11-100 then it calls the function with shit items :3

    this is the most noob way to do it, but its simple and easy to read/edit/add to by anyone, also its just the Random method so yeah you definitely already know about it if you code regularly, also you said you had a system that does this on your other source anyways so why not just transfer that over? i used this for my Lootboxes in my vault, basically when you reach a goal, you are allowed to use your vaults lootbox, click "Claim" and it runs the RunLootbox function, dropping the item in a bag at your feet (cuz ur in vault thought that would be cool lmao, easy change for sending it to inventory) and then taking away your CanLootbox permissions until you reach your next goal (its not all handled inside the RunLootbox function, obviously, just the item rewarding half of it is)

    Last edited by Riigged; 10-22-2020 at 05:56 AM.

     








  3. The Following User Says Thank You to Riigged For This Useful Post:

    Mister_Raccoon (11-13-2020)

  4. #3
    Mister_Raccoon's Avatar
    Join Date
    Jul 2016
    Gender
    male
    Posts
    42
    Reputation
    22
    Thanks
    16
    My Mood
    Amused
    Quote Originally Posted by Riigged View Post
    you want different chance percentages of each possible reward which sadly this method does not support but there are ways to force it in, like dissecting it into 2 functions, one containing the shit items, and one containing the good items, and wherever you call those 2 functions have it roll a number 1-100 for example, if its 1-10 then it calls the function containing the good items, but 11-100 then it calls the function with shit items :3

    this is the most noob way to do it, but its simple and easy to read/edit/add to by anyone, also its just the Random method so yeah you definitely already know about it if you code regularly, also you said you had a system that does this on your other source anyways so why not just transfer that over? i used this for my Lootboxes in my vault, basically when you reach a goal, you are allowed to use your vaults lootbox, click "Claim" and it runs the RunLootbox function, dropping the item in a bag at your feet (cuz ur in vault thought that would be cool lmao, easy change for sending it to inventory) and then taking away your CanLootbox permissions until you reach your next goal (its not all handled inside the RunLootbox function, obviously, just the item rewarding half of it is)

    I would love to use the old one but I no longer have access to that original source and, tbh, I was never that good at putting all this stuff together.
    Really just needed an idiot-proof way to get this done. I seem to recall the one I was using being simplified though. Something along the lines of consume this xmas gift to get one of 8 possible items inside.

    So like, add an activate effect: Gift Box B
    then player.useitem.cs is where I'd toss the guts
    then create xml/sprite for the box.

    It's been a while since I've put a server together so I hope I'm getting it right

  5. #4
    Mister_Raccoon's Avatar
    Join Date
    Jul 2016
    Gender
    male
    Posts
    42
    Reputation
    22
    Thanks
    16
    My Mood
    Amused
    Quote Originally Posted by Riigged View Post
    stuff I cut so as not to double quote
    Unfortunately this didn't work. It definitely consumes the item and I get no errors in VS or IntelliJ when running in debug.
    I tossed 2 items in it to test it but nothing drops when I consume it.

  6. #5
    Invader_Zim's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    Atlas 2
    Posts
    546
    Reputation
    10
    Thanks
    300
    My Mood
    Tired
    Look at the functions that generate a bag, say dropping an item, or enemy death with loot.

    After you get it working, this will give you an idea on how to create a sort of weighted system on choosing the reward.
    Code:
    Common = { item1, item2, item3 }
    Uncommon = { item4, item5 }
    Rare = { item6, item7 }
    Epic = { item8, item9 }
    Legendary = { item10 }
    
    //important that the sum of all values equal 1
    Cn = 0.60
    Un = 0.22
    Rn = 0.12
    En = 0.05
    Ln = 0.01
    
    n = rand.NextDouble()
    
    if (n >= (1 - Cn))
    	group = Common
    else if (n >= (1 - Cn - Un))
    	group = Uncommon
    else if (n >= (1 - Cn - Un - Rn))
    	group = Rare
    else if (n >= (1 - Cn - Un - Rn - En))
    	group = Epic
    else 
    	group = Legendary
    	
    rewardItem = group[rand.Next(group.Length())]
    There is a 60% chance to receive item 1, 2, or 3, and a 1% chance to receive item 10.

    You can create a real weighted system using a tuple or a two-dimensional array, but I personally wouldn't make something like that. Mainly because using something like I showed gives you fixed rates, and adding an item in a group wouldn't affect the rates for other items outside of the group.
    Last edited by Invader_Zim; 11-12-2020 at 03:57 PM.

    My weapon is a backpack.

  7. The Following User Says Thank You to Invader_Zim For This Useful Post:

    Mister_Raccoon (11-13-2020)

  8. #6
    Mister_Raccoon's Avatar
    Join Date
    Jul 2016
    Gender
    male
    Posts
    42
    Reputation
    22
    Thanks
    16
    My Mood
    Amused
    Quote Originally Posted by Invader_Zim View Post
    Look at the functions that generate a bag, say dropping an item, or enemy death with loot.

    After you get it working, this will give you an idea on how to create a sort of weighted system on choosing the reward.
    Code:
    Common = { item1, item2, item3 }
    Uncommon = { item4, item5 }
    Rare = { item6, item7 }
    Epic = { item8, item9 }
    Legendary = { item10 }
    
    //important that the sum of all values equal 1
    Cn = 0.60
    Un = 0.22
    Rn = 0.12
    En = 0.05
    Ln = 0.01
    
    n = rand.NextDouble()
    
    if (n >= (1 - Cn))
    	group = Common
    else if (n >= (1 - Cn - Un))
    	group = Uncommon
    else if (n >= (1 - Cn - Un - Rn))
    	group = Rare
    else if (n >= (1 - Cn - Un - Rn - En))
    	group = Epic
    else 
    	group = Legendary
    	
    rewardItem = group[rand.Next(group.Length())]
    There is a 60% chance to receive item 1, 2, or 3, and a 1% chance to receive item 10.

    You can create a real weighted system using a tuple or a two-dimensional array, but I personally wouldn't make something like that. Mainly because using something like I showed gives you fixed rates, and adding an item in a group wouldn't affect the rates for other items outside of the group.
    I'm too much of a scrub to know what to do with all of that. The code appears clean and easy enough to understand how to set items and whatnot but unless someone dumbs it down for me and also includes a method for obtaining the item (hence starting the random item chance you set there) it's just gonna be another thing for me to screw up in a long list of things I've had to have someone bail me out on.

    Quote Originally Posted by Riigged View Post
    snip
    I figured out what my issue was. My dumbass set additional parameters to the switch case because in my noobishness I saw all the other switch cases had parameters and thought this would need to as well. Turns out all the dependencies are built into the code (damn fine work by the way this is great) so it was absolutely unnecessary for me to overcomplicate it by adding things like realmtime, target, position, ect to switch case.

    Thank you both for your help and consideration. You guys fuckin' rock!

  9. #7
    Invader_Zim's Avatar
    Join Date
    Aug 2011
    Gender
    male
    Location
    Atlas 2
    Posts
    546
    Reputation
    10
    Thanks
    300
    My Mood
    Tired
    The only thing missing from what I provided is correct declaration of variables, as I just wrote out an idealization in notepad, not actual code. I would provide more insight, but I don't have a NR-Core source to skim through.

    For item usage, I would start looking at the /give admin command. This should present to you how a given item is declared, and placed into a container, being the player's inventory.

    Creating a container entity should be pretty simple after looking at how it's done when a player drops an item, or looking into how loot is handled. Initialize the entity, since it's a container you can modify the slots, set position to player's, and enter world.

    You would then combine your new knowledge into the custom activate effect for your consumable. Granted that you already know how to create the item with the correct activate tag.



    However, you can take a relatively simple approach, much like DECA has done, and instead have your consumable spawn an enemy that you kill for the loot. You would then use the "OnlyOne" loot behavior, with a list of items at 100% drop rate, for one item to be rewarded. To have more common items, just have copies of items to make them a higher chance to be selected.
    Code:
    new Threshold(0.01,
    	new OnlyOne(
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Life", 1),
    	)
    )
    Att 60%, Mana 30%, Life 10%, only one reward.

    My weapon is a backpack.

  10. The Following User Says Thank You to Invader_Zim For This Useful Post:

    Mister_Raccoon (11-14-2020)

  11. #8
    Mister_Raccoon's Avatar
    Join Date
    Jul 2016
    Gender
    male
    Posts
    42
    Reputation
    22
    Thanks
    16
    My Mood
    Amused
    Quote Originally Posted by Invader_Zim View Post
    The only thing missing from what I provided is correct declaration of variables, as I just wrote out an idealization in notepad, not actual code. I would provide more insight, but I don't have a NR-Core source to skim through.

    For item usage, I would start looking at the /give admin command. This should present to you how a given item is declared, and placed into a container, being the player's inventory.

    Creating a container entity should be pretty simple after looking at how it's done when a player drops an item, or looking into how loot is handled. Initialize the entity, since it's a container you can modify the slots, set position to player's, and enter world.

    You would then combine your new knowledge into the custom activate effect for your consumable. Granted that you already know how to create the item with the correct activate tag.



    However, you can take a relatively simple approach, much like DECA has done, and instead have your consumable spawn an enemy that you kill for the loot. You would then use the "OnlyOne" loot behavior, with a list of items at 100% drop rate, for one item to be rewarded. To have more common items, just have copies of items to make them a higher chance to be selected.
    Code:
    new Threshold(0.01,
    	new OnlyOne(
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Attack", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Mana", 1),
    		new ItemLoot("Potion of Life", 1),
    	)
    )
    Att 60%, Mana 30%, Life 10%, only one reward.
    I hadn't even considered that last option there. I may yet use that for something else, thank you very much!

  12. The Following User Says Thank You to Mister_Raccoon For This Useful Post:

    [MPGH]Beex (11-14-2020)

Similar Threads

  1. [Help Request] Need a tester for new Quickswitch
    By wGRWGHWGRERGrgergergrg in forum Alliance of Valiant Arms (AVA) Help
    Replies: 4
    Last Post: 06-26-2013, 02:41 AM
  2. [Request] Need SC2 Hacks for new update
    By terror4444 in forum Starcraft 2 Hacks
    Replies: 5
    Last Post: 05-05-2012, 08:42 AM
  3. NEED A GLITCHER FOR NEW MAP MALL
    By Sunday. in forum CrossFire Discussions
    Replies: 5
    Last Post: 03-24-2011, 02:38 PM
  4. Need Idea's for new mod
    By vbdfgrseraes in forum Call of Duty Modern Warfare 2 Help
    Replies: 10
    Last Post: 07-15-2010, 08:17 AM
  5. [Request] I need the files for new update
    By jaskiiez20 in forum Soldier Front General
    Replies: 11
    Last Post: 12-23-2009, 10:24 AM