Is there a way to make one entity and a config file, And in the coonfig a line like
entityMake("weapon_name" , name) etc and it will create an entity at runtime based on that infomation?
[QUOTE=0V3RR1D3;47628185]Is there a way to make one entity and a config file, And in the coonfig a line like
entityMake("weapon_name" , name) etc and it will create an entity at runtime based on that infomation?[/QUOTE]
If I understand correctly, you want to create a base entity, and decide how it behaves when you create it to suit your needs? If so, then yes, it is more than possible. If I were you, I would create my base to rely on variables saved in the ENT table, and change those variables when spawning it.
Yes, you can create a helper-function to directly insert data into Weapons / Vehicles / Entities / ETC... tables and have it work. They are considered "internal" functions because they're used when including sweps, entities, etc... in their respective folders... But, yes, as said you can create an entity without having the entity in its own file or folder...
As James suggested though, it's best to keep the "config" in the entity.. So if you're writing a base, have it read SWEP.X or ENT.X, ie self.X in function SWEP:XX( ) or function ENT:XX( ), so when you create a new weapon or entity from the base you only need to add variables to the file...
Example of how I define SWEPs:
[code]//
// AK47 - Josh 'Acecool' Moser
//
if SERVER then
AddCSLuaFile( );
else
SWEP.PrintName = "AK47"
SWEP.ViewModelFOV = 72
SWEP.ViewModelFlip = true
SWEP.HolsterSettings = {
default = { bone = "ValveBiped.Bip01_Spine2", pos = Vector( 3.8, -4.52, 2.67 ), ang = Angle( 0, 0, 214.31 ) };
unloaded = { bone = "ValveBiped.Bip01_Spine2", pos = Vector( 3.41, 5, 5.95 ), ang = Angle( 0, 0, 216.9 ) };
};
end
SWEP.Base = "acecool_weapon_base";
SWEP.Slot = WEAPON_SLOT2;
SWEP.HoldType = "ar2"
SWEP.IdleHoldType = "passive"
SWEP.ViewModel = "models/weapons/v_rif_ak47.mdl" // cstrike/c
SWEP.WorldModel = "models/weapons/w_rif_ak47.mdl"
SWEP.UnloadedWorldModel = "models/weapons/unloaded/rif_ak47.mdl"
SWEP.MagazineWorldModel = "models/weapons/unloaded/rif_ak47_mag.mdl"
SWEP.Sights= {
idlesights = { pos = Vector (-6.0287, -3.9819, -1.1684), ang = Angle(-20.049, -47.8242, 16.905) },
ironsights = { pos = Vector(6.0809, -11.3068, 2.6259), ang = Angle(2.6184, -0.0945, 0) }
};
SWEP.Primary.Sound = Sound( "Weapon_AK47.Single" )
SWEP.Primary.SuppressedSound = nil
SWEP.FireRatePerMinute = 600;
SWEP.Primary.MagazineCapacity = 30;
SWEP.Primary.Caliber = CALIBER_762X39;
SWEP.WeaponAccessories = { WEAPON_IRONSIGHTS }
SWEP.SelectFireModes = { WEAPON_FIREMODE_SAFE, WEAPON_FIREMODE_AUTO }
SWEP.WeaponClass = WEAPON_CLASS_ASSAULT_RIFLE;
SWEP.DeploySpeed = 1;
//
// util.Precache
//
util.Precache( { SWEP.ViewModel, SWEP.WorldModel, SWEP.UnloadedWorldModel, SWEP.MagazineWorldModel, SWEP.Primary.Sound, SWEP.Primary.SuppressedSound } );
[/code]
A lot of the vars such as FireRatePerMinute, MagazineCapacity, Etc... are custom and the base reads it to decide how it needs to define the weapon / set the next-fire-delay, etc....
Sorry, you need to Log In to post a reply to this thread.