Mod Question Repository... Questions come in, answers go out - Page 49

Mod Question Repository... Questions come in, answers go out

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Locked
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Mod Question Repository... Questions come in, answers go out

Post by Master-Athmos »

Master-Athmos wrote:Can anyone give info on the way resurrection is handled:
What determines the time needed for the resurrection and what defines the amount of energy needed while doing so?
Does nobody have info on this? Currently it seems to me that the energy consumption during the resurrection is influenced by the unit's original e-costs for building. At least I get a very high e-drain when rezzing a carrier while only a fraction of that when rezzing a cruiser or battleship (with way higher metal costs / metal worth wrecks)...

I also didn't find anything valuable in the Wiki...
I'd have preferred a general, constant e-drain for rezzing in general no matter what you want to bring back to life...
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Mod Question Repository... Questions come in, answers go out

Post by Tobi »

Code: Select all

UseEnergy(ud->energyCost * resurrectSpeed / ud->buildTime * modInfo.resurrectEnergyCostFactor)
where ud is the UnitDef of the to-be-resurrected unit.
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Mod Question Repository... Questions come in, answers go out

Post by Master-Athmos »

Thanks! :-)
There is no simple way to change that formula from a mod's side is there?
I'd prefer a constant value multiplied by the resurrectspeed or as the resurrectEnergyCostFactor already is a constant value just kick all the unit specific values out of the equation...
LordMuffe
Posts: 286
Joined: 13 Mar 2005, 15:39

Re: Mod Question Repository... Questions come in, answers go out

Post by LordMuffe »

Some Questions here:

in cob/bos scripting,

is it possible to make a repair-station for planes with more than one landing pad, where each pad has its own animation ( like moving a crane to that position, each pad with its own crane and each repairing synchron ) ?

Is it possible to assign different unit-types to different landing-pads (Bombers to A, VTOl to B, etc) ?

Another problem:

Sometimes units get stuck in the construction-structure after its finished. But it don┬┤t happen every time and to different unit-types of various sizes. Only planes never get stuck.
The units are leaving after manually ordering the unit to move.

I don┬┤t know if that is the same problem, but often the units ignore the way-points set for the con-building.

I hope my questions are understandable and i would be very grateful for any hint or help.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

the getting stuck sounds like a bad foot print map. take a look at the wiki on fbi's and find the footprint section (or look at a mod/game with working ones)

The multiple air pad is used in many mods, but if you want to sort them out you'll need to make a lua script that detects what kind of unit is landing and then move that landing point to that section of the model for those categories.
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Mod Question Repository... Questions come in, answers go out

Post by Master-Athmos »

There currently is a bug in the new smooth mesh movement behaviour for gunship. It also can cause them not being able to land on air pads...

For the air pad problems: I don't think that special landing pads for special types are possible - at least not unless the hardcoded functionality that assigns the planes to go to the nearest pad gets extended by that. The animation stuff also might not be possible - at least I know of no COB command which could get an input as to which pad currently is used...
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

i meant detect the unit type maybe by cob id and then move the point it is already assigned to to that area. And if its full cancel the orders via lua.
LordMuffe
Posts: 286
Joined: 13 Mar 2005, 15:39

Re: Mod Question Repository... Questions come in, answers go out

Post by LordMuffe »

thank s for the input.

There was an error in the Yard-map for the fac, but it did not cause the problem. If it would not be so random, i would say its the scripts fault.

The thing with the different pads for different planes was just an idea, if its not easy to do with bos, I will not use it. But thats ok.

Thanks or the fast responses.
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Mod Question Repository... Questions come in, answers go out

Post by SanadaUjiosan »

So about a week ago I made a huge breakthrough with my project and learned how to make my units shoot multiple weapons using Lua. Hooray.

Part of that process, though, was taking the Signal and SetSignalMask parts out of the AimWeapon thread in the animation script. I was able to get all weapons to fire at once, but noticed spastic behavior, like continually returning to default orientation and then re-aiming between each shot. I didn't know what the Signals and all that meant till a few days ago, and I thought armed with that new knowledge I could fix this bug, because I figured the Signals were important just not absolutely crucial to the core function of firing. Apparently my knowledge wasn't enough, as the units still won't fire all weapons with Signals included.

So, my two big questions are, does the number assigned to a Signal mask matter?

And, how do I set up my multiple weapons firing with these signals?

Just to specify, my understanding of signals is that SetSignalMask sort of labels a function as such and such, and you use Signal to make that function stop. I've tried assigning a different number to the second weapon, but that didn't work either.

And to complete the ensemble, here is an example of how I currently have my multiple weapons script.

Code: Select all

	-- by KR
	
	--pieces
        local waist = piece "waist"

        local rightthigh = piece "rightthigh"
        local rightshin = piece "rightshin"
        local rightfoot = piece "rightfoot"

        local leftthigh = piece "leftthigh"
        local leftshin = piece "leftshin"
        local leftfoot = piece "leftfoot"

	local body = piece "body"

        local head = piece "head"

	local rightarm = piece "rightarm"
	local rightgun = piece "rightgun"
        local flare2 = piece "flare2"

	local leftarm = piece "leftarm"
	local leftgun = piece "leftgun"
	local flare1 = piece "flare1"


	--signals
	local SIG_AIM = 2
	local SIG_AIM_SEC = 3
	local walk_go = 4
	local walk_stop = 5
	
	function script.Create()
	       
	end

	local function walk()
		SetSignalMask(walk_go)
		while (true) do
	                Turn( leftshin, x_axis, -1, 2 )
	                Turn( leftthigh, x_axis, 1, 2 )
	               
	                Turn( rightshin, x_axis, 1, 2 )
	                Turn( rightthigh, x_axis, -1, 2 )
	               
	                WaitForTurn( leftshin, x_axis )
	                WaitForTurn( leftthigh, x_axis )
	                WaitForTurn( rightshin, x_axis )
	                WaitForTurn( rightthigh, x_axis )
	                Sleep(1)
	               
	                Turn( leftshin, x_axis, 1, 2 )
	                Turn( leftthigh, x_axis, -1, 2 )
	               
	                Turn( rightshin, x_axis, -1, 2 )
	                Turn( rightthigh, x_axis, 1, 2 )

	                WaitForTurn( leftshin, x_axis )
	                WaitForTurn( leftthigh, x_axis )
	                WaitForTurn( rightshin, x_axis )
	                WaitForTurn( rightthigh, x_axis )
	                Sleep(1)
	        end
	end

	local function stop_walk()
	        Signal(walk_go)
		Turn( leftshin, x_axis, 0, 2 )
		Turn( leftthigh, x_axis, 0, 2 )
	       
	        Turn( rightshin, x_axis, 0, 2 )
	        Turn( rightthigh, x_axis, 0, 2 )

	end
	
	function script.StartMoving()
	        StartThread(walk)
	end
	
	function script.StopMoving()
	        StartThread(stop_walk)
	end
	
	local function RestoreAfterDelay(unitID)
		Sleep(2500)
		Turn(body, y_axis, 0, math.rad(90))
        	Turn(leftarm, x_axis, 0, math.rad(50))
        	Turn(leftgun, x_axis, 0, math.rad(50))
        	Turn(rightarm, x_axis, 0, math.rad(50))
        	Turn(rightgun, x_axis, 0, math.rad(50))
	end

	function script.QueryWeapon1() return flare1 end

        function script.QueryWeapon2() return flare2 end
	
	function script.AimFromWeapon1() return body end

        function script.AimFromWeapon2() return body end
	
	function script.AimWeapon1( heading, pitch )
                Signal(SIG_AIM)
		SetSignalMask(SIG_AIM)
        	Turn(body, y_axis, heading, math.rad(90))
        	Turn(leftarm, x_axis, -0.75, math.rad(60))
                Turn(leftgun, x_axis, -0.85, math.rad(60))
        	WaitForTurn(body, y_axis)
        	WaitForTurn(leftarm, x_axis)
        	WaitForTurn(leftgun, x_axis)
		StartThread(RestoreAfterDelay)
		return true
	end

	function script.AimWeapon2( heading, pitch )
		Signal(SIG_AIM_SEC)
		SetSignalMask(SIG_AIM_SEC)
        	Turn(body, y_axis, heading, math.rad(90))
        	Turn(rightarm, x_axis, -0.75, math.rad(60))
                Turn(rightgun, x_axis, -0.85, math.rad(60))
        	WaitForTurn(body, y_axis)
        	WaitForTurn(rightarm, x_axis)
        	WaitForTurn(rightgun, x_axis)
		StartThread(RestoreAfterDelay)
		return true
	end
	
	function script.FireWeapon1()
	       Sleep(30)
	end

	function script.FireWeapon2()
	       Sleep(30)
	end
	
	function script.Killed(recentDamage, maxHealth)
		Sleep(30)
	end
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Mod Question Repository... Questions come in, answers go out

Post by Tobi »

The numbers are bitmasks. (hence signal mask)

You can assign any such bitmask to a thread using SetSignalMask.

On a call to Signal all threads for which the bitwise and of the number passed to Signal and the number passed to SetSignalMask for that thread are killed.

So you probably want to use different numbers for different weapons (as long as they are independent, i.e. not mounted on the same turret, at least) like this:

Code: Select all

   local SIG_AIM = 1
   local SIG_AIM_SEC = 2
   local walk_go = 4
   local walk_stop = 8  -- continue with 16, 32, 64, etc.
I am considering making the functions accept any kind of object as "name" for the thread but I did not make a final decision on this.
User avatar
KingRaptor
Zero-K Developer
Posts: 838
Joined: 14 Mar 2007, 03:44

Re: Mod Question Repository... Questions come in, answers go out

Post by KingRaptor »

Is it me or is LUS not actually using the MoveRate# callins?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Mod Question Repository... Questions come in, answers go out

Post by Tobi »

In LUS it's a single MoveRate call-in with a rate parameter.

http://springrts.com/wiki/Animation-LuaCallins
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Mod Question Repository... Questions come in, answers go out

Post by Gota »

http://pastebin.com/m3db5c17f
This gadget sets different values for turnradius for a specified set of units under certain conditions.

When one of the units,specifiedi n the script dies the game spews out an error.

http://pastebin.com/m75fd458c

how to fix?
Kloot
Spring Developer
Posts: 1867
Joined: 08 Oct 2006, 16:58

Re: Mod Question Repository... Questions come in, answers go out

Post by Kloot »

Code: Select all

function gadget:UnitDestroyed(unitID, unitDefID, team)
    if (fighter_types[unitDefID]) then
        fighters[unitID] = nil
    end
end
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Mod Question Repository... Questions come in, answers go out

Post by Gota »

Thx that helped.
It seems though that the script does not work for fight commands...
when the fighter is given an attack order he will get a big turnradius value making him fly further from its target before coming back to it,but,it does not seem to work for fight commands.
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Mod Question Repository... Questions come in, answers go out

Post by Gota »

redundant.
Last edited by Gota on 22 Feb 2010, 21:55, edited 1 time in total.
User avatar
bobthedinosaur
Blood & Steel Developer
Posts: 2702
Joined: 25 Aug 2004, 13:31

Re: Mod Question Repository... Questions come in, answers go out

Post by bobthedinosaur »

bump for gota.


edit:
nvm
User avatar
SanadaUjiosan
Conflict Terra Developer
Posts: 907
Joined: 21 Jan 2010, 06:21

Re: Mod Question Repository... Questions come in, answers go out

Post by SanadaUjiosan »

For the past number of hours, oksnoop2 and I worked on getting a unit in-game. He modeled and I textured a factory, with the intention of it being a "pop-up" factory. We wanted it to basically perform like the handful of "pop-up" turrets in the various *A games, but instead of it being a gun, it would be a factory. And, of course, I'm here because we couldn't get it to work.

Because I was working on his computer (and am now home) I can't supply things like scripts or infologs, but I can do my best to describe the problem. Looking at the *A game pop-up turrets, we saw and realized they are built in their "active" or "firing" position, so we positioned the objects to simulate this (large doors opened and the buildpad on "ground level".) Using a working factory animation lua, I started plugging in what I thought would do the trick. After several errors, I gave up and returned home.

A common error in the infolog between tests was something referring to 316, and a problem with "co_create." There's totally not 316 lines in that script, and nowhere do I have "co_create" in the script. Makes me think these are hidden problems, behind the script that I'm writing and tinkering with. Can anyone supply me with what these may mean?

I went ahead and took out all of the attempts at animation, and the factory worked perfectly fine, so it's not an issue with the part of the script dealing with the actual building. And like every factory in the *A games are little miracles of origami, what with their panels folding into each other and whatnot, so I know that animations associated with building is possible. I tried putting the StartThread(blah blah) in the Activate part of the script with the various "SetUnitValue(COB.YARD_OPEN, 1)" and all that, and it didn't work. Then I read the wiki and saw a command for StartBuilding, and tried using that, but it didn't work either. I even tried plugging in Signals, although I don't think they're really needed. I didn't try very hard with the signals, as I had no idea where they should really be and just sort of winged it.

So, any suggestions?
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: Mod Question Repository... Questions come in, answers go out

Post by Tobi »

Yes, get oksnoop2 to post the exact error messages. :regret:
User avatar
Gota
Posts: 7151
Joined: 11 Jan 2008, 16:55

Re: Mod Question Repository... Questions come in, answers go out

Post by Gota »

http://pastebin.com/m7973725c

This is the Custom Formations widget.
How can i stop it from working on air units?
Locked

Return to “Game Development Tutorials & Resources”