//JUNK EMPIRES CITY AddCSLuaFile( "cl_init.lua" ) AddCSLuaFile( "shared.lua" ) include( 'shared.lua' ) function ENT:SpawnFunction( ply, tr ) if ( !tr.Hit ) then return end local SpawnPos = tr.HitPos + tr.HitNormal * 16 local ent = ents.Create( "city" ) ent:SetPos( SpawnPos ) ent:Spawn() ent:Activate() return ent end function ENT:Initialize() //the city self.Entity:SetModel( "models/props_trainstation/trainstation_ornament002.mdl" ) self.Entity:PhysicsInit( SOLID_VPHYSICS ) self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) self.Entity:SetSolid( SOLID_VPHYSICS ) self.Entity:SetMaterial("models/debug/debugwhite") local phys = self.Entity:GetPhysicsObject() if (phys:IsValid()) then phys:EnableMotion(false) //Don't want our cities rolling around everywhere end self.claimed = false self.combatant = false self.Overlord = "nothing" end function ENT:Use(ply) if(!self.claimed) then self.Entity:SetColor( ply:GetColor() ) //set city to player's color local R, G, B, A = ply:GetColor() self.Entity:SetNWInt("ColorR", R) self.Entity:SetNWInt("ColorG", G) self.Entity:SetNWInt("ColorB", B) ply:SetNWInt(ply:Nick() .. "_cities", ply:GetNWInt(ply:Nick() .. "_cities") + 1) //add to the citycount //ply:SetNWEntity( "city_" .. ply:GetNWInt(ply:Nick() .. "_cities"), self.Entity) //not too sure about this lagwise self.claimed = true self.Overlord = ply self.combatant = true end end function ENT:GetOverlord() return self.Overlord end function ENT:Raze() if(self.Overlord != "nothing") then self.Overlord:SetNWInt(self.Overlord:Nick() .. "_cities", self.Overlord:GetNWInt(self.Overlord:Nick() .. "_cities") - 1) self.Overlord:SetNWInt(self.Overlord:Nick() .. "_gold", self.Overlord:GetNWInt(self.Overlord:Nick() .. "_gold") - 5) local effectdata = EffectData() effectdata:SetEntity( self ) effectdata:SetOrigin( self.Entity:GetPos()) util.Effect( "propspawn", effectdata ) self.Entity:Remove() end end function ENT:IsCombatant() return self.combatant end function ENT:Think() for k, v in pairs(ents.FindInSphere(self.Entity:GetPos(), 200)) do if (v:GetClass() == "farm" || v:GetClass() == "iron_mine") then v:SetNWBool("claimebel", true) v:SetNWString("claimebelby", "self.Overlord") end end end