diff --git a/changelog.md b/changelog.md index 9ae8d9d1..18c7abe4 100644 --- a/changelog.md +++ b/changelog.md @@ -2,6 +2,7 @@ - Improved: Going in and out of the settings no longer clips into the player model. - Fixed: NPC makers not respecting the spawn frequency -1 causing a lot of NPCs being spawned in some cases. - Fixed: ep1_c17_00a: Don't cancel scripted_sequence on player death. +- Fixed: weapons not properly transitioning for NPCs. 0.9.25 - Improved: Hints will no longer show duplicates, instead it will renew the existing hint that has the same text. diff --git a/gamemode/sv_transition.lua b/gamemode/sv_transition.lua index 7bdc71a4..38be6949 100644 --- a/gamemode/sv_transition.lua +++ b/gamemode/sv_transition.lua @@ -444,6 +444,11 @@ function GM:SerializeEntityData(landmarkEnt, ent, playersInTrigger) data.SaveTable["LambdaVehicle"] = ent:GetNWEntity("LambdaVehicle", nil) local activeWeapon = ent:GetActiveWeapon() if IsValid(activeWeapon) then data.ActiveWeapon = activeWeapon:GetClass() end + local npcWeps = ent:GetWeapons() + data.NPCWeapons = {} + for _, v in pairs(npcWeps) do + table.insert(data.NPCWeapons, v:GetClass()) + end elseif ent:IsVehicle() then data.Type = ENT_TYPE_VEHICLE if ent:IsGunEnabled() then @@ -943,12 +948,13 @@ function GM:CreateTransitionObjects() if data.IsPassengerSeat == true then ent:SetNWBool("IsPassengerSeat", true) end if data.Type == ENT_TYPE_NPC then ent:SetMovementActivity(data.MovementActivity) - --ent:SetMovementSequence(data.MovementSequence) ent:SetExpression(data.Expression) ent:SetNPCState(data.NPCState) + for _, v in pairs(data.NPCWeapons) do + ent:Give(v) + end if data.ActiveWeapon ~= nil then - ent:SetKeyValue("additionalequipment", data.ActiveWeapon) - GAMEMODE:EntityKeyValue(ent, "additionalequipment", data.ActiveWeapon) + ent:SelectWeapon(data.ActiveWeapon) end elseif data.Type == ENT_TYPE_VEHICLE then if data.EnableGun == true then