Jump to content

AOE Range Indicators


Recommended Posts

Hello everyone! Thanks for taking some time to possibly help me.
In my character mod, my character has an AOE ability, the range of which is represented with a Light with no falloff, which looks something like this at night: image.thumb.png.36352ab93606415f680a9446c19631e2.png

But during the day, it's barely visible, looking like this image.thumb.png.1023041363854a70b7d17212a84d53b5.png

Yes, it is on there. You can just barely see it.

Is there a way I could either

1. Make the light more intense, so you can see it in the day, or

2. Use the range indicators from something like the Ice Flingomatic to represent the range of the AOE.

Link to comment
Share on other sites

On 11/29/2020 at 8:41 PM, TheSkylarr said:

2. Use the range indicators from something like the Ice Flingomatic to represent the range of the AOE.

This interested me, so I took a look at the code. Turns out its managed by a component called "DeployHelper." The range indicator entity is not an existing prefab, it's created on the spot (and only on the client). I put the relevant code into its own prefab file and gave it a function so that you can attach it to any entity. Create a prefab file with the following code:

local assets =
{
    Asset("ANIM", "anim/firefighter_placement.zip"),
}

local prefabs = {}

local function LinkToEntity(inst, ent, scale)
	inst.entity:SetParent(ent.entity)
	inst.Transform:SetScale(scale, scale, scale)
end

local function fn()
    local inst = CreateEntity()

    inst.entity:AddTransform()
    inst.entity:AddAnimState()
    inst.entity:AddNetwork()

	inst.entity:SetCanSleep(false)
	inst.persists = false

	inst.AnimState:SetBank("firefighter_placement")
	inst.AnimState:SetBuild("firefighter_placement")
	inst.AnimState:PlayAnimation("idle")
	
	inst.AnimState:SetLightOverride(1)
	inst.AnimState:SetOrientation(ANIM_ORIENTATION.OnGround)
	inst.AnimState:SetLayer(LAYER_BACKGROUND)
	inst.AnimState:SetSortOrder(1)
	inst.AnimState:SetAddColour(0, .2, .5, 0)

	inst:AddTag("CLASSIFIED")
	inst:AddTag("NOCLICK")
	inst:AddTag("placer")

    inst.entity:SetPristine()

    if not TheWorld.ismastersim then
        return inst
    end

	inst.LinkToEntity = LinkToEntity

    return inst
end

return Prefab("aoerange", fn, assets, prefabs)

I named it "aoerange," but you can name it whatever you want. With the above prefab, you will be able to create the range indicator on the server and attach it to anything you want. Here is an example:

local function EnableAOEIndicator(inst, enable, scale)
	if inst.aoe_range ~= nil then
		inst.aoe_range:Remove()
		inst.aoe_range = nil
	end
	if enable then
		inst.aoe_range = SpawnPrefab("aoerange")
		inst.aoe_range:LinkToEntity(inst, scale)
	end
end

Keep in mind that since this is created on the server, it will be visible to everyone. It's possible to make it only visible to the player using the ability but it will require a bit of extra code. Also note that you will have to experiment with the scale a bit to match the range of your ability as there isn't a way to give it a specific radius.

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...