diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-21 19:08:34 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2018-07-21 19:08:34 -0400 |
| commit | 81d3d4eb333e226432a591461b84ed12f5ac9a3f (patch) | |
| tree | d802983c3caf6683f1fd8eb881c7df65afa0d27b /gamemode/core/animation | |
| parent | bfdf805676684a838dde5d4cdeb3d8c972d5003d (diff) | |
| download | artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.gz artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.tar.bz2 artery-81d3d4eb333e226432a591461b84ed12f5ac9a3f.zip | |
Various updates
* Animation api now allows sequences to be played
* items now have a .inv attribute that is set when they are added
to shaped or equipment inventories
* Refactored the way skill inventory is structured
* Added some more methods to cl_common to move items around on a
player
* Minor update to nrequire to display purple message when asked
to include a file that dosn't exist.
Diffstat (limited to 'gamemode/core/animation')
| -rw-r--r-- | gamemode/core/animation/cl_animate.lua | 23 | ||||
| -rw-r--r-- | gamemode/core/animation/sh_animations.lua | 20 | ||||
| -rw-r--r-- | gamemode/core/animation/sv_animate.lua | 33 |
3 files changed, 76 insertions, 0 deletions
diff --git a/gamemode/core/animation/cl_animate.lua b/gamemode/core/animation/cl_animate.lua index fd322a1..c7dc19d 100644 --- a/gamemode/core/animation/cl_animate.lua +++ b/gamemode/core/animation/cl_animate.lua @@ -11,3 +11,26 @@ net.Receive("art_stop_animation",function() local anim = net.ReadString() what:StopLuaAnimation(anim) end) + +local sequences = {} +net.Receive("art_start_sequence",function() + local who = net.ReadEntity() + local seq = net.ReadUInt(31) + local time = net.ReadFloat() + local untilstoped = net.ReadBool() + local speed = net.ReadFloat() + sequences[who] = sequences[who] or {} + who:SetCycle(0) + if untilstoped then + sequences[who] = {CurTime() + 9999999, seq, speed} + else + sequences[who] = {CurTime() + time, seq, speed} + end +end) + +net.Receive("art_end_sequence",function() + local who = net.ReadEntity() + sequences[who] = nil +end) + +return sequences diff --git a/gamemode/core/animation/sh_animations.lua b/gamemode/core/animation/sh_animations.lua index 3846fcc..a1430a5 100644 --- a/gamemode/core/animation/sh_animations.lua +++ b/gamemode/core/animation/sh_animations.lua @@ -2,3 +2,23 @@ if not RegisterLuaAnimation then error("JetBoom's libanimbone is required for animations. (It's bundeled with PAC3)") return end + +local sequences +local log = nrequire("log.lua") +if SERVER then + sequences = nrequire("core/animation/sv_animate.lua") +else -- CLIENT + sequences = nrequire("core/animation/cl_animate.lua") +end + +hook.Add("UpdateAnimation","art_updateanim",function(ply,vel,mgs) + if sequences and ply and sequences[ply] and CurTime() < sequences[ply][1] then + ply:SetPlaybackRate(sequences[ply][3]) + end +end) + +hook.Add("CalcMainActivity","art_swing",function(ply,vel) + if sequences and ply and sequences[ply] and CurTime() < sequences[ply][1] then + return -1, sequences[ply][2] + end +end) diff --git a/gamemode/core/animation/sv_animate.lua b/gamemode/core/animation/sv_animate.lua index 24d0ed0..b8cec56 100644 --- a/gamemode/core/animation/sv_animate.lua +++ b/gamemode/core/animation/sv_animate.lua @@ -5,6 +5,8 @@ local meta = FindMetaTable("Player") util.AddNetworkString("art_start_animation") util.AddNetworkString("art_stop_animation") +util.AddNetworkString("art_start_sequence") +util.AddNetworkString("art_end_sequence") function meta:StartAnimation(name) net.Start("art_start_animation") @@ -19,3 +21,34 @@ function meta:StopAnimation(name) net.WriteString(name) net.Broadcast() end + +local sequences = {} + +function meta:StartSequence(name,untilstoped,speed) + untilstoped = untilstoped or false + speed = speed or 1 + local seq, time = self:LookupSequence(name) + sequences[self] = sequences[self] or {} + if untilstoped then + sequences[self] = {CurTime() + 9999999, seq, speed} + else + sequences[self] = {CurTime() + time, seq, speed} + end + self:SetCycle(0) + net.Start("art_start_sequence") + net.WriteEntity(self) + net.WriteUInt(seq,31) + net.WriteFloat(time) + net.WriteBool(untilstoped) + net.WriteFloat(speed) + net.Broadcast() +end + +function meta:EndSequence(name) + sequences[self] = nil + net.Start("art_end_sequence") + net.WriteEntity(self) + net.Broadcast() +end + +return sequences |
