Release WeaponBuilder (for plugin developers)
#1
WeaponBuilder class

Features
  • Supports up to 3 attachments each weapon
  • Camo
  • Reticle's
  • Choose from over 30 different attachments
  • Choose from 14 different camo's (Including Marine and Winter, the hidden camo's)
  • Sniper support (MW3 handles sniper attachments really weirdly)

What is it?
A class that makes it easier for plugin developers to create highly customizable weapons.
NO, IT'S NOT A FUCKING PLUGIN

How to use?
Just add a class to your project and paste the source code (below) in there.
Change 'YourNameSpace' to your namespace.

Example:
Code:
cl.Other.PrimaryWeapon = GetWeapon(WeaponBuilder.CreateWeapon("iw5_scar_mp", WeaponBuilder.Attachment.reflex, WeaponBuilder.Attachment.silencer, WeaponBuilder.Camo.Gold, WeaponBuilder.Reticle.Delta, WeaponBuilder.Attachment.heartbeat));

Result: (Notice the silencer, Heartbeat & Scope)
[Image: 3f9cf798.png]
[Image: b818695e.png]

Sourcecode:
Code:
using System; using System.Collections.Generic; using System.Text; //Modded WeaponBuilder class from RTD (rollthedice.googlecode.com) //By JariZ namespace YourNameSpace { class WeaponBuilder { public enum Camo { None = 00, Classic = 01, Snow = 02, Multicam = 03, DigitalUrban = 04, Hex = 05, Choco = 06, Snake = 07, Blue = 08, Red = 09, Autumn = 10, Gold = 11, Marine = 12, Winter = 13 }; public enum Reticle { None = 0, TargetDot = 1, Delta = 2, UDot = 3, MilDot = 4, Omega = 5, Lambda = 6 }; public enum Attachment { none, acog, acogsmg, reflex, reflexsmg, reflexlmg, silencer, silencer02, silencer03, grip, gl, gp25, m320, akimbo, thermal, thermalsmg, shotgun, heartbeat, fmj, rof, xmags, eotech, eotechsmg, eotechlmg, tactical, hamrhybrid, hybrid, zoomscope, scope, scopevz }; static string[] snipers = { "barrett", "rsass", "dragunov", "msr", "l96a1", "as50" }; static string remove(string source, string needle) { return source.Replace(needle, ""); } public static string CreateWeapon(string name, Attachment Attachment1) { return CreateWeapon(name, Attachment1, Attachment.none, Camo.None, Reticle.None, Attachment.none); } public static string CreateWeapon(string name) { return CreateWeapon(name, Attachment.none, Attachment.none, Camo.None, Reticle.None, Attachment.none); } public static string CreateWeapon(string name, Attachment Attachment1, Attachment Attachment2) { return CreateWeapon(name, Attachment1, Attachment2, Camo.None, Reticle.None, Attachment.none); } public static string CreateWeapon(string name, Attachment Attachment1, Attachment Attachment2, Camo Camo) { return CreateWeapon(name, Attachment1, Attachment2, Camo, Reticle.None, Attachment.none); } public static string CreateWeapon(string name, Attachment Attachment1, Attachment Attachment2, Camo Camo, Reticle Reticle) { return CreateWeapon(name, Attachment1, Attachment2, Camo, Reticle, Attachment.none); } public static string CreateWeapon(string name, Attachment Attachment1, Attachment Attachment2, Camo Camo, Reticle Reticle, Attachment Attachment3) { if (name.Substring(0, 4) != "iw5_" && name.EndsWith("_mp")) return name; else if (name.Substring(0, 4) != "iw5_" && !name.EndsWith("_mp")) return name + "_mp"; string basename = remove(remove(name, "iw5_"), "_mp"); // remove iw5 & mp bool sniper = false; foreach (string s in snipers) { if (s == basename) { sniper = true; break; } } string a1 = Attachment1.ToString(); if (sniper) a1 = basename + a1; string a2; if (Attachment2 != Attachment.none) { a2 = Attachment2.ToString(); if (sniper) a2 = basename + a2; a2 += "_"; } else a2 = ""; string a3; if (Attachment3 != Attachment.none) { a3 = Attachment3.ToString(); if (sniper) a3 = basename + a3; a3 += "_"; } else a3 = ""; string fCamo = ((int)Camo).ToString(); if (((int)Camo).ToString().Length == 1) fCamo = "0" + fCamo; string x = string.Format("iw5_{0}_mp_{1}_{2}{3}camo{4}_scope{5}", basename, a1, a2, a3, fCamo, (int)Reticle); return x; } } }

Credits
- @Yamato - Attachment list
- @Nukem - Some Intelz over how to do camo
Reply

#2
Nice job @JariZ.
I have just 1 tip. In c# when declaring an enum you don't have to assign every entry a number. If you give the first entry a number it will automatically count upwards.

For example
Code:
public enum Reticle { None = 0, TargetDot = 1, Delta = 2, UDot = 3, MilDot = 4, Omega = 5, Lambda = 6 };
Could be simplified to
Code:
public enum Reticle { None = 0, TargetDot, Delta, UDot, MilDot, Omega , Lambda};


Btw, @zxz0O0 this class should really be build in to the addon's api.
[Image: MaEIQ.png]
Reply

#3
@Pozzuh I've been asking nukem for over a few months to add this but he never gave me a serious reaction so I just decided to release this seperatly. This class is at least 2/3 months old now.
Reply

#4
@Pozzuh I did that mostly to make sure that each value had the right number while testing.
I know that already, I've been working with C# for at least 3/4 years now.
Reply

#5
What Pozzuh said. Anyway, nice job.
[Image: 30xhrep.png]

A casual conversation between barata and I about Nukem.
Reply

#6
Nice job! Thank you!
Reply

#7
I <3 it!
Reply

#8
Awesome job @JariZ I didn't know you had something like this. If I find time I will defintely integrate this into the addon.
[Image: azuw.jpg]
Reply

#9
I kinda forgot about it after @Nukem ignoring me.
I haven't tested the snipers fully so you might want to test it a bit before adding it.
Reply

#10
Successfully ported to the server addon. Had to make some small changes but I think it's working properly now. It will be in the next update (release date unknown).
[Image: azuw.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 6,492 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 7,592 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 55,806 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 7,643 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 8,295 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 82,113 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 25,160 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 3,655 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 44,653 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 3,975 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2026 Melroy van den Berg.