Page 1 of 1

0.82.7.1 to spring-83.0, something changed with AttachUnit?

Posted: 18 May 2013, 09:50
by knorke
I think something changed with Spring.UnitScript.AttachUnit and/or transport between spring 0.82.7.1 and spring-83.0
Anyone got an idea?
steps to reproduce:

download
http://springfiles.com/spring/games/spring-tanks
(version rc5.2) or rapid: springtanks:latest

start the mod on any map
press ESC to hide menu or disable the widget
do
/cheat
/give tplegocar
/give tpflag 1

drive to the flag with the car.

What happens in 0.82.7.1:

As you get near, the flag will attach itself on top of the car like this:
Image

This is because
gadgets\tp_gamelogic.lua

Code: Select all

blabla if unit is near flag then
env = Spring.UnitScript.GetScriptEnv(nearunitid)
if (env) then Spring.UnitScript.CallAsUnit(nearunitid,env.script.TransportPickup,flagid) end
scripts\tplegocar.lua

Code: Select all

function script.TransportPickup (passengerID)
...
		Spring.UnitScript.AttachUnit (flagattachpoint, passengerID)
...
end
What happens in 83.0 and later:
The flag does not get attached to the car.
If you put an Echo before the AttachUnit() one can see everything else works until there.

In newer spring versions, the units spawned by mod do not run their unitscripts because of wrong layer in gadget. There are also some wrong/too many lua base files. Not sure if that matters since units spawned with /give work, but in case there is svn with fixed version:
https://code.google.com/p/springtanks/


Was AttachUnit() made to check stricter what can load what?
These units should be able to load the flag though, wrt mass, size.
(AttachUnit should be able to attach anything to anything!)

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 12 Jun 2013, 11:27
by jK
your flag is a building for those cantBeTransported is default true.

edit: the bold one

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 13 Jun 2013, 00:33
by knorke
thanks :)
If AttachUnit() could bypass those checks, that would be useful if one wants untransportable units that should still sometimes attach to other units. For example carrying a "weapon" or melee units picking up each like in wrestling.

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 13 Jun 2013, 00:41
by CarRepairer
knorke wrote:If AttachUnit() could bypass those checks, that would be useful if one wants untransportable units that should still sometimes attach to other units. For example carrying a "weapon" or melee units picking up each like in wrestling.
Instead of a bypass (which would be a hidden behavior), better to have a finer control over which unit can transport which. Similarly I had hopes of that kind of control of which unit can repair which, based on category, but it doesn't seem likely to happen. http://springrts.com/phpbb/viewtopic.php?f=21&t=23397

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 13 Jun 2013, 00:43
by smoth
+1 Knorke's suggestion is legitimate

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 13 Jun 2013, 01:07
by knorke
Why is it hidden behaviour?
For units that the engine deems untransportable, the script.TransportPickup etc callins in LUS would never be called. (like now)

But if a gadget wants to attach one unit to another, it should be able to do so.
Similiar to how a unit with maxVelocity=0 can not move by engine, but gadget can still make it move with MoveCtrl functions.

But maybe Spring.UnitScript.AttachUnit is the wrong place for such attach function. Since it only takes one unitID as parameter, gadgets can not use it anyway.
Would it be better to have a Spring.AttachUnit (passengerID, transporterID, pieceNr) for gadgets?

Re: 0.82.7.1 to spring-83.0, something changed with AttachUn

Posted: 13 Jun 2013, 01:13
by CarRepairer
Oh, I see what you mean now.