Skip to content

Commit

Permalink
Merge pull request #317 from GMLambda/fix-npc-weapons
Browse files Browse the repository at this point in the history
Fix npc weapon transitioning
  • Loading branch information
ZehMatt authored Oct 13, 2024
2 parents 5944a19 + 1929f48 commit 710ee82
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 9 additions & 3 deletions gamemode/sv_transition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 710ee82

Please sign in to comment.