Applying a status
Applying statuses to characters is very similar to applying abilities.
To apply your status to a character in WCS you need to instantiate the status class providing a Character Class Instance
.
If you want to get the Character Class Instance
from a model its applied to you can use a special static method provided by WCS:
Character.GetCharacterFromInstance()
.
Let's make some ability give us a speed boost upon using:
- TypeScript
- Luau
import { Skill, SkillDecorator } from "@rbxts/wcs";
import { SpeedBoost } from "shared/statusEffects/speedBoost";
@SkillDecorator
export class Dash extends Skill {
public OnStartServer() {
const speedBoost = new SpeedBoost(this.Character);
speedBoost.Start(5);
}
}
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local WCS = require(ReplicatedStorage.WCS)
local SpeedBoost = require(ReplicatedStorage.StatusEffects.SpeedBoost)
local Dash = WCS.RegisterSkill("Dash")
function Dash:OnStartServer()
local speedBoost = SpeedBoost.new(self.Character)
speedBoost:Start(5)
end
return Dash
You can safely instantiate status effects on client, but they will not be replicated and will only be visible to client character apis.
You can invoke Start()
without providing a time limit, but you will have to call Stop()
manually.
To prevent memory leaks WCS calls Destroy()
on a status effects automatically when it ends.
You can set DestroyOnEnd
to false inside OnConstructServer()
to change that behavior, but you will have to
call Destroy()
manually.