Forged Alliance Forever Forged Alliance Forever Forums 2016-08-24T21:29:46+02:00 /feed.php?f=41&t=12968 2016-08-24T21:29:46+02:00 2016-08-24T21:29:46+02:00 /viewtopic.php?t=12968&p=133466#p133466 <![CDATA[Re: How to move soothsayer ambient]]>

As i see your radar got a Gattling Weapon ^^. Good luck with your projects ;)

Statistics: Posted by Franck75 — 24 Aug 2016, 21:29


]]>
2016-08-24T20:51:48+02:00 2016-08-24T20:51:48+02:00 /viewtopic.php?t=12968&p=133464#p133464 <![CDATA[Re: How to move soothsayer ambient]]>

Here is the right code.

Code:
# 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.

Statistics: Posted by RavenCurow — 24 Aug 2016, 20:51


]]>
2016-08-24T18:18:13+02:00 2016-08-24T18:18:13+02:00 /viewtopic.php?t=12968&p=133449#p133449 <![CDATA[Re: How to move soothsayer ambient]]>
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:
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).

Statistics: Posted by Franck75 — 24 Aug 2016, 18:18


]]>
2016-08-24T12:02:09+02:00 2016-08-24T12:02:09+02:00 /viewtopic.php?t=12968&p=133426#p133426 <![CDATA[Re: How to move soothsayer ambient]]>
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:
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.

Statistics: Posted by RavenCurow — 24 Aug 2016, 12:02


]]>
2016-08-23T22:44:05+02:00 2016-08-23T22:44:05+02:00 /viewtopic.php?t=12968&p=133394#p133394 <![CDATA[Re: How to move soothsayer ambient]]> Statistics: Posted by RavenCurow — 23 Aug 2016, 22:44


]]>
2016-08-23T14:14:31+02:00 2016-08-23T14:14:31+02:00 /viewtopic.php?t=12968&p=133352#p133352 <![CDATA[Re: How to move soothsayer ambient]]>
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.

Statistics: Posted by Franck75 — 23 Aug 2016, 14:14


]]>
2016-08-23T08:17:19+02:00 2016-08-23T08:17:19+02:00 /viewtopic.php?t=12968&p=133335#p133335 <![CDATA[Re: How to move soothsayer ambient]]> Statistics: Posted by RavenCurow — 23 Aug 2016, 08:17


]]>
2016-08-22T14:13:27+02:00 2016-08-22T14:13:27+02:00 /viewtopic.php?t=12968&p=133274#p133274 <![CDATA[Re: How to move soothsayer ambient]]>
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.

Statistics: Posted by Franck75 — 22 Aug 2016, 14:13


]]>
2016-08-22T10:27:03+02:00 2016-08-22T10:27:03+02:00 /viewtopic.php?t=12968&p=133265#p133265 <![CDATA[How to move soothsayer ambient]]> Statistics: Posted by RavenCurow — 22 Aug 2016, 10:27


]]>