Force Power

Description

This page belongs to the force power registration structure when creating your own force powers in the lua/wos/advswl/forcepowers folder of the addon.

The syntax is an expanded version of Robotboy's original addon to be more modular. All properties are always registered within the forcepower and accessible at any time, but only select properties are networked.

Parameters

name [string]

The name of the force power.


icon [string]

The characters that will be used for quick reference if using Hybrid or Classic force power HUD settings.

Can be any sequence of characters, but will show nothing if blank or not defined.

image [string]

The path of the material or png that will be used for the force power in all related menus and HUDs.

Will only show letter icon if not defined
All paths are relative to the materials folder by default, so don't include that part.

description [string]

The description of the force power that will appear in the force power selection menu or the selection of Hybrid or Classic force power HUD settings.

Defaults to "No Description" if not defined.

help [string]

The help text on how to use the force power that will appear in the force power selection menu when you right click on it.

This will do nothing if not defined.

cooldown [float]

The amount of time that a player must wait before casting this power again.

Will default to 0 (no cooldowns) if not defined
This property will do nothing if an action or think function attached to this force power does not return true at some point.

action [function]

The function that activates when you press your alternate fire button. The only argument is the weapon (self) and it is only called on the SERVER

Example

A simple force power that heals the current owner when used

action = function( self )     local owner = self.Owner     if not IsValid( owner ) then return end     if self:GetForce() < 30 then return end     self.Owner:SetHealth( math.min( self.Owner:Health() + 10, self.Owner:GetMaxHealth() ) )     self:AddForce( -30 )     return trueend,
Returning true in this function will activate cooldowns for this force power, if any is defined

think [function]

The function that activates when you have this force power selected. The only argument is the weapon (self) and it is only called on the SERVER

Example

Another simple force power that adds health if below 50% current health on cooldown. The force power is on cooldown for x seconds only when healh was added below 50% max health

think = function( self )     local owner = self.Owner     if not IsValid( owner ) then return end     if self.Owner:Health() >= self.Owner:GetMaxHealth()*0.5 then return end     self.Owner:SetHealth( math.min( self.Owner:Health() + 30, self.Owner:GetMaxHealth() ) )     return trueend,
Returning true in this function will activate cooldowns for this force power, if any is defined
This function runs every thought of the weapon, so avoid complicated logic
wikOS powered By wiltOS Technologies