diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-25 22:40:09 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-05-25 22:40:09 -0400 |
| commit | f797cbe348dd52b51da4cd4812cfa291d1434095 (patch) | |
| tree | df4fabacfc6819a981d750c510122f5bbda8083c /entities | |
| parent | a5932d386488030b6005c829fe343f74daed9893 (diff) | |
| parent | fd04cb695e1c0e6597456f2b1b7b076310fd81bf (diff) | |
| download | gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.tar.gz gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.tar.bz2 gmstranded-f797cbe348dd52b51da4cd4812cfa291d1434095.zip | |
Merge branch 'structsystem'hotfix
Diffstat (limited to 'entities')
| -rw-r--r-- | entities/entities/gms_antlionbarrow.lua | 2 | ||||
| -rw-r--r-- | entities/entities/gms_base_entity.lua | 12 | ||||
| -rw-r--r-- | entities/entities/gms_buildsite.lua | 2 | ||||
| -rw-r--r-- | entities/entities/gms_copperfurnace.lua | 7 | ||||
| -rw-r--r-- | entities/entities/gms_generic_structure.lua | 47 | ||||
| -rw-r--r-- | entities/entities/gms_seed.lua | 2 | ||||
| -rw-r--r-- | entities/entities/gms_tree.lua | 2 | ||||
| -rw-r--r-- | entities/weapons/gms_wand.lua | 40 |
8 files changed, 85 insertions, 29 deletions
diff --git a/entities/entities/gms_antlionbarrow.lua b/entities/entities/gms_antlionbarrow.lua index 9c6000d..c06aa08 100644 --- a/entities/entities/gms_antlionbarrow.lua +++ b/entities/entities/gms_antlionbarrow.lua @@ -10,7 +10,7 @@ ENT.DoWake = true if ( CLIENT ) then return end function ENT:OnInitialize() - self:SetNetworkedString( "Owner", "World" ) + self:SetNWString( "Owner", "World" ) self:SetMoveType( MOVETYPE_NONE ) diff --git a/entities/entities/gms_base_entity.lua b/entities/entities/gms_base_entity.lua index 074633e..eff03cb 100644 --- a/entities/entities/gms_base_entity.lua +++ b/entities/entities/gms_base_entity.lua @@ -16,19 +16,19 @@ function ENT:Initialize() self:PhysicsInit( SOLID_VPHYSICS ) self:SetMoveType( MOVETYPE_VPHYSICS ) self:SetSolid( SOLID_VPHYSICS ) - - if ( self.Color ) then self:SetColor( self.Color ) end - if ( self.DoWake ) then self:Wake() end - if ( self.DoFreeze ) then self:DoFreeze() end end - self:OnInitialize() + self:onInitialize() +end + +function ENT:Draw() + self:DrawModel() end function ENT:OnInitialize() end -if ( CLIENT ) then return end +--if ( CLIENT ) then return end function ENT:Use( ply ) if ( !ply:KeyPressed( IN_USE ) ) then return end diff --git a/entities/entities/gms_buildsite.lua b/entities/entities/gms_buildsite.lua index 919c725..a0f8199 100644 --- a/entities/entities/gms_buildsite.lua +++ b/entities/entities/gms_buildsite.lua @@ -28,7 +28,7 @@ function ENT:AddResource( res, int ) for k, v in pairs( self.Costs ) do str = str .. "\n" .. string.Replace( k, "_", " " ) .. " ( " .. v .. "x )" end - self:SetNetworkedString( "Resources", str ) + self:SetNWString( "Resources", str ) end function ENT:Setup( model, class ) diff --git a/entities/entities/gms_copperfurnace.lua b/entities/entities/gms_copperfurnace.lua index 1aaa970..3dddd48 100644 --- a/entities/entities/gms_copperfurnace.lua +++ b/entities/entities/gms_copperfurnace.lua @@ -8,6 +8,11 @@ ENT.Model = "models/props/cs_militia/furnace01.mdl" if ( CLIENT ) then return end -function ENT:OnUse( ply ) +function ENT:onUse( ply ) + print("use called") ply:OpenCombiMenu( "gms_copperfurnace" ) end + +function ENT:onInitialize() + print("Initalize calleD") +end diff --git a/entities/entities/gms_generic_structure.lua b/entities/entities/gms_generic_structure.lua new file mode 100644 index 0000000..d76ed30 --- /dev/null +++ b/entities/entities/gms_generic_structure.lua @@ -0,0 +1,47 @@ + +AddCSLuaFile() + +ENT.Type = "anim" +ENT.Base = "gms_base_entity" + +function ENT:Initialize() + print("Initalize called!") + util.PrecacheModel(self.Model) + if self.Model then self:SetModel(self.Model) end + if self.onInitialize then self:onInitialize() end + if CLIENT then return end + self:PhysicsInit( SOLID_VPHYSICS ) + --self:SetMoveType( MOVETYPE_VPHYSICS ) + self:SetSolid( SOLID_VPHYSICS ) + if SERVER then self:SetUseType(SIMPLE_USE) end +end + +if (SERVER) then + util.AddNetworkString( "ent_use" ) +end +function ENT:Use( ply ) + if self.onUse != nil then + self.onUse(self, ply) + net.Start("ent_use") + net.WriteUInt(self:EntIndex(), GMS.NETINT_BITCOUNT) + net.WriteString(self.Name) + net.WriteUInt(ply:UserID(), GMS.NETINT_BITCOUNT) + net.Send(ply) + end +end +if (CLIENT) then + net.Receive( "ent_use", function(ln,ply) + local ent = Entity(net.ReadUInt(GMS.NETINT_BITCOUNT)) + local nam = net.ReadString() + local who = Player(net.ReadUInt(GMS.NETINT_BITCOUNT)) + local tbl = GMS.Structures[nam] + if tbl != nil then + if tbl.uniquedata then + tbl = GMS.UniqueStructures[ent:EntIndex()] + end + if tbl.onUse != nil then + tbl.onUse(ent,who) + end + end + end) +end diff --git a/entities/entities/gms_seed.lua b/entities/entities/gms_seed.lua index 626669f..be1cd07 100644 --- a/entities/entities/gms_seed.lua +++ b/entities/entities/gms_seed.lua @@ -117,7 +117,7 @@ function GAMEMODE.MakeTree( pos ) ent:SetPos( pos ) ent:Spawn() ent.GMSAutoSpawned = true - ent:SetNetworkedString( "Owner", "World" ) + ent:SetNWString( "Owner", "World" ) end function GAMEMODE.MakeGrain( pos, ply ) diff --git a/entities/entities/gms_tree.lua b/entities/entities/gms_tree.lua index cd73761..746e3ad 100644 --- a/entities/entities/gms_tree.lua +++ b/entities/entities/gms_tree.lua @@ -15,7 +15,7 @@ ENT.Uses = 100 if ( CLIENT ) then return end function ENT:OnInitialize() - self:SetNetworkedString( "Owner", "World" ) + self:SetNWString( "Owner", "World" ) self:SetMoveType( MOVETYPE_NONE ) diff --git a/entities/weapons/gms_wand.lua b/entities/weapons/gms_wand.lua index cd71e2c..724b5d9 100644 --- a/entities/weapons/gms_wand.lua +++ b/entities/weapons/gms_wand.lua @@ -20,10 +20,14 @@ function SWEP:Initialize() end function SWEP:PrimaryAttack() - ParticleEffectAttach( "vortigaunt_hand_glow_c", PATTACH_ABSORIGIN_FOLLOW, self, 0 ) + if(SERVER) then + //if !(self:IsCarriedByLocalPlayer()) then return end + //ParticleEffectAttach( "vortigaunt_hand_glow_c", PATTACH_ABSORIGIN_FOLLOW, self, 0 ) + //ParticleEffect("vortigaunt_hand_glow_c",self.Owner:GetPos() + Vector(0,0,64),self:GetAngles(),self) + end //ParticleEffectAttach("vortigaunt_hand_glow_c",PATTACH_ABSORIGIN_FOLLOW,self,0) self:throw_attack("models/props/cs_office/Chair_office.mdl") - + end local ShootSound = Sound("Metal.SawbladeStick") @@ -31,46 +35,46 @@ local ShootSound = Sound("Metal.SawbladeStick") function SWEP:throw_attack (model_file) //Get an eye trace. This basically draws an invisible line from - //the players eye. This SWep makes very little use of the trace, except to + //the players eye. This SWep makes very little use of the trace, except to //calculate the amount of force to apply to the object thrown. local tr = self.Owner:GetEyeTrace() - + //Play some noises/effects using the sound we precached earlier self:EmitSound(ShootSound) self.BaseClass.ShootEffects(self) - + //We now exit if this function is not running serverside if (!SERVER) then return end - + //The next task is to create a physics prop based on the supplied model local ent = ents.Create("prop_physics") ent:SetModel(model_file) - - + + //Set the initial position and angles of the object. This might need some fine tuning; //but it seems to work for the models I have tried. ent:SetPos(self.Owner:EyePos() + (self.Owner:GetAimVector() * 16)) ent:SetAngles(self.Owner:EyeAngles()) - + ent:Spawn() - + ParticleEffectAttach( "vortigaunt_hand_glow_c", PATTACH_ABSORIGIN_FOLLOW, ent, 0 ) - - + + //Now we need to get the physics object for our entity so we can apply a force to it local phys = ent:GetPhysicsObject() - + //Check if the physics object is valid. If not, remove the entity and stop the function if !(phys && IsValid(phys)) then ent:Remove() return end - - //Time to apply the force. My method for doing this was almost entirely empirical + + //Time to apply the force. My method for doing this was almost entirely empirical //and it seems to work fairly intuitively with chairs. phys:ApplyForceCenter(self.Owner:GetAimVector():GetNormalized() * math.pow(tr.HitPos:Length(), 3)) - - + + //Now for the important part of adding the spawned objects to the undo and cleanup lists. cleanup.Add(self.Owner, "props", ent) - + undo.Create ("Thrown_SWEP_Entity") undo.AddEntity (ent) undo.SetPlayer (self.Owner) |
