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

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
thedude
Posts: 66
Joined: 21 Aug 2009, 12:47

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

Post by thedude »

Sorry but I don't get it. In the wiki (http://springrts.com/wiki/Lua_CMDs) there is this example:

Spring.GiveOrderToUnit(unitID,
CMD.INSERT,
{-1,CMD.ATTACK,CMD.OPT_SHIFT,unitID2},
{"alt"}
);

Because I have to use the build queue of my factory I have to use "CMD.OPT_CONTROL" instead of "CMD.OPT_SHIFT" (as the wiki says "options.CONTROL -> use the build queue for factories"). But what have I to use insead of CMD.ATTACK? Cause there is no command like "CMD.BUILD"?
If I wouldn't use "CMD.OPT_CONTROL" would this command go to the queue of the unit which is built by my factory, right?
SirMaverick
Posts: 834
Joined: 19 May 2009, 21:10

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

Post by SirMaverick »

thedude wrote:But what have I to use insead of CMD.ATTACK? Cause there is no command like "CMD.BUILD"?
For build commands the negative unitdefid is used.
thedude
Posts: 66
Joined: 21 Aug 2009, 12:47

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

Post by thedude »

The goog thing is I don't get errors but the factory still does not build the unit.
What I use:
Spring.GiveOrderToUnit(factoryID, CMD.INSERT,{-1,-unitdefid,CMD.OPT_CONTROL},{});

The "-1" puts my command at the end of the build queue. What have I to use to put the command on the first position ("0" or "1") ?
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

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

Post by KDR_11k »

I think you have to put the CMD.OPT_CONTROL into the CMD.INSERT too.
thedude
Posts: 66
Joined: 21 Aug 2009, 12:47

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

Post by thedude »

Nope,
Spring.GiveOrderToUnit(factoryID, CMD.INSERT,{-1,-unitdefid,CMD.OPT_CONTROL},{CMD.OPT_CONTROL});

doesn't work for me.
After trying a whole week to make the command work I feel like I already tried all possibilities. (But not the right one)
User avatar
AF
AI Developer
Posts: 20687
Joined: 14 Sep 2004, 11:32

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

Post by AF »

The command to build a Peewee has the ID -(peewee ID)

So if the peewee unitdef is 46, the command ID is -46
thedude
Posts: 66
Joined: 21 Aug 2009, 12:47

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

Post by thedude »

Thanks dude but SirMaverick already told :wink:
SirMaverick wrote: For build commands the negative unitdefid is used.
Spring.GiveOrderToUnit(factoryID, CMD.INSERT,{-1,-unitdefid,CMD.OPT_CONTROL},{CMD.OPT_CONTROL});
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

I am trying to make a nuclear missile submarine. Is there any way to make a submerged unit fire a missile? I have built a test unit and when its submerged (i use the waterline string in the unit fbi) it won't fire. When I reset the waterline, so it behaves like a ship, it will fire nukes normally. I looked at few old TA units examples, but that didn't help...

Any ideas?

Thanks!
User avatar
hoijui
Former Engine Dev
Posts: 4344
Joined: 22 Sep 2007, 09:51

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

Post by hoijui »

i would bet it needs Lua, have no idea how to do it though.
how exactly does this work anyway (in real). do they catapult the missile out of water, and only then ignite its main engine?

edit:
nice idea, good luck! :-)
User avatar
BrainDamage
Lobby Developer
Posts: 1164
Joined: 25 Sep 2006, 13:56

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

Post by BrainDamage »

EE ( Expand & Exterminate ) has it, and iirc it had it much longer than spring had lua scripting, search there
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

Thanks! As for the other question not entirelly sure. I would suspect a dual cycle or something like that...
User avatar
CarRepairer
Cursed Zero-K Developer
Posts: 3359
Joined: 07 Nov 2007, 21:48

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

Post by CarRepairer »

tyran_nick wrote:I am trying to make a nuclear missile submarine. Is there any way to make a submerged unit fire a missile? I have built a test unit and when its submerged (i use the waterline string in the unit fbi) it won't fire. When I reset the waterline, so it behaves like a ship, it will fire nukes normally. I looked at few old TA units examples, but that didn't help...

Any ideas?

Thanks!
CA's Leviathan - Tactical Nuke/Anti Nuke Missile Sub sounds like what you want. Described here: http://trac.caspring.org/wiki/UnitGuide#Shipyard1

Unit file is here: http://trac.caspring.org/browser/trunk/ ... ukesub.lua
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

Thanks! I managed to do make my sub fire missiles underwater. Just for reference I used lua, but it seems the only thing I needed was a line in the weapon description (waterWeapon = true), so either fbi or lua are ok. I worked a bit more on the unit and I made it submerge/surface using the unit_replace gadget. However I have a problem now, any nukes that are stockpiled are lost when I change state. Any suggestions?

P.S. My lua skills are very poor (yet). I suspect I could do it with lua, but any more detailed help would be greatly appreciated!
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

I have a unit that seems to work alright (no crashes/missing files/etc) but there are times it won't fire its weapons. Sometimes it fires normally and sometimes it won't fire at all. The unit has two weapons, weapon1 is a missile similar to armmerl and the second weapon is a beamlaser mounted on a turret. There are times that the unit will fire all its weapons normally, but most of the times only the laser...! Even if I take control of the unit (by pressing C) I can see that the weapons are ready to fire (after aiming) but when i press the mouse button the missile just won't fire... :? Any ideas? The laser always works fine

I haven't used any lua on this one, just standard cob and fbi.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

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

Post by yuritch »

This can be some kind of script problem. Post your .bos and .fbi maybe?
Also, make sure the object from which the missile is fired (which is referenced in QueryWeapon) is not underwater (if your unit is a ship), because armmerl weapon can't fire from there.
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

Thanks, I re-checked the script as you suggested did a few changes and now the missile fires all the time. It wasn't the water... but couldn't really find what it was. My old script was based on the nuke silo (the other mode of the unit is to fire nukes) so it must have been something with that.

Next question :-)
How is the size of the radar blip in the minimap calculated? Can I override it by changing the unit's fbi?
User avatar
zwzsg
Kernel Panic Co-Developer
Posts: 7052
Joined: 16 Nov 2004, 13:08

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

Post by zwzsg »

In the \units\that_unit.FBI there is a line such as:

Code: Select all

	icontype=that_unit_icon;
In \gamedata\icontypes.tdf there is an entry such as

Code: Select all

	[that_unit_icon]
	{
		bitmap=icons/some_picture.tga;// Image to use
		size=1;// Multiplier for icon size
		radiusadjust=0;// Does the icon change size according to unit size?
		distance=0.5;// Multiplier for the distance at which unit turns into icon
	}
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

Thanks!
So based on:
radiusadjust=0;// Does the icon change size according to unit size?
I presume its something like unit radius * height from the .s3o file or the footprintX * footprintY for the engine to identify the unit size?
User avatar
tyran_nick
Posts: 47
Joined: 07 Mar 2010, 12:42

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

Post by tyran_nick »

Can we do cylinders with LUPS (similar to LUPS spheres)?
Are they any example units?
LordMuffe
Posts: 286
Joined: 13 Mar 2005, 15:39

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

Post by LordMuffe »

I┬┤m having a problem with the new spring version. I updated my mod with the game_spawn.lua , just the file as it was posted here in the forum. So far it works, commander gets spawned. But suddenly all my labs disappeared from the build menu.

Infolog tells me that they got removed, but not why

Code: Select all

WARNING: removed the "dgjeagfab" entry from the "dgcom" build menu


if i try to /give the units i get

Code: Select all

Couldnt find wreckage info dgjeagfab
But I┬┤m quite sure that I did not change anything besides the game_spawn.lua. The same mod file worked with older Spring versions.

Have i missed a change in that regard?
Locked

Return to “Game Development Tutorials & Resources”