How to move soothsayer ambient

Everything about mods can be found here.

Moderator: Morax

How to move soothsayer ambient

Postby RavenCurow » 22 Aug 2016, 10:27

For a mod I'm working on I've made a hydrocarbon perimeter monitoring building and added the soothsayer ambient effect from the cybran building. It looks good, but for some reason its not centered on the building. Is there a way to center the effect in the script? Much obliged for any insight anyone may have.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: How to move soothsayer ambient

Postby Franck75 » 22 Aug 2016, 14:13

Hi Raven, one way to fix the emitter effect position is to make a copy of the blueprint effect in your mod directory and adjust the X, Y, Z position in the bp. It may be a little painful to find the active params as only just some of them are active.

Also, i think there may be a way to make it on the fly without bp editing with the function Effect:OffsetEmitter(x,y,z) but i never tried it before.

Hope this will help you.
Franck75
Crusader
 
Posts: 13
Joined: 22 Aug 2016, 13:56
Has liked: 2 times
Been liked: 0 time
FAF User Name: Franck

Re: How to move soothsayer ambient

Postby RavenCurow » 23 Aug 2016, 08:17

Thank you Franck75 your information has proven invaluable. Unfortunately I now have another problem. Applying the script works if I do a quick summon in test with alt + F2, but if I build it actually on the hydrocarbon the effect returns to default. I'm not sure what to do now.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: How to move soothsayer ambient

Postby Franck75 » 23 Aug 2016, 14:14

You are welcome.

Can you give more information on your script ? Did you mod from an existing building with your own copy, create it from scratch or did you just edit an existing building ?

When you say that the effect returns to default, you mean that :
1. it stops ?
2. it never works on unit creation ?
3. it stacks with the original pre modded effect ?

If the problem is 1, you can edit the effect bp and set 'Lifetime = -1.00' to give a permanent effect.

If the problem is 2, you need to catch your effect by hooking your unit's lua file. Check the function 'on create'. Add your effect here : CreateAttachedEmitter (unit, -1, army, 'your bpeffect path')

If the problem is 3, and if you don't want that your effect would stack with the older one : it takes a little more time as you need to find where the original lua bp effect is. If you use Notepad++ as your editor, you can search the bp effect name to find it. Then you can just hook and change for your bp.

Good luck.
Franck75
Crusader
 
Posts: 13
Joined: 22 Aug 2016, 13:56
Has liked: 2 times
Been liked: 0 time
FAF User Name: Franck

Re: How to move soothsayer ambient

Postby RavenCurow » 23 Aug 2016, 22:44

No what I mean is that if I spawn it the effect moves to where I want it; however, if I build it like normal then the effect returns to its original offset position as if its ignoring my script altogether. I will paste my script tomorrow to give more information as I have to head to work now. I'm also modding a Nomad building for offline FA so it may be another whole can of worms. Thanks for your help.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: How to move soothsayer ambient

Postby RavenCurow » 24 Aug 2016, 12:02

Okay so for a little more background into what I'm doing. I have a mod that I've been piecing together for some time now that adds in all of the unused civilian buildings from the supreme commander campaign for multiplayer. However, I don't want them to just be eye candy and useless so I've made them do things. After doing that I've integrated the nomads into my offline FA as thats the only way to play them until a fix for them is found.

So digging through the code I found a Nomad Civilian building that was unfinished. As in it has a model and stuff, but no mesh textures. So I stuck some textures on it and turned it into a perimeter defense building built on a hydrocarbon.

Here is my code.

Code: Select all
local NShieldStructureUnit = import('/lua/nomadunits.lua').NShieldStructureUnit
local NomadEffectUtil = import('/lua/nomadeffectutilities.lua')


INB1162 = Class(NShieldStructureUnit) {
   
    CreateBuildEffects = function( self, unitBeingBuilt, order )
            NomadEffectUtil.CreateRepairBuildBeams( self, unitBeingBuilt, self:GetBlueprint().General.BuildBones.BuildEffectBones, self.BuildEffectsBag )
        end,
       
    CreateBuildEffects = function( self, unitBeingBuilt, order )
            NomadEffectUtil.CreateNomadBuildSliceBeams( self, unitBeingBuilt, self:GetBlueprint().General.BuildBones.BuildEffectBones, self.BuildEffectsBag )      
    end,
   
   

    CreateReclaimEffects = function( self, target )
        NomadEffectUtil.PlayNomadReclaimEffects( self, target, self:GetBlueprint().General.BuildBones.BuildEffectBones or {0,}, self.ReclaimEffectsBag )
    end,

    CreateReclaimEndEffects = function( self, target )
        NomadEffectUtil.PlayNomadReclaimEndEffects( self, target, self.ReclaimEffectsBag )
    end,
}

TypeClass = INB1162



Strangely the code you gave me worked for other buildings that I've made that do the same thing, but for this one building inparticular it seems to have no effect. When built normally the soothsayer ambient will not resize and will not offset as I've coded. I'm stumped.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: How to move soothsayer ambient

Postby Franck75 » 24 Aug 2016, 18:18

Hi RavenCurow,

It seems that this code is about build effects like factories or engies. Not the effects on the building itself as a permanent state. So theses events are never called in your kind of building. But i maybe wrong ?

If you want it simple, if you want to add your effect, i need to catch it at some event. For example, at unit 'on create' on your INB1162 lua script.

If you want it more 'FA like architectural', you can use the autoeffect template system used in FA. So you need to follow the structure Entity.lua -> Unit.lua -> defautsunits.lua -> factionunits.lua -> Yourunitscript.lua and the effects lua files to investigate where the effect is applied. I never did. But if you have some time.


For now, unless you want to assimilate the full effect template system of FA, you may just find or add a OnCreate function in your unit script :

Code: Select all
OnCreate = function(self)
  CreateAttachedEmitter (self, 0, self:GetArmy(), 'your bpeffect path')
end,


So the effect starts at the unit creation and stays until it is destroyed.

You may wanna call the effect at some different event as 'OnActive'... if your building has different states...you just have to take a look at the unit.lua to catch the function event and bring the function at your unit script (it's possible because each unit own script is a sub class from unit.lua).
Franck75
Crusader
 
Posts: 13
Joined: 22 Aug 2016, 13:56
Has liked: 2 times
Been liked: 0 time
FAF User Name: Franck

Re: How to move soothsayer ambient

Postby RavenCurow » 24 Aug 2016, 20:51

I apologize. I posted the wrong script this morning. I was tired and didn't realize I didn't open the right unit lol.


Here is the right code.

Code: Select all
# civilian structure with gun

local AddLights = import('/lua/nomadutils.lua').AddLights
local NRadarUnit = import('/lua/nomadunits.lua').NRadarUnit
local GattlingWeapon1 = import('/lua/nomadweapons.lua').GattlingWeapon1
local VizMarker = import('/lua/sim/VizMarker.lua').VizMarker
local CSoothSayerAmbient = import('/lua/EffectTemplates.lua').CSoothSayerAmbient

NRadarUnit = AddLights(NRadarUnit)

INB9001 = Class(NRadarUnit) {
    Weapons = {
        MainGun = Class(GattlingWeapon1) {
          Rotates = false,
      },
    },
    LightBones = { {'Light1', 'Light2', }, {}, {}, {'Light3', 'Light4', }, },
   
    IntelEffects = {
        {
            Bones = { {'Light1', 'Light2', }, {}, {}, {'Light3', 'Light4', }, },
            Offset = { 0, 0, 0, },
            Type = 'Jammer01',
        },
    },
   
    OnStopBeingBuilt = function(self)
        NRadarUnit.OnStopBeingBuilt(self)
        ChangeState( self, self.ExpandingVision )
        self.ExpandingVisionDisableCount = 0
       
       
        if self.OmniEffectsBag then
            for k, v in self.OmniEffectsBag do
                v:Destroy()
            end
        end
      self.OmniEffectsBag = {}
      
        for k, v in CSoothSayerAmbient do
            table.insert( self.OmniEffectsBag, CreateAttachedEmitter(self, 'INB9001', self:GetArmy(), v):OffsetEmitter(0, 2.5, -1):ScaleEmitter(0.2) )
        end       
    end,
   
    OnKilled = function(self, instigator, type, overkillRatio)
        local curRadius = self:GetIntelRadius('vision')
        local position = self:GetPosition()
        local army = self:GetAIBrain():GetArmyIndex()
        NRadarUnit.OnKilled(self, instigator, type, overkillRatio)
        local spec = {
            X = position[1],
            Z = position[3],
            Radius = curRadius,
            LifeTime = -1,
            Army = army,
        }
        local vizEnt = VizMarker(spec)
        vizEnt.DeathThread = ForkThread(self.VisibleEntityDeathThread, vizEnt, curRadius)
    end,
   
    VisibleEntityDeathThread = function(entity, curRadius)
        local lifetime = 0
        while lifetime < 30 do
            if curRadius > 1 then
                curRadius = curRadius - 1
                if curRadius < 1 then
                    curRadius = 1
                end
                entity:SetIntelRadius('vision', curRadius)
            end
            lifetime = lifetime + 2
            WaitSeconds(0.1)
        end
        entity:Destroy()
    end,

    OnIntelEnabled = function(self)
        self.ExpandingVisionDisableCount = self.ExpandingVisionDisableCount - 1
        if self.ExpandingVisionDisableCount == 0 then
            if self.OmniEffectsBag then
                for k, v in self.OmniEffectsBag do
                    v:Destroy()
                end
              self.OmniEffectsBag = {}
          end
            for k, v in CSoothSayerAmbient do
                table.insert( self.OmniEffectsBag, CreateAttachedEmitter(self, 'INB9001', self:GetArmy(), v) )
            end                    
            ChangeState( self, self.ExpandingVision )
        end
    end,

    OnIntelDisabled = function(self)
        self.ExpandingVisionDisableCount = self.ExpandingVisionDisableCount + 1
        if self.ExpandingVisionDisableCount == 1 then
            if self.OmniEffectsBag then
                for k, v in self.OmniEffectsBag do
                    v:Destroy()
                end
              self.OmniEffectsBag = {}
          end
            ChangeState( self, self.ContractingVision )
        end
    end,
   
    ExpandingVision = State {
        Main = function(self)
            WaitSeconds(0.1)
            while true do
                if self:GetResourceConsumed() ~= 1 then
                    self.ExpandingVisionEnergyCheck = true
                    self:OnIntelDisabled()
                end
                local curRadius = self:GetIntelRadius('vision')
                local targetRadius = self:GetBlueprint().Intel.MaxVisionRadius
                if curRadius < targetRadius then
                    curRadius = curRadius + 1
                    if curRadius >= targetRadius then
                        self:SetIntelRadius('vision', targetRadius)
                    else
                        self:SetIntelRadius('vision', curRadius)
                    end
                end
                WaitSeconds(0.2)
            end
        end,
    },
   
    ContractingVision = State {
        Main = function(self)
            while true do
                if self:GetResourceConsumed() == 1 then
                    if self.ExpandingVisionEnergyCheck then
                        self:OnIntelEnabled()
                    else
                        self:OnIntelDisabled()
                        self.ExpandingVisionEnergyCheck = true
                    end
                end
                local curRadius = self:GetIntelRadius('vision')
                local targetRadius = self:GetBlueprint().Intel.MinVisionRadius
                if curRadius > targetRadius then
                    curRadius = curRadius - 1
                    if curRadius <= targetRadius then
                        self:SetIntelRadius('vision', targetRadius)
                    else
                        self:SetIntelRadius('vision', curRadius)
                    end
                end
                WaitSeconds(0.2)
            end
        end,
    },
}

TypeClass = INB9001


EDIT: Looking at my code here again I've noticed that my effects line for the corrected offset is not the same in my OnStopBeingBuilt line as it is in my OnIntelEnabled line. The latter may be overwriting the former lol.

EDIT: That was the problem. Thank you for your time and help my friend. I guess its a good idea to take a break for looking at a project now and then to get a better perspective on your troubles.
RavenCurow
Avatar-of-War
 
Posts: 98
Joined: 30 Oct 2014, 01:17
Has liked: 1 time
Been liked: 14 times
FAF User Name: RavenCurow

Re: How to move soothsayer ambient

Postby Franck75 » 24 Aug 2016, 21:29

Yw,


As i see your radar got a Gattling Weapon ^^. Good luck with your projects ;)
Franck75
Crusader
 
Posts: 13
Joined: 22 Aug 2016, 13:56
Has liked: 2 times
Been liked: 0 time
FAF User Name: Franck


Return to Mods & Tools

Who is online

Users browsing this forum: No registered users and 1 guest