Ship set target

Discussion in 'Flight Commander' started by Iceblade, Apr 26, 2011.

  1. Iceblade

    Iceblade Admiral

    Messages:
    1,977
    Likes Received:
    13
    Trophy Points:
    36,985
    Gender:
    Male
    I seem to be having an annoying problem the Ship_setTarget function.

    In my mission, I have some placed ships and some ships that are spawned. To avoid having the player attacked by all of them, I created a randomtarget(shipid) function show here.

    Code:
    function randomtarget(shipid)
      x = math.random(1,4);
      if(x == 1) then
        target = "player";
      end
      if(x == 2) then
        target = "stiletto";
      end
      if(x == 3) then
        target = "maniac";
      end
      if(x == 4) then
        target = "maestro";
      end
      Ship_setTarget(shipid, target);
    end
    I have all enemy fighters have a creation script with this function. The spawned fighters appear to receive follow this function perfectly; however, the already existing fighters ignore the target command. Using prints, I know this function is being called and that the right arguments are being passed to the target function with usually one or two fighters out of four slated to attack me. So I have no clue why this function is not working on pre-existing fighters.

    I originally had this function called within the nav creation script with the enemy fighter shipid as the argument, but that obviously wasn't working.

    The only thing I can think of is that the shipid is not being passed with quotes.

    Edit: I tried the LUA tostring() function, but that didn't fix the issue.
     
  2. Iceblade

    Iceblade Admiral

    Messages:
    1,977
    Likes Received:
    13
    Trophy Points:
    36,985
    Gender:
    Male
    I even added in a AI disable/enable commands around the setTarget and they still come after me.

    On another note, my wingman in a shrike managed to take out the destroyer and actually contributed somewhat in its destruction (at least 3 to 5 successful light torps hits, which is really good considering she was just bumping randomly around the hull of the Orca). She actually knocked out both the bridge and engine; course it was pure luck she was near the components when launching some of those torpedoes, but a kill is a kill.

    So the AI appears to be improving, at least tangentially (better torp AI, improved wing AI, and bombing run AI - at least bombers are firing torps now). Though, sometimes those torpedoes just want to go curving away from the components if the trajectory is not dead-on, but WCSO had a similar (though less common) problem. Actually errant torps would probably add to the 'realism' of the combat by thinking that the alien capships are using anti-torp 'electronic' countermeasures. Of course, a head-on trajectory would make torps harder to deflect.

    Oh and one thing I found that made flying the shrike much more bearable: increasing the rear turret's refire rate. (Seriously, 1 shot per second? That was the refire rate in WCSO?) Anyway cranking it up to 4 shots per second allowed me to get some of those bogeys off my tail long enough to turn around and nail them with charging mass driver fire. I think I killed one or two actually with just the rear turret (of course they morays and squids).
     
  3. eddieb

    eddieb Vice Admiral

    Messages:
    975
    Likes Received:
    2
    Trophy Points:
    32,385
    Location:
    Los Angeles
    Hmm. I wonder if your scriptids in the mission.xml don't match the ids in the lua.
     
  4. eddieb

    eddieb Vice Admiral

    Messages:
    975
    Likes Received:
    2
    Trophy Points:
    32,385
    Location:
    Los Angeles
    There's no explicit bomber run ai yet, but I think it does know to at least switch to torps, if I recall.
     
  5. eddieb

    eddieb Vice Admiral

    Messages:
    975
    Likes Received:
    2
    Trophy Points:
    32,385
    Location:
    Los Angeles
    And eventually there should be attack and defend queues, so you can prioritize targets from a script.
     
  6. Iceblade

    Iceblade Admiral

    Messages:
    1,977
    Likes Received:
    13
    Trophy Points:
    36,985
    Gender:
    Male
    Actually, the problem is not with the scriptids as all spawned units have no problem following the code's order.

    It is just preexisting ships that won't listen. I could always use a work-around of spawning all enemy fighters within the first second of a nav, but that is a little annoying.
     

Share This Page