Page 1 of 2
Target cone
Posted: 15 Oct 2007, 15:11
by MadRat
Is there any way we could get support for a target cone, basically the opposite of the aiming cone, so that we can specify exact parts of a target to aim? I would think the code for aiming could be largely recycled here, with a simple check to see if the aim point and target point are both in their respective cones.
I want to be able to simulate tailchasing weapons.
Posted: 15 Oct 2007, 15:33
by KDR_11k
I think you could lua that by simply preventing the weapon from shooting if it's in the wrong place.
Posted: 15 Oct 2007, 19:05
by Zpock
This can be easily LUA:ed (tm), combined with some cob hacking.
I'd wait for better LUA to weapon interfacing tough.
Posted: 16 Oct 2007, 07:19
by MadRat
So how do I query the location and direction variables of the target in LUA?
Posted: 16 Oct 2007, 14:28
by Zpock
http://spring.clan-sy.com/wiki/Lua_Scripting
More precisely:
Spring.GetUnitPosition
( number unitID ) -> nil | number x, number y, number z
Spring.GetUnitBasePosition
( number unitID ) -> nil | number x, number y, number z
Spring.GetUnitDirection
( number unitID ) -> nil | number dx, number dy, number dz
Spring.GetUnitHeading
( number unitID ) -> nil | number heading
Posted: 22 Oct 2007, 00:33
by MadRat
How do I know what unit is the target?
Posted: 22 Oct 2007, 01:26
by Zpock
The parameter of the attack command.
Posted: 22 Oct 2007, 01:50
by trepan
Adding a COB function would probably be the best way to do this.
How about something like:
Code: Select all
// targetID = unitID or (featureID + offset) or 0 for ground target?
AllowShot(weaponNum, targetID)
if (MyTestGoesHere(weaponNum, targetID)) {
return 1;
} else {
return 0;
}
}
The AimPrimary() COB function can be used to block shots, but
it will only do so if forwardOnly is not enabled. The other problem
is that you wont know what the target is.
It might be better to set this up for an immediate return value.
Posted: 22 Oct 2007, 03:20
by FLOZi
A cleaner way to script-limit weapons would be epic.
Posted: 22 Oct 2007, 03:38
by trepan
I have it coded as the following:
Code: Select all
AllowShot1(unitID, retval)
{
// unitID = 0 for ground targets
if ( the shot should not be fired ) {
retval = 0;
}
return (whatever);
}
AllowShot2() ...
Now I just need to test it

Posted: 22 Oct 2007, 03:43
by trepan
Would yall prefer BlockShot#() ?
Code: Select all
BlockShot1(unitID, blockShot)
{
// unitID = 0 for ground targets
if ( the shot should not be fired ) {
blockShot = 1;
}
return (whatever);
}
Posted: 22 Oct 2007, 03:43
by Snipawolf
trepan wrote:Would yall prefer BlockShot#() ?
A hint of southern! Oh noez!
Posted: 22 Oct 2007, 03:49
by Zpock
I would like FireShot(unitID,weapon#,targetID)
Posted: 22 Oct 2007, 04:25
by FLOZi
I'm not bothered about the name, why give a unitID of 0 for ground targets?
Posted: 22 Oct 2007, 04:27
by trepan
It has to be something, and i'd rather not limit the call to just
unit target shots. UnitID = 0 is used in other parts of cobs to
indicate a null unit (check some of the GET calls...)
P.S. I changed it to BlockShot#(unitID, block), where block
is the return value, and its input state is 0.
Posted: 22 Oct 2007, 15:38
by FLOZi
Oh, I get what you mean now. Thought you were returning 0 for any non-vtol unit.
edit: also, I thought unitids started at 0 anyway?
Posted: 22 Oct 2007, 17:02
by rattle
When is BlockShotX(...) getting called? I don't really get this yet... :(
Posted: 24 Oct 2007, 06:32
by MadRat
So are units that a weapon slot cannot target given an ID of 0, too?
Posted: 24 Oct 2007, 07:38
by trepan
BlockShot#() is called just before the shot is fired.
Posted: 24 Oct 2007, 19:29
by rattle
So technically the unit succesfully aims but you keep it from firing.