API Bugs

Discussion in 'Empyrion API' started by Jascha, Mar 14, 2017.

  1. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    Ok. The point is: Before you import a structure you need to export it (to be able to have all the structure information like fuel/signals/groups/etc....).

    When you import/spawn a structure, fill the "exportedEntityDat" property with the exported file (Path and file name). Best is to have it in the same folder as the structure.

    Then he will spawn that structure with all the details it had before.
     
    #41
    Dost likes this.
  2. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    So I played with uploading this export file as exportedEntityDat under EntitySpawnInfo.
    Positive thing is that it sets alien faction correctly when using it. Negative is that structure integrity and "not firing on me" problems aren't resolved by it. The only situation when structural integrity is correct immediately after span is when the spawn is in the vicinity of my character in the game.
    I tried export of different strucutres even those pregenerated by game (Epsilon COM structure) to see if they have some settings differently.

    Also on a different note, all structures (including pregenerated) return powered:False in GlobalStructureInfo but they are obviously powered when visited. And their guns are blazing at predators but unfortunately not on me.
     
    #42
  3. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    This is extract of my code I use:
    Code:
    // preparing next structure
    String playfield = "Akua";
    EntitySpawnInfo nextSpawnInfo = new EntitySpawnInfo
    {
      playfield = playfield,
      pos = next_spawn_pos,   // PVector3 - I have to guess Y coordinate by close deposit pos
      rot = rotation,   // PVector3 - works great
      prefabName = "BA_RadosRefinery", // this prefab is not usually on Akua, is it a problem?
      name = "Mining Station",
      type = 2, // should be BA
      factionId = 0, // want alien but doesn't give it. I use console command to change to Aln
      factionGroup = 0 // have no idea if this one is correct
      // exportedEntityDat - ignored this one or used one generated from other structures
    };
    // getting new id for structure
    GameAPI.Game_Request(CmdId.Request_NewEntityId, (ushort)CmdId.Request_NewEntityId, null);
    
    ...
    // in Event_NewEntityId:
    
    Id newId = (Id)data;
    nextSpawnInfo.forceEntityId = newId;
    
    GameAPI.Game_Request(CmdId.Request_Entity_Spawn, (ushort)CmdId.Request_Entity_Spawn, nextSpawnInfo);
     
    #43
  4. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    Here is capture of the situation. When close, it spawns ok, when a far, integrity doesn't work: https://www.useloom.com/share/3a50ca04d00e4d6ba79d31a3b5272de1

    I just chained API spawn when receiving /spawn chat message so I can demonstrate the problem.
    I guess that in real game, things aren't usually spawned away from player and first random generation of playfield may work completely differently.

    Anyway, looks like it may require devs to look at it and call something after new spawn to make structure solid.
     
    #44
  5. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    Also I should probably note that structure doesn't fire on me even out of god mode ;)
     
    #45
  6. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    Yeah exactly that also has to do with the missing export information.
     
    #46
  7. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    Even structure with provided dat file doesn't fire on me unfortunately :(
     
    #47
  8. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    I prepared exact case, Exported original generated Drone Base. Found in file it is BA_DroneBase_Pharos, Spawned new Drone Base from correct prefab with DAT file and while original one smash me immediately with its turrets, new one is Alien but doesn't care about me. I was freshly spawned after death not using gm at all.

    Interestingly enough, using DAT file makes creatures inside the structure to attack me. So it is one step in right direction. Unfortunately those creatures were immediately attacked by other spawned "Alien" structure by its turrets.

    So it looks like something is resolved by DAT file but turret's targets not.

    Also to the note, spawned alien turrets don't attack other alien structures, be it original or spawned. They don't attack players structures too. Players structure turrets do attack both spawned and original alien structures.

    So there is something wrong with spawned alien turrets. They attack predators, they attack alien creatures, they don't attack alien structures, they don't attack player's structures. Even copied from original DAT file from original generated working structure.
     
    #48
    Mortlath and Jascha like this.
  9. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    Funnily enough those towers attack even their own spawns of certain kind. From tested they smash crawlers, assassins but leave alone Zirax Male or Turret Robot...
    How strange
     
    #49
  10. Mortlath

    Mortlath Commander

    Joined:
    Jul 26, 2017
    Messages:
    49
    Likes Received:
    26
    Putting in alien core into a spawned structure has the same effect. All the alien weapons only attack wildlife, etc. as if it were the spawning player's building still.
     
    #50
  11. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    hm ok. Thank you both for the infos. I try to reproduce it the next days and will send it to the devs. Then its more a game logic problem.
     
    #51
  12. Dost

    Dost Ensign

    Joined:
    Dec 25, 2017
    Messages:
    11
    Likes Received:
    3
    Thank you Jascha, sounds great :)
     
    #52
  13. Mortlath

    Mortlath Commander

    Joined:
    Jul 26, 2017
    Messages:
    49
    Likes Received:
    26
    I'm not getting back a response when sending out Eleon.Modding.CmdId.Request_InGameMessage_SinglePlayer anymore.

    I'm not getting back Eleon.Modding.CmdId.Event_Error or Event_Ok.
     
    #53
  14. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    Ok I'll check that. Thanks.
    But was it really send before?
     
    #54
  15. Mortlath

    Mortlath Commander

    Joined:
    Jul 26, 2017
    Messages:
    49
    Likes Received:
    26
    Yes, it was working fine until a recent update.
     
    #55
  16. Mortlath

    Mortlath Commander

    Joined:
    Jul 26, 2017
    Messages:
    49
    Likes Received:
    26
    Eleon.Modding.CmdId.Request_Entity_Spawn doesn't allow one to spawn a ship as private anymore by setting the faction id to the player's entity id. It now comes in as public or as the player's faction instead.
     
    #56
  17. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    Just to make sure: You also set the faction group to private or?
     
    #57
  18. Mortlath

    Mortlath Commander

    Joined:
    Jul 26, 2017
    Messages:
    49
    Likes Received:
    26
    I'm setting it to the value I get from PlayerInfo.factionGroup
     
    #58
  19. Jascha

    Jascha Administrator

    • Moderator
    Joined:
    Jan 22, 2016
    Messages:
    1,141
    Likes Received:
    713
    hm ok. I will check it, but we use it quite frequently and I never heard a complaint.
     
    #59
  20. Exacute

    Exacute Rear Admiral

    Joined:
    Feb 17, 2017
    Messages:
    456
    Likes Received:
    307
    @Jascha
    It seems https://empyrion.gamepedia.com/Game_API_CmdId#Event_GameEvent is broken.
    I used the following code to test it:
    Code:
    case CmdId.Event_GameEvent:
                            GameAPI.Console_Write("event");
                            GameAPI.Console_Write(data.ToString());
                            GameEventData gd = (GameEventData)data;
                            if (gd.Type != -1)
                            {
                                GameAPI.Console_Write(gd.Type.ToString() + " : type");
                            }
                            if (gd.PlayerId != -1)
                            {
                                GameAPI.Console_Write(gd.PlayerId.ToString() + " : player");
                            }
                            if (gd.Name!="")
                            {
                                GameAPI.Console_Write(gd.Name + " : name");
                            }
                            if (gd.Amount != -1)
                            {
                                GameAPI.Console_Write(gd.Amount.ToString() + " : amount");
                            }
                            if (gd.EventType!=000000)
                            {
                                GameAPI.Console_Write(gd.EventType.ToString() + " : eventtype");
                            }
                            if (gd.Flag)
                            {
                                GameAPI.Console_Write(gd.Flag.ToString() + " : flag");
                            }
                            if (gd.ItemStacks.Length>0)
                            {
                                for(int i = 0; i < gd.ItemStacks.Length; i++)
                                {
                                    GameAPI.Console_Write(gd.ItemStacks[i].id.ToString() + " : stack, " + i.ToString() + " id");
                                    GameAPI.Console_Write(gd.ItemStacks[i].slotIdx.ToString() + " : stack, " + i.ToString() + " slotidx");
                                    GameAPI.Console_Write(gd.ItemStacks[i].decay.ToString() + " : stack, " + i.ToString() + " decay");
                                    GameAPI.Console_Write(gd.ItemStacks[i].count.ToString() + " : stack, " + i.ToString() + " count");
                                    GameAPI.Console_Write(gd.ItemStacks[i].ammo.ToString() + " : stack, " + i.ToString() + " ammo");
                                }
                              
                            }
                            break;
                            case CmdId.Event_Player_Info:
                                ChatMessage("h0");
                                ChatMessage("hx" + seqNr.ToString());
                                if (seqNr == 19983)
                                {
    
                                    PlayerInfo ply = (PlayerInfo)data;
                                    ChatMessage("h1");
                                    ChatMessage("h2:" + ply.playfield.ToString());
                                    GameAPI.Console_Write("Player died at : " + ply.playfield.ToString());
                                    GameAPI.Game_Request(CmdId.Request_Playfield_Entity_List, (ushort)19983, new Eleon.Modding.PString(ply.playfield));
                                }
                                else if (seqNr == 19984)
                                {
                                    PlayerInfo ply = (PlayerInfo)data;
                                    ChatMessage("h1");
                                    GameAPI.Console_Write(ply.died.ToString());
                                    GameAPI.Console_Write(ply.origin.ToString());
                                    GameAPI.Console_Write(ply.playerName.ToString());
                                    ChatMessage("h2:" + ply.playerName + " : " + ply.died.ToString() + " : " + ply.origin);
                                }
                                break;

    (In Game_Event, under a case switch)

    NOTHING was outputted to the log, no matter what happened in the PDA.
    I tested it with this:
    Code:
      - ChapterTitle: Chapter23
        Category: SoloMission
        Description: Chapter22_description
        PictureFile: "WelcomeBack.jpg"
        PlayerLevel: 1
        Visibility: Always
        Activatable: Always
        AutoActivateOnGameStart: false
        CompletedMessage: Chapter22_completed
        Tasks:
          - TaskTitle: Chapter_Chapter22_tasktitle_1
            PictureFile: "WelcomeBack.jpg"
            Headline: Chapter22_tasktitle_1_headline
            Actions:
              - ActionTitle: Chapter_Chapter22_tasktitle_1_actiontitle_0
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_1_actiontitle_0_completedMessage"
                Description: Chapter_Chapter22_tasktitle_1_actiontitle_0_description
                Check: WindowOpened
                Names:
                  - Player
            OnCompletePlayfieldOps:
              - "SpawnDrone\x3A1\x3BDroneSmallFast01Minigun\x3BNearPlayer"
              - "SpawnEnemy\x3A5\x3BZiraxRocket\x3B55"
              - "SpawnEnemy\x3A5\x3BZiraxMale\x3B55"
            Rewards:
              - Item: RocketLauncherEpic
                Count: 1
              - Item: SlowRocketHoming
                Count: 50
          - TaskTitle: Chapter_Chapter22_tasktitle_0
            PictureFile: "WelcomeBack.jpg"
            Headline: Chapter22_tasktitle_0_headline
            Actions:
              - ActionTitle: Chapter_Chapter22_tasktitle_0_actiontitle_0
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_0_actiontitle_0_completedMessage"
                Description: Chapter_Chapter22_tasktitle_0_actiontitle_0_description
                Check: SubjectKilled
                Names:
                  - ZiraxMale
              - ActionTitle: Chapter_Chapter22_tasktitle_0_actiontitle_1
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_0_actiontitle_1_completedMessage"
                Description: Chapter_Chapter22_tasktitle_0_actiontitle_1_description
                Check: SubjectKilled
                Names:
                  - ZiraxRocket
              - ActionTitle: Chapter_Chapter22_tasktitle_0_actiontitle_2
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_0_actiontitle_2_completedMessage"
                Description: Chapter_Chapter22_tasktitle_0_actiontitle_2_description
                Check: SubjectKilled
                Names:
                  - ZiraxRocket
                  - ZiraxMale
              - ActionTitle: Chapter_Chapter22_tasktitle_0_actiontitle_3
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_0_actiontitle_3_completedMessage"
                Description: Chapter_Chapter22_tasktitle_0_actiontitle_3_description
                Check: SubjectKilled
                Names:
                  - ZiraxMale
                Amount: 2
              - ActionTitle: Chapter_Chapter22_tasktitle_0_actiontitle_4
                AllowManualCompletion: false
                CompletedMessage: "norm\x3B6\x7CChapter_Chapter22_tasktitle_0_actiontitle_4_completedMessage"
                Description: Chapter_Chapter22_tasktitle_0_actiontitle_4_description
                Check: SubjectKilled
                Names:
                  - ZiraxMale
                  - ZiraxRocket
                Amount: 2 

    No matter what happened, nothing was sent to the event.

    (On a sidenote, pda readdata didn't work for s* in multiplayer.. But that isn't really the APIs fault ;) )


    Did I do it wrong, or is this a bug?
     
    #60

Share This Page