Forged Alliance Forever Forged Alliance Forever Forums 2015-03-15T11:52:47+02:00 /feed.php?f=41&t=9574 2015-03-15T11:52:47+02:00 2015-03-15T11:52:47+02:00 /viewtopic.php?t=9574&p=96119#p96119 <![CDATA[Re: Need help: SimSync, GUI, Unlocking things]]>
Some good info above regarding the Sync table. :)

to reverse it and send info back to the sim, you would use simcallbacks the only differance here is that from the userlayer you are only sending info back from the focus army (player army) and not to all armies like when using sim sync. you can use GetFocusArmy() in the user layer to get your armyindex.

you say you want to use a new resource?

if so, why not set up the resource in the sim using the Aibrain to run a thread that updates used/produced of said resource every second and update the values in the ui, just set it up like the energy resource, you can duplicate alot of the energy core code but changing the resource type. its actually not that difficult, ive actually got some core code added already in my DMS mod to add new resource, i have actually already added base code for black matter which i want exp to use in future.

to use the AIbrain method, you would have to add the resource producing/using unit to a table and have the aibrain loop those units and get then set the values for the ui.
you can then call a function in the unit(s) script to trigger when no resource or resource low/full/depleted etc.

there is a learning curve, but i think you can do it.. :)

good job so far.. welcome to supcom modding!

Domino

Statistics: Posted by Domino — 15 Mar 2015, 11:52


]]>
2015-03-14T00:34:16+02:00 2015-03-14T00:34:16+02:00 /viewtopic.php?t=9574&p=96059#p96059 <![CDATA[Re: Need help: SimSync, GUI, Unlocking things]]>

I got nearly everything working now: I have separate points for each player and each player got it's own score in the panel. (Un-)locking units works as well.
There's one issue left though:

How can I sync into the other direction, from GUI to Sim?
Say, when the player clicks on a certain GUI element I'd like to update a few variables which I have stor'ed in the SIM. How would I do that?

Thanks,

~Locutus

Statistics: Posted by Locutus — 14 Mar 2015, 00:34


]]>
2015-03-10T23:00:22+02:00 2015-03-10T23:00:22+02:00 /viewtopic.php?t=9574&p=95876#p95876 <![CDATA[Re: Need help: SimSync, GUI, Unlocking things]]>
Myxir wrote:
you can pass information from sim to ui by using UserSync.lua

as example, use
Code:
Sync.researchpoints = {0 = 13, 1 = 342, 2 = 23, 3 = 98}

somewhere in the code, Sync is a global var and you don't need to import it

then, hook UserSync.lua:
Code:
local baseOnSync = OnSync
function OnSync()
   baseOnSync()

   if Sync.researchpoints then
      import('/mods/researchMod/modules/myUi.lua').updateUi(Sync.researchpoints)
   end
end


Thanks, got that working!
Whenever the research station is constructed points do nicely increase :D


Myxir wrote:
(in this case, you'd send all data to every player, but you get the idea)

This is the part were I'm stuck. How does the GUI even differentiate between players?
Currently I got this:
--code of the research station
Code:
OnCreate = function(self)
      TWallStructureUnit.OnCreate(self)
         print('RM: A research station has been built')
         self:ForkThread(self.GenerateResearchThread)   
    end,
   
   GenerateResearchThread = function(self)
      while true do
         local army = self:GetArmy()
                     
         if not Sync.ResearchPoints then
            Sync.ResearchPoints = {Army = army, ResearchPoints1 = 3}
         end
         WaitSeconds(1.00)
         end
   end,


--UI Code
Code:
function UpdateScores(ResearchPoints)   
   if not ResearchPoints then
      return   
   end
   local rsp = ResearchPoints.ResearchPoints1
   research_points_1 = research_points_1 + rsp
   if research_points_1 >= research_points_1_max then
      research_points_1 = research_points_1 - research_points_1_max
      research_points_2 = research_points_2 + 1
      treePointView.Group.ResearchPoints2:SetText(research_points_2)
   end
   treePointView.Group.ResearchPoints1:SetText(LOCF('%s / %s', research_points_1, research_points_1_max))
end

No idea how I could display individual scores for the players...


Myxir wrote:
unsure about this, i suggest to take a look at some blackops/extremewars code, they might do stuff like that

Thanks, I'll take a look! :D

Statistics: Posted by Locutus — 10 Mar 2015, 23:00


]]>
2015-03-10T19:30:29+02:00 2015-03-10T19:30:29+02:00 /viewtopic.php?t=9574&p=95843#p95843 <![CDATA[Re: Need help: SimSync, GUI, Unlocking things]]>
Locutus wrote:
1) I'd need a rough understand on how UserSync and SimSync work. Taking a look at the source files wasn't really helpful to me, there's too much I don't understand yet.
Or would it be easier, instead of putting a function in the building script itself, to have a global script which counts all research stations on the map and calculates the point income based on that? If so, where would I start?


you can pass information from sim to ui by using UserSync.lua

as example, use
Code:
Sync.researchpoints = {0 = 13, 1 = 342, 2 = 23, 3 = 98}

somewhere in the code, Sync is a global var and you don't need to import it

then, hook UserSync.lua:
Code:
local baseOnSync = OnSync
function OnSync()
   baseOnSync()

   if Sync.researchpoints then
      import('/mods/researchMod/modules/myUi.lua').updateUi(Sync.researchpoints)
   end
end

(in this case, you'd send all data to every player, but you get the idea)


Locutus wrote:
2) I somehow need to count the points for each player separately. Is it correct that "army" is the word I need to look for in the scripts?
Are there simple mods you could suggest as learning examples?


you can try something like this in the sim code:
Code:
for army, brain in ArmyBrains do
   myPointTable[army] = hisResearchPoints
end
Sync.researchpoints = myPointTable




Locutus wrote:
3) In the campaign new units get unlocked all the time. I haven't really looked for it yet but I think that should work in multiplayer too, right? Is it also possible to unlock new abilities? I believe a cheaty solution would be to lock the old unit and unlock a new one in the factory but would it be also possible for all units that are already on the field?

unsure about this, i suggest to take a look at some blackops/extremewars code, they might do stuff like that

Statistics: Posted by Myxir — 10 Mar 2015, 19:30


]]>
2015-03-10T19:09:24+02:00 2015-03-10T19:09:24+02:00 /viewtopic.php?t=9574&p=95840#p95840 <![CDATA[Need help: SimSync, GUI, Unlocking things]]>
a few days ago I started modding FA and I already ran into a bunch of problems I can't solve.
I'm not new to modding itself but I'm not familiar with how FA works, so please go easy on me.
I'm currently working on the basics to get a new resource - research points - into the game. Somewhat similar to SC2, I'd like a research station to produce this new resource. I managed to get some ugly UI elements into the game which display the current points and offer the possibility to open a new window which should be used to unlock tech.
The major problem I am facing right now is how UI and Sim are connected. Without really knowing what I'm doing I managed to slap some code together so that every time a player builds a wall a number gets incremented in my GUI. So that worked in a way but I don't really understand what I am doing.
I figured that Domino is for SupCom what Zerted is for SWBF2 and took a look at his mods. The CTF mode is quite close to what I need (I think) but boy, no idea whats going on there. Without an IT background I have a hard time understanding anything from those scripts. Unfortunately the forums.gaspowered site seems to be offline and Google cache isn't really helpful...

Could someone help me understand the basics?

1) I'd need a rough understand on how UserSync and SimSync work. Taking a look at the source files wasn't really helpful to me, there's too much I don't understand yet.
Or would it be easier, instead of putting a function in the building script itself, to have a global script which counts all research stations on the map and calculates the point income based on that? If so, where would I start?

2) I somehow need to count the points for each player separately. Is it correct that "army" is the word I need to look for in the scripts?
Are there simple mods you could suggest as learning examples?

3) In the campaign new units get unlocked all the time. I haven't really looked for it yet but I think that should work in multiplayer too, right? Is it also possible to unlock new abilities? I believe a cheaty solution would be to lock the old unit and unlock a new one in the factory but would it be also possible for all units that are already on the field?

Thanks,

Locutus

Statistics: Posted by Locutus — 10 Mar 2015, 19:09


]]>