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

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
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 »

Okay. Here is a really ugly script that I am having issues with the weapon1 firing at all. I know it is the script because I have changed out weapons that I know work and it fails to fire. I have also replaced the aimweapon1 script with a bare minimum and it still fails to fire.

Any help bug fixing I would be most gracious!

http://pastebin.com/z0d9s4U2
User avatar
Argh
Posts: 10920
Joined: 21 Feb 2005, 03:38

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

Post by Argh »

I have also replaced the aimweapon1 script with a bare minimum and it still fails to fire.
If you've tried AimWeapon1(){return(1);}

...then the problem is elsewhere. Are you using aiming cones, etc. that might be causing an issue?
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 »

It is not the weapon's issue. I have weapons that work on the same unit, and other units running for the test. It is something in the script that doesn't let it aim.
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

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

Post by FireStorm_ »

Before addressing this one should probably know I have no programming background (besides perhaps my own brain :-) ). And I'm trying to Lua script a unit by looking at examples and reading the wiki.

Question:
Can I show an animation of the unit dying or falling over after the call-in 'Killed' was called? I started like this:

function script.Killed(recentDamage, maxHealth)
StartThread( Diescript )
return 1
end

'Diescript' is ofcourse my animation of the unit falling to the ground. But calling 'Killed' makes the unit disappear (or be replaced with a corpse), and a disappeared unit cant show an animation. So how should/can this be done? I hope my question is not to ignorant to be taken seriously.
User avatar
Peet
Malcontent
Posts: 4384
Joined: 27 Feb 2006, 22:04

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

Post by Peet »

The unit is removed when killed() returns. Do the animation in the same thread as that function (just call diescript() instead of running it in a new thread).
User avatar
FireStorm_
Posts: 666
Joined: 19 Aug 2009, 16:09

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

Post by FireStorm_ »

I see my mistake now. The way I wrote it the function is a thread, which makes it run parallel, which caused my problem. I should have written Diescript() where i put StartThread( Diescript )
I'm actually starting to get some of this stuff. Thanks Peet.
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

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

Post by PTSnoop »

Is there a weapon tag to prevent explosions from damaging friendly units? I've tried CollideFriendly=0 but the quite-excessively-large area of effect is still damaging friendly units. Or will this have to be a Lua thing?
User avatar
Pxtl
Posts: 6112
Joined: 23 Oct 2004, 01:43

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

Post by Pxtl »

PTSnoop wrote:Is there a weapon tag to prevent explosions from damaging friendly units? I've tried CollideFriendly=0 but the quite-excessively-large area of effect is still damaging friendly units. Or will this have to be a Lua thing?
Lua. Not too hard to do that one though, I believe that several games have a noselfpwn gadget kicking around that could easily be expanded to all friendlies. It'd be a good starter-project to learn Lua, really.
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 »

PTSnoop wrote:Is there a weapon tag to prevent explosions from damaging friendly units? I've tried CollideFriendly=0 but the quite-excessively-large area of effect is still damaging friendly units. Or will this have to be a Lua thing?
http://trac.caspring.org/browser/trunk/ ... lyfire.lua
User avatar
PTSnoop
Posts: 97
Joined: 09 Sep 2009, 19:05

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

Post by PTSnoop »

I ended up messing around with CA's noselfpwn, but didn't get it working exactly how I wanted.

But the nofriendlyfire gadget (which I didn't notice for some reason) is working perfectly. And I learnt a bit of Lua in the process! Thanks guys.
User avatar
Beherith
Posts: 5145
Joined: 26 Oct 2007, 16:21

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

Post by Beherith »

Is a feature that is not selectable still reclaimable if it has an autoreclaimable=1 and a reclaimable=1 tag?
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

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

Post by jK »

Beherith wrote:Is a feature that is not selectable still reclaimable if it has an autoreclaimable=1 and a reclaimable=1 tag?
yup, try a area reclaim next to it.
thedude
Posts: 66
Joined: 21 Aug 2009, 12:47

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

Post by thedude »

Is it possible to give a build command to a gaia factory?
(I couldn't find a build command to use it for Spring.Give Order() )
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 »

Factories have two queues, one build queue and one rally queue (the orders that go to units built by it), check the wiki page on the CMDs, I think it's described there.
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
Locked

Return to “Game Development Tutorials & Resources”