Page 1 of 1
Request, scripts creating units
Posted: 22 Oct 2006, 13:15
by PauloMorfeo
I bereby formaly request for the possibility for a script to create a unit, as in, make it spawn out of no where.
Imagine a coocoon spawning a unit from inside, after some time, like the Zerg in Starcrap. Many more usefull uses, too. It is eagerly needed for a thing in TLL...
Posted: 22 Oct 2006, 19:20
by KDR_11k
There's currently no way to store a unit type in a variable so I don't think it's possible to implement such a function as there's no way to pass it the unit type you wish to create.
Posted: 23 Oct 2006, 13:19
by PauloMorfeo
There must be some easy way that can be implemented...
After all, a building makes units. I don't understand the scripting system well but i'm imagining a function of the type:
Code: Select all
CreateUnit (UnitName, PosX, PosY, PosZ);
Posted: 23 Oct 2006, 16:10
by KDR_11k
Buildings don't create the units through script, the engine sees that the building is a factory and when a build order is placed the building gets told to open, then the unit is created and the building starts nanolathing it into existence.
Posted: 23 Oct 2006, 21:32
by Guessmyname
You could use the Unit ID
Posted: 24 Oct 2006, 07:57
by KDR_11k
Units don't have IDs in Spring.
Posted: 24 Oct 2006, 12:11
by PauloMorfeo
If code-wise people would give me a hand with a few things, i would give it a go at trying to implement that.
- I need to know where is the code responsible for «doing» what the scripts have.
- I need to know where i can find the code that is run whenever we use the cheat ".give unitnumber unitname".
Posted: 24 Oct 2006, 16:58
by KDR_11k
Scripts are handled by the COB interpreter, there should be a few files with COB in the name.
Posted: 24 Oct 2006, 17:14
by rattle
Posted: 25 Oct 2006, 09:55
by Argh
You could build a unit at the same location and then have the "factory" destroy itself, to create "cocoons". Now that units can destroy themselves, a lot of things like that are possible.
Posted: 25 Oct 2006, 11:30
by rattle
You mean like building a human as building (who offers a variety of units to build). Once the first unit has finished building, the building detonates itself (if that's possible; otherwise the unit has to) leaving behind a cocoon corpse model.
Posted: 25 Oct 2006, 19:11
by PauloMorfeo
Ok, that was pretty dumb of me... I forgot that there is a middle program between the scripts and the COB interpreter, the COB compiler. I was having some trouble trying to understand the COB engine in Spring when i remembered it, i had to also mess with a COB compiler, like Scriptor, to make it also compile the new function, not just adjust the COB interpreter.
Was it not for that, it would have been a good effort. After all, the code to create units is already there (".cheat", ".give ArmCA"). But the fact is that that is over my league and i was really dumb forgeting about the compiler...
Bah!
Posted: 01 Nov 2006, 18:22
by PauloMorfeo
I seem to have found a way to, somewhat easily, do that.
In the thread about emiting SFX through scripts:
http://taspring.clan-sy.com/phpbb/viewt ... 608#139608
PauloMorfeo wrote:Could that system be adapted to:
Code: Select all
[SFXTypes]
{
explosiongenerator0=custom:EXPLOSION1;
explosiongenerator1=custom:EXPLOSION2;
explosiongenerator2=custom:CreateZerglings;
}
Code: Select all
[CreateZerglings]
{
[CreateUnit]
{
class = CCreateUnit;
[properties]
{
dir = dir;
Distance=0;
Unit=ScZergling;
}
water=1;
air=1;
underwater=1;
ground=1;
count=2;
}
}
Making it call, into the position defined by the custom explosion generator script, the "cheat" «.give count zergling».
That would allow us to create units by scripts.
And shouldn't be very hard to implement. Code for unit creation is already there of when we ".cheat" + ".give ArmCa"...
Please, someone at least say that it has been seen, even if it is not going to be coded in a recent future.
Posted: 01 Nov 2006, 19:03
by rattle
Abusing the particle generator to spawn stuff?... I don't know...
Posted: 02 Nov 2006, 02:00
by MadRat
You'd almost need a DeathType variable, a default of zero for spawning a wreckage whereas you could otherwise spawn off another unit. Or maybe you could spawn off multiple units within a building's footprint, like in C&C. I can see it now, a peewee dangling from a parachute pops out of every ARM aircraft destroyed mid-air.
Posted: 02 Nov 2006, 02:02
by Neddie
That ability would be best implemented in Battletech. I mean, in the game universe, MechWarriors commonly eject from their Mechs... why not have an infantry unit up to start the fight up toe to toe?
Posted: 02 Nov 2006, 02:05
by Argh
This is all possible, however... it'd require reserving yet another bunch of IDs for "FX" in memory, or (a more elegant solution) we could write up a new bytecode to be watched (a "Create"), and then have the COB interpreter check for that bytecode and execute the appropriate instructions. It'd just require replacement of one file with Scriptor, and a very minor change in the COB interpreter.
However, from there, the implementation might be a bit difficult. While I see no reason you couldn't just spawn it right at the point... you'd need to make sure it never spawned underground, etc.
Personally, this is one of those things that makes me more sure than ever that the OSRTS project is necessary.
Posted: 02 Nov 2006, 04:11
by MadRat
Wouldn't it be more efficient to be a spinoff of the death sequence from the unit and not from the cob? I'd have to assume the scripted death animation is only called after the corpse is already revealed, since the corpses seem to spring up at that time. You could drop a newly spawned unit down instead of a corpse.
Posted: 04 Nov 2006, 20:12
by KDR_11k
The corpse is spawned and the unit removed once the function Killed() returns. The cob actively influences the death.