Target cone

Target cone

Requests for features in the spring code.

Moderator: Moderators

User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Target cone

Post 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.
User avatar
KDR_11k
Game Developer
Posts: 8293
Joined: 25 Jun 2006, 08:44

Post by KDR_11k »

I think you could lua that by simply preventing the weapon from shooting if it's in the wrong place.
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Post by Zpock »

This can be easily LUA:ed (tm), combined with some cob hacking.

I'd wait for better LUA to weapon interfacing tough.
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

So how do I query the location and direction variables of the target in LUA?
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Post 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
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

How do I know what unit is the target?
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Post by Zpock »

The parameter of the attack command.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

A cleaner way to script-limit weapons would be epic.
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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 ;-)
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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);
} 
User avatar
Snipawolf
Posts: 4357
Joined: 12 Dec 2005, 01:49

Post by Snipawolf »

trepan wrote:Would yall prefer BlockShot#() ?
A hint of southern! Oh noez!
User avatar
Zpock
Posts: 1218
Joined: 16 Sep 2004, 23:20

Post by Zpock »

I would like FireShot(unitID,weapon#,targetID)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

I'm not bothered about the name, why give a unitID of 0 for ground targets?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post 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.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6242
Joined: 29 Apr 2005, 01:14

Post by FLOZi »

Oh, I get what you mean now. Thought you were returning 0 for any non-vtol unit. :oops:

edit: also, I thought unitids started at 0 anyway?
Last edited by FLOZi on 22 Oct 2007, 19:12, edited 1 time in total.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

When is BlockShotX(...) getting called? I don't really get this yet... :(
User avatar
MadRat
Posts: 532
Joined: 24 Oct 2006, 13:45

Post by MadRat »

So are units that a weapon slot cannot target given an ID of 0, too?
trepan
Former Engine Dev
Posts: 1200
Joined: 17 Nov 2005, 00:52

Post by trepan »

BlockShot#() is called just before the shot is fired.
User avatar
rattle
Damned Developer
Posts: 8278
Joined: 01 Jun 2006, 13:15

Post by rattle »

So technically the unit succesfully aims but you keep it from firing.
Post Reply

Return to “Feature Requests”