Icewind Dale 2 - so I wonder

Discussion in 'Icewind Dale Total Conversion' started by anatoliy, Aug 24, 2021.

Remove all ads!
  1. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Here's the code if you wanna have a look:
    https://github.com/GrognardsFromHel...eacb76d7da12430cc/TemplePlus/critter.cpp#L327
     
  2. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
  3. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Hmm, sounds like it could get messy... does executing one script block all the others in IE? Is this WAIT command used exclusively in cut scenes that take ownership of all events?
     
  4. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    It won't get messy, as I use class inheritance and object composition templates extensively for NPCs and BCS scripts. It's hard to explain, unless my framework scanned and read.

    Code:
    class Script_00AATGN_Auto(inf_scripting.ScriptBase):
        # AR1000 10HEDRON Hedron ScriptClass (Special 2)
       
        @classmethod
        def do_execute(cls, self):
            assert isinstance(self, inf_scripting.InfScriptSupport)
            while True:
                # See(NearestEnemyOf(Myself),0)
                if self.iSee(self.iNearestEnemyOf("Myself"), 0):
                    # EquipWeapon()
                    # AttackOneRound(LastMarkedObject)
                    self.iEquipWeapon()
                    self.iAttackOneRound("LastMarkedObject")
                    break
               
                break # while
            return
    
    # next in other, manual file there will be following:
    class Script_00AATGN(py10005_ar1000_scripts_auto.Script_00AATGN_Auto):
        # AR1000 10HEDRON Hedron ScriptClass (Special 2)
       # human could override automatically generated class method here
       pass
    
    
    inf_scripting.InfScriptSupport, which is "self" arg here, will have ability to "redirect" or "override" actual context (kind of self)...

    Ownership of events (self substitution) is used a lot in scripts, not tied to cutscenes.
     
  5. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Not sure I understand, is the above related to how you chain together the commands into a single script? If so that's great but it's not what I'm talking about.
    What I mean is, when a script executes WAIT, is it expected that other scripts can also run during this time, or not?
     
    anatoliy likes this.
  6. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    Good catch @Sitra Achara !

    I have not thought about it. Probably not.

    To be frank, I'm still not sure when these assigned scripts are run exactly. See this pic: https://co8.org/community/attachments/actor1-jpg.9694/
    I think all of them should run in heartbeat, and "combat" probably in turn start, as it mostly pick enemy. For example some NPCs have preferences scripted.

    I guess in case of delayed WAIT code block I'd have to suspend all other scrips executions. Thanks Sitra!!
     
  7. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    I think I found answer:
    https://www.pocketplane.net/tutorials/simscript.html#Cutscenes

    SetCutSceneLite is not used in IWD2.
     
  8. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Cool, very informative link!
    Heartbeats should be sufficient for most simple things, but if finer grained control is needed it should probably be with Time Events.
     
    anatoliy likes this.
  9. Allyx

    Allyx Master Crafter Global Moderator Supporter

    Joined:
    Dec 2, 2004
    Messages:
    5,009
    Likes Received:
    254
    Bristol is at war? Who knew? I know Bristol is the breast implant capital of the UK (or so I've heard) so I don't mind going but this is the first I'm hearing about a war there.
     
  10. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    Status update

    Finally figured out how to make delayed scripts execution. Now cutscenes do work. But the produced code is quite complicated.

    Example:
     
  11. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    Problems:

    1) npc.float_line does not always work.
    I spent hour trying to figure out why. Had to switch to float_text_line :(

    2) game.create_history_freeform does not always work.
    When used in first heartbeat it breaks and stops working further on. No idea why, IDA code is too complicated.
    I also thought, that string is disposed before it prints itself. Added global storing of text in Python but it did not help.

    3) Scripted cutscene MoveToPoint
    I'm setting standpoint and waiting for 7 seconds before script is continued. There is no way to determine when NPC would arrive, and sometimes when destination tile is occupied it simply will not go.

    Probably I will have to use workaround with decoy and npc.find_path_to_obj. It's a pain...
     
  12. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Are there any log message that could indicate what's wrong?
     
  13. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    If you are in regards to float_line:
    LoadNpcLine calls __usercall sub_10038240@<eax>(int eax0@<eax>, int a2)
    I do not know how to parse such. Perhaps this is self / this.
    In any case it does not work and no log messages. I would not post here if I did not tried to figure out it myself.
    if create_history_freeform:
    No log messages. Kind of wierd.​
     
  14. Sitra Achara

    Sitra Achara Senior Member

    Joined:
    Sep 1, 2003
    Messages:
    3,622
    Likes Received:
    538
    Do you wanna do a discord session this evening?
     
  15. anatoliy

    anatoliy Established Member

    Joined:
    Feb 18, 2017
    Messages:
    635
    Likes Received:
    201
    Yes, sounds great. Let's continue in the pm
     
Our Host!