// Legendary: custom items made from the game's own, each with its own color (icon, name and the model in hand). A Golden M4 that hits harder, a Hunter's Bow, a Survivor's Medkit // that stacks to 10. They keep their base's model and rules (ammo, crafting, durability) and have their own name, // description, icon and values. They stay in inventories, boxes and the world save; if this plugin is removed they turn // back into the plain item. // Admins: /legendary opens a menu to give them. Other plugins can give them too: Give( player, "Golden M4" ). // Install: copy this file into the server's data folder, plugins/Legendary.cs. // Script engine rules: test objects with != null, no static fields that change, callbacks with one parameter at most. using RustLegacy; public class Legendary : RustPlugin { readonly List _names = new List(); public override void OnLoaded() { // values are read from the base item, so they follow the game's balance var m4 = ItemDatabase.Find( "M4" ); var golden = new PluginItem { Id = "legendary_golden_m4", Base = "M4", Title = "Golden M4", Description = "25 % more damage, a tighter spread. Only one on the island.", Tint = "#ffc83c", PaintModel = true }; golden.Stats["Damage"] = m4.Damage * 1.25f; golden.Stats["DamageMin"] = m4.DamageMin * 1.25f; golden.Stats["Spread"] = m4.Spread * 0.7f; Define( golden ); var bow = ItemDatabase.Find( "Hunting Bow" ); var hunter = new PluginItem { Id = "legendary_hunters_bow", Base = "Hunting Bow", Title = "Hunter's Bow", Description = "Hits like a rifle, for those who never miss.", Tint = "#8fd16a" }; hunter.Stats["Damage"] = bow.Damage * 1.6f; hunter.Stats["DamageMin"] = bow.DamageMin * 1.6f; Define( hunter ); var medkit = new PluginItem { Id = "legendary_survivor_medkit", Base = "Large Medkit", Title = "Survivor's Medkit", Description = "A Large Medkit that stacks to 10.", Tint = "#7fb8ff" }; medkit.Stats["MaxStack"] = 10; Define( medkit ); AddCommand( "legendary", OnCommand, "Legendary items", true, "[item name]" ); } void Define( PluginItem item ) { DefineItem( item ); _names.Add( item.Title ); } void OnCommand( ChatCommand cmd ) { var p = cmd.Player; if ( cmd.Args.Length > 0 ) { var name = string.Join( " ", cmd.Args ); Give( p, name, 1 ); Reply( p, $"Given: {name}" ); return; } var menu = new PluginMenu { Title = "Legendary items", Text = "Custom items of this server. Click to get one.", KeepOpen = true }; foreach ( var name in _names ) menu.Buttons.Add( new PluginMenuButton { Label = name, Command = $"/legendary {name}", Item = name } ); ShowMenu( p, menu ); } }