Author Topic: remove-goal  (Read 5557 times)

0 Members and 1 Guest are viewing this topic.


Does the remove-goal sexp work?  Every time I try it, it does not seem to have an effect.  Then again perhaps it's the way I'm using it.  Basically, I want Beta wing to engage Red wing, but only when Red wing is ~10,000 m from its capital ship.  So I have it set up that once Red wing is 10,000+ from home, add goal to Beta to chase Red.  Once Red wing is destroyed OR the distance between Red and cap ship is under 10,000, remove that goal.  But it doesn't work.  Beta wing maintains its chase-Red goal and just sits still until the next wave of Red ships arrives and crosses the 10,000 meter threshold.  What gives?

killface

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
As a workaround, try using clear-goals and then readding the goals you want it to perform now.

 
I should have mentioned...I did try using clear-goals, that was actually my plan to begin with.  But as these are every-time sexps (because there will be multiple waves of red wing), using clear-goals then add-goal just makes Beta wing fly in tiny circles, confused, as their goals get repeatedly voided out and re-added.

EDIT
Additionally, I tried having Red Wing protected until they get 10,000 meters from the cap ship, but this doesn't work either, because the unprotect-ship sexp only lets you select individual ships, not wings.  Which sucks, because there's many waves of Red wing to be had...
« Last Edit: May 12, 2009, 01:18:02 am by killface »

 

Offline FUBAR-BDHR

  • Self-Propelled Trouble Magnet
  • 212
  • Master Drunk
    • 165th Beer Drinking Hell Raisers
Try stay near ship 50 on the cap and attack red 75 as initial orders or when the cap arrives.

Also every-time should not be used in a case like this.  A repeating when would be fine and may solve the problem.  So something more advanced would be

when
--num-ships-in-battle
--->0
--->red
--clear goals
--->beta
-->add-goal
---->ai-stay-near
-----><cap>
---->89
repeat 999999 delay 1

when
--num-ships-in-battle
---> > 0
--->red
--clear goals
--->beta
-->add-goal
---->ai-chase
----->red
---->89
repeat 999999 delay 1



No-one ever listens to Zathras. Quite mad, they say. It is good that Zathras does not mind. He's even grown to like it. Oh yes. -Zathras

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
You can also try making two sexps, one for the times when RED is far away from the cap ship like

when (repeat 99999)
 >
  distance
    -RED
    -CAP SHIP
  XXXXXX
clear goals
 Alpha
add goal
 Alpha
 protect Cap ship (so it stays near it)

and another for when the wing is close enought


when (repeat 99999)
 <
  distance
    -RED
    -CAP SHIP
  XXXXXX
clear goals
 Alpha
add goal
 Alpha
 IA-chase RED


el hombre vicio...

 

#1, it's not that Beta needs to stay near the cap ship...it's that they need to WAIT until Red is far enough away from the ENEMY cap ship before approaching, because the enemy cap ship has flak guns that will tear them up.

#2, I did try the repeating when, with the exact same effect. 

#3, Every time I involve a clear-goals sexp, the ships just wobble in space as their goals get repeatedly voided and added.  It's like they suffer from repetitive short-term memory loss.  "Let's go attack the-!....wait, what were we doing?...Oh yeah, let's get the bast-...wait, what now?"

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
Code: [Select]
// Goober5000
void sexp_remove_goal(int n)
{
}

Well it's pretty obvious why this SEXP doesn't work. :p
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 
Is this as simple as the converse of sexp_add_goal?

i.e.
Code: [Select]
int num, sindex;
char *name;

Assert ( n >= 0 );
name = CTEXT(n);
sindex = CDR(n);

// first, look for ship name -- if found, then add ship goal.  else look for wing name -- if
// found, add wing goal
if ( (num = ship_name_lookup(name, 1)) != -1 )
ai_remove_ship_goal( sindex, AIG_TYPE_EVENT_SHIP, &(Ai_info[Ships[num].ai_index]) );

or is there more to it?

I can't find the equivalent of ai_remove_wing_goal - is there one?
STRONGTEA. Why can't the x86 be sane?

 

Forgive me my non-coder background, kara, but are you saying that this sexp has been disabled?  If so, why?  Any ideas for what I can do to work around it?

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
I'm not saying that it's been disabled. I'm saying it doesn't even exist! There is code to make the SEXP appear and work in FRED and for it to load in correctly in FRED and FS2. However there is no code for the SEXP itself. When game tries to run the SEXP the code to tell it what to actually do is non-existent and it just skips it.

What's even stranger is that it appears that it has always been that way. TortoiseBlame seems to suggest that Goober added the SEXP in 2006 with no actual code. Unless he was doing that to replace a buggy earlier version for compatibility reasons I'm at a loss to explain it.


@portej05 - If there is such a function in the code I could add this SEXP in about 3-4 minutes flat. If not it's probably possible to make one. But I'd like to know what happened to the body of the original function first.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Offline Angelus

  • 210
  • The Angriest Angel

#1, it's not that Beta needs to stay near the cap ship...it's that they need to WAIT until Red is far enough away from the ENEMY cap ship before approaching, because the enemy cap ship has flak guns that will tear them up.

me thinks:


everytime
-->
---distance
----red
----hostile capship
----10000
---clear-goal
----Beta
---add-goal
----Beta
-----ai-chase
------red
------89


everytime
--<
---distance
----red
----hostile capship
----10000
---clear-goal
----Beta
---add-goal
----Beta
-----ai-ignore       ( alternative is to add a goal where the wing strays near a friendly cap )
------red
------89
     

FRED's not working, so i'm not 100% sure.


Every time I involve a clear-goals sexp, the ships just wobble in space as their goals get repeatedly voided and added.  It's like they suffer from repetitive short-term memory loss.  "Let's go attack the-!....wait, what were we doing?...Oh yeah, let's get the bast-...wait, what now?"


 :lol:

dementia squad is awaiting orders...
« Last Edit: May 12, 2009, 12:35:04 pm by Angelus »

 

That is EXACTLY what I tried initially...but again, clear-goals sexp + everytime conditional doesn't seem to like working.  So I can't clear the goals, I can't remove the goals, I can't protect or unprotect wings instead of individual ships...I am stuck here.

 

Offline Angelus

  • 210
  • The Angriest Angel
That's odd, i'm using the everytime conditional a lot, never had problems with it, but i'm giving orders to single ships not wings.
Try to disband the wing ( Beta ) and give the order to each ship in the wing instead of the wing.

Do you use the 3.6.10 RC2 build?

 

Offline Rodo

  • Custom tittle
  • 212
  • stargazer
    • Steam
also, could you post the sexp you are using, a screenshot could help us to see what might be wrong.
el hombre vicio...

 
It's RC1.  Thanks for pointing me to RC2, I was on vacation while that came out, but I'm not sure if it relates to this issue.

Here's the screenshot of the SEXP, please tell me if I've got anything wrong in there.

EDIT: Again, I believe it's the repeating nature of the every-time conditional (or the when with repeats) that is causing the problem, constantly voiding out Beta wing's goals and causing the ships to stutter in space.  But I don't know of any other way to address this scenario

[attachment deleted by ninja]

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
I'm taking a good long look at this and I simply can't see why you're using the every-time SEXP in the first place. Not only is this not one of the special circumstances when every-time is needed but more importantly this is one of the times when using every-time is hindering you more than helping.

Furthermore you're using a completely unnecessary brute force solution to the problem. As a result you're wiping and changing the orders of ships around 70 times a second. No wonder the ships are acting schizophrenically.

A little finesse should help with this.

1) Use repeating when and make it a 1 or 2 second delay between repeats. There is no need really for any less than that and you could probably justify it being longer.
2) Use a string variable to store the current orders Beta is under. In the first event set it to ATTACK_RED. In the second event use string-equals to check if the value is ATTACK_RED and if it is (along with the stuff already in the trigger) set it to ATTACK_CRUISER. Now change the first event to add the condition that the variable must equal ATTACK_CRUISER and set that to your default value for the variable.

That should drastically cut the AI flailing on its own. If it doesn't I have some other ideas. :)
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

I had tried using when with repeats, with the same result.  However, hadn't tried lengthening the repeat.  That's a good call.  Implementing all of the changes you outlined created an unexpected result.  Now Beta wing just sits there with "no orders".  Very confused re: why.  Here are the SEXPs as they read now.

[attachment deleted by ninja]

 

Offline karajorma

  • King Louie - Jungle VIP
  • Administrator
  • 214
    • Karajorma's Freespace FAQ
You probably forgot to actually give some initial order to Beta. I don't know how your mission is set up but if red wing starts out less than 10,000m from the Typhon the game will never enter either of those two events.

Swapping the default value for the Variable would probably solve this too. The default value should reflect what you want Beta to be doing right at the start.
Karajorma's Freespace FAQ. It's almost like asking me yourself.

[ Diaspora ] - [ Seeds Of Rebellion ] - [ Mind Games ]

 

Alright, that seemed to work...but ultimately I think I'm just going to redesign the layout of this mission to prevent near-capship encounters, rather than do this sexp setup for the 20+ fighter wings involved.  Also, it would be sweet if remove-goal could be made to live once more (if it ever did). 

Thanks all

 

Offline General Battuta

  • Poe's Law In Action
  • 214
  • i wonder when my postcount will exceed my iq
...20+ fighter wings?

Simultaneously?