STEAM GROUP
Star Wars Vehicles: Redux SWV:R
Membership by invitation only
STEAM GROUP
Star Wars Vehicles: Redux SWV:R
0
IN-GAME
2
ONLINE
Founded
18 July, 2018
Showing 1-6 of 6 entries
3
The Event System
What an Event System Is

If you've worked with Javascript or other languages in the past, you may be familiar with event systems.

Star War Vehicles: Redux is designed to be an event driven framework. This means your code will be reactive instead of proactive. You do things based on an event that just happened. The base itself takes care of making sure you react to the correct event.

What Events are there?

The current list of events are as follows:

  • OnFire(group, seat) - Triggers whenever any of the ship's weapon groups are fired.
  • OnOverheat(group, seat) - Triggers whenever any of the ship's weapon groups overheat.
  • OnOverheatReset(group, seat) - Triggers whenever any of the ship's weapon groups reset.
  • OnShieldsDown() - Triggers when the shields go down.
  • OnCollision(damage) - Triggers when the ship makes a physics collision (and shields are down)
  • OnCritical() - Triggers when the ship enters the critical threshhold.
  • OnEnter(player) - Triggers when a player enters the ship (pilot or passenger).

What can I do with these Events?

Well an important thing to note is that these events get called on the server and the client! This is so you can be as flexible as possible with what you do with the events. Let's do an example.

Say you want to let the player know in chat when their shields go down. Chat functions are clientside so we need to add this event on the client.

So, when initializing your ship add the event:

self:AddEvent("OnShieldsDown", function() if LocalPlayer():GetNWEntity("Ship") ~= self then return end -- On people in the ship! chat.AddText(Color(255, 0, 0), "[WARNING] ", Color(255, 255, 255), "SHIELDS OFFLINE") end)

This would print "[WARNING] SHIELDS OFFLINE" to all players inside the ship. If you wanted only the pilot to know then you could add further checks.

You can see it in action here: https://www.youtube.com/watch?v=lsvjaC7cjxk

This event system is already used internally for default events such as the overheating noises:

self:AddEvent("OnFire", function(group, seat) if LocalPlayer():GetNWEntity("Ship") ~= self then return end if LocalPlayer():GetNWString("SeatName") ~= seat then return end if (group.Overheat >= group.OverheatMax - 10) then self:EmitSound("vehicles/shared/swvr_overheat_ping.wav", 75, 100, math.Clamp(math.exp(math.pow(group.Overheat / group.OverheatMax * 0.98, 7)) - 1, 0, 1)) end end)

Here's how that looks: https://www.youtube.com/watch?v=WjSAp63O51M

If you want to add the default events to your ship, you can simply call self:SetupDefaults() or configure it as follows.

self:SetupDefaults({ OnShieldsDown = false })

Setting an event to false stops the default from running (so you can override it with your own). You can add as many events as you want, even multiple of the same event and they will all be called automatically.
9
Introduction to New Features
0
GitHub Contributing
9
Introduction to New Features
Hey everyone,

Just wanted to give everyone a quick overview of the current new features and new way of doing certain things, as well as some of the planned features that were requested by some of you and the community.

You can assume everything from the old base is already there (and probably improved).

Design Philosophy

I want the base to be as configurable as possible. Because of this, most functions now accept a table in order to parse optional data. Anywhere a table is passed to a function as a paramter, you can assume all the table values are optional and will be set to defaults if you do not override them.

For example when adding a seat you might see something like this:

self:AddSeat("Back", Vector(255, 0, 85), self:GetAngles() + Angle(0, 90, 0), { visible = false, exitpos = Vector(0, 35, -20), weapons = {"Back"} })

That last parameter is a table, the values inside of it are all the optional things you can set to configure the seat even more.

Because all the table values have defaults, you could in theory leave it out of the function call and it will still work:

self:AddSeat("Back", Vector(255, 0, 85), self:GetAngles() + Angle(0, 90, 0))

Currently Added Features

Ship Scaling

Ever felt like your ship was too big or too small? Don't want to recompile your entire model just to change the size? Now you don't have to!

Due to the nice way I have setup positioning, I was able to add drop in support for model scaling. This means that you can call
self:SetModelScale()
at the beginning of
ENT:Initialize()
to set a scale for all positioning involving the ship.

This means that you can scale the ship, all weapons, engine effects, etc. just with one line. Currently there may be some issues with view scaling but that should get ironed out. It's kinda fun to fly your ship around at 0.05 scale and feel like an RC plane.

Shield System

Probably one of my most requested features. Optional to use with ships. Haven't fully implemented recharging yet but it will be soon.

Here[my.mixtape.moe] is a quick video showing the effect. Currently using a generic shield sounding hit until I can get a better.

Improved HUD

The HUD will now draw for each passenger inside of ship, not just the pilot. This means passengers will have a better idea of the status of the ship they are in.

Separate weapon cooldowns are also now supported for other seats. That means that firing weapons as a gunner will also display your own cooldown under the main reticle.

Here[my.mixtape.moe] is an example showing off the addition of the HUD to passengers and their own weapon cooldowns

Clientside Sound System

Sometimes you only want the people in the ship to hear something, this is best accomplished by only playing the sounds on the clients that need to hear it. As a result of this need, ships support a new AddSound method client side.

If you want to do something such as adding background radio chatter, this can easily be accomplished with the new AddSound method:

self:AddSound("Chatter", "vehicles/starviper/chatter/attack1.wav", { once = false, cooldown = 5 })

But this is boring, you only have one sound file! Luckily AddSound supports tables to.

self:AddSound("Chatter", { "vehicles/starviper/chatter/attack1.wav", "vehicles/starviper/chatter/formation2.wav", "vehicles/starviper/chatter/moving5.wav", "vehicles/starviper/chatter/rightaway.wav" }, { once = false, cooldown = 5 })

By passing a table instead of a string, a random path will automatically be chosen each time the sound is played.

Note: This method is best used for sounds you want to play on intervals or only once during the lifetime of the ship. If you need a more complex sound condition, please see the information about events.

WIP, will finish this post later.
Showing 1-6 of 6 entries