Sor3nt / manhunt-toolkit

A free and open source toolkit to quickly modify Rockstar`s game Manhunt.
15 stars 3 forks source link

MLS files after sexual deviants crash #41

Open HoJo215 opened 2 months ago

HoJo215 commented 2 months ago

So I found a fix for the tolerance zone end cutscene where danny walks through the floor using the ps2 retail version mls file.

I went to edit that into the pc version mls file to keep the bums / civilians but it crashes on recompile. Just unpacking and repacking without touching the script seems to crash.. This is with the master version zip.

Same thing for the plaza and a couple levels that seems to go back to important scripts going into the unsupported folder. I also notice the script size gets larger when repacked sometimes too without touching anything.. Compression problem?

It be nice to see these errors fixed up before you retire it, as I see you have "maybe the last one" on the recent release.

Sor3nt commented 2 months ago

That is math related, MHT has some issues with "complex"-calculations, you need to break it down by yourself to fix it. A12 => 13#genhunterscript.srce Line 113 pos.y := pos.y + 1 + (randnum(50) * 0.01);

Change it to newRand := randnum(50) * 0.01; pos.y := pos.y + 1 + newRand; (do not forget to define newRand)

Move the .srce into the supported folder and try again.

Same level , 14#genhunterscript is fixed, please load the latest MHT from Master.

About the size, never saw that issue, the new MLS is always smaller then the original file, please provide me your workspace, i need to check what you have.

also take sure you always apply game and platform argument to MHT! And maybe, we have also a differences between SLES 548.19 and SLUS 216.13, which retail version do you use ?

HoJo215 commented 2 months ago

The newer build is not unpacking a "supported" folder at all. Using the command:

php mht.phar unpack A12_PL.MLS --game=mh2 --platform=ps2

Game: mh2 | Platform: pc Identify file as Levelscript Processing C:\Users\H\Desktop\Manhunt Mods Stuff\manhunt-toolkit-master(newer)\A12_PL.MLS .................................................................................................................................................................................................................................. Extracted to C:\Users\H\Desktop\Manhunt Mods Stuff\manhunt-toolkit-master(newer)/export/A12_PL#MLS C:\Users\H\Desktop\Manhunt Mods Stuff\manhunt-toolkit-master(newer)>

Whats weird is it still shows platform as pc instead of ps2 I'm using ps2 retail SLUS 216.13

Sor3nt commented 2 months ago

--game and --platform are deprecated, please try this command

php mht.phar A12_PL.MLS mh2 ps2

HoJo215 commented 2 months ago

Okay tried the new commands and they work but it's still only unpacking the "not-supported" folder. No "supported" folder at all.

The older master still unpacks both "supported" and "not-supported" folders.. Strange.. I don't see why it would unpack one folder but not the other folder. There might be a regression here.

Sor3nt commented 2 months ago

are u sure, you using the master mht.phar ?


% php mht.phar ./ps2_slus_216.13_1.03/LEVELS/A12_PL/A12_PL.MLS mh2 ps2

███╗   ███╗██╗  ██╗████████╗    ██╗   ██╗   ██████╗    █████╗
████╗ ████║██║  ██║╚══██╔══╝    ██║   ██║  ██╔═████╗  ██╔══██╗
██╔████╔██║███████║   ██║       ██║   ██║  ██║██╔██║  ╚██████║
██║╚██╔╝██║██╔══██║   ██║       ╚██╗ ██╔╝  ████╔╝██║   ╚═══██║
██║ ╚═╝ ██║██║  ██║   ██║        ╚████╔╝██╗╚██████╔╝██╗█████╔╝
╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝         ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚════╝ 2024
            Coded by Sor3nt | dixmor-hospital.com
A free and open source toolkit to quickly modify Rockstar`s game Manhunt.

Game: mh2 | Platform: ps2
Identify file as Levelscript
Processing ./ps2_slus_216.13_1.03/LEVELS/A12_PL/A12_PL.MLS ...............................
Extracted to ./ps2_slus_216.13_1.03/LEVELS/A12_PL/export/A12_PL#MLS

% find .
.
./not-supported
./not-supported/13#genhunterscripts.mht_code
./not-supported/13#genhunterscripts.stab
./not-supported/13#genhunterscripts.entt
./not-supported/13#genhunterscripts.scpt
./not-supported/13#genhunterscripts.error
./not-supported/13#genhunterscripts.code
./not-supported/13#genhunterscripts.srce
./not-supported/13#genhunterscripts.smem
./not-supported/13#genhunterscripts.trce
./not-supported/13#genhunterscripts.line
./not-supported/13#genhunterscripts.name
./not-supported/13#genhunterscripts.data
./not-supported/13#genhunterscripts.dmem
./supported
./supported/8#breakablelights.srce
./supported/4#gentriggerscripts.srce
./supported/15#genhunterscripts.srce
./supported/7#genopenablescript.srce
./supported/17#genhunterscripts.srce
./supported/2#playerscripts.srce
./supported/6#elevatorscripts.srce
./supported/14#genhunterscripts.srce
./supported/3#genbreakablescripts.srce
./supported/16#genhunterscripts.srce
./supported/1#sectorscripts.srce
./supported/11#gencopter.srce
./supported/0#levelscript.srce
./supported/18#genhunterscripts.srce
./supported/10#genhunterscripts.srce
./supported/5#leaderscripts.srce
./supported/9#genhunterscripts.srce
./supported/12#genhunterscripts.srce
Sor3nt commented 2 months ago

just notices the issue, its php version related, i pushed a new mht.phar to master

HoJo215 commented 2 months ago

We're getting there.. It unpacks both "supported" and "not-supported" folders but now it wont pack back up into an mls file..

C:\Users\H\Downloads\manhunt-toolkit-master>php mht.phar pack C:\Users\H\Downloads\manhunt-toolkit-master\export\A07_Tolerance_Zone#mls mh2 pc

███╗   ███╗██╗  ██╗████████╗    ██╗   ██╗   ██████╗    █████╗
████╗ ████║██║  ██║╚══██╔══╝    ██║   ██║  ██╔═████╗  ██╔══██╗
██╔████╔██║███████║   ██║       ██║   ██║  ██║██╔██║  ╚██████║
██║╚██╔╝██║██╔══██║   ██║       ╚██╗ ██╔╝  ████╔╝██║   ╚═══██║
██║ ╚═╝ ██║██║  ██║   ██║        ╚████╔╝██╗╚██████╔╝██╗█████╔╝
╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝         ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚════╝ 2024
                        Coded by Sor3nt | dixmor-hospital.com
A free and open source toolkit to quickly modify Rockstar`s game Manhunt.

PHP Fatal error:  During inheritance of IteratorAggregate: Uncaught ErrorException: Return type of Symfony\Component\Finder\Finder::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/vendor/symfony/finder/Finder.php:620
Stack trace:
#0 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/vendor/symfony/finder/Finder.php(39): exception_error_handler()
#1 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/vendor/composer/ClassLoader.php(444): include('...')
#2 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/vendor/composer/ClassLoader.php(322): Composer\Autoload\includeFile()
#3 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/App/Service/Resources.php(62): Composer\Autoload\ClassLoader->loadClass()
#4 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/App/Commands/pack.php(62): App\Service\Resources->load()
#5 phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/mht.php(123): include('...')
#6 C:\Users\H\Downloads\manhunt-toolkit-master\mht.phar(10): include('...')
#7 {main} in phar://C:/Users/H/Downloads/manhunt-toolkit-master/mht.phar/vendor/symfony/finder/Finder.php on line 39

C:\Users\H\Downloads\manhunt-toolkit-master>
Sor3nt commented 2 months ago

MHT was developed with PHP 7.4, it may work with PHP 8.0/8.1 too. I guess your PHP version is 8.3, please downgrade 🤷

MHT upgrade to latest PHP will happen, ~but not now, sorry~

(The "anything was inside not-supported" problem was also related to the PHP version, but in this case the solution was simple.)

Sor3nt commented 2 months ago

just hacked a version together, try it, but your best bet is still using a older php version mht_php8x_testing.phar.zip

HoJo215 commented 2 months ago

That testing.phar works! Unpacking and packing. I did downgrade to 7.4 though as suggested.

Now about the larger size.. It's the red light district: A07_Tolerance_Zone.mls It's originally 83kb in size but when unpacked and repacked, it's 444kb in size without touching it?

The fix for danny to not walk through the floor at the end cut scene is:

A07 => 39#leaderscript.srce - line 554

MoveHunter('player(player)', 58.661, 11.004, -10.084, 270);

changed to:

MoveHunter('player(player)', 58.661, 11.564, -10.084, 270);

and it works but the newly packed A07_Tolerance_Zone.mls is not stable. It's seems to randomly crash either on restart level or right before cop brutality cutscene. I dont know if it has to with bigger size mls file..

If we ever want this cutscene fixed or even port the cut staircase puzzle from psp 0.01 version leak A07 level. We need a stable edit-able A07_Tolerance_Zone.mls It's strange because it's just a "supported" folder but still crashes..

Sor3nt commented 2 months ago

The original MLS file is zLib compressed, MHT version is not compressed that why the size diff, just checked, the new file is smaller.

The crashes are most likely related to memory allocation. I couldn't figure out how to calculate the MEM for each script, so I defined a fixed value. This value is sometimes not enough 🤷

I changed the logic. When extracting an MLS file, each SRCE has a header that reflects the memory used.

please try this mht.phar.zip

HoJo215 commented 2 months ago

It works! php 8.2 version. I tried running through checkpoints and every way to make it crash.. No crashes at all on the new A07_Tolerance_Zone.mls - cutscene fixed.

I haven't tested other levels but so far so good. Thank you so much

One more thing on the A12_Plaza.. How do I define newRand? Is that a php command? I changed: 13#genhunterscript.srce Line 113 newRand := randnum(50) * 0.01; pos.y := pos.y + 1 + newRand;

It packed with no errors but still freezes.. When I unpacked, it was back in "not-supported" folder.. I must be missing something.

Sor3nt commented 2 months ago

good :)

try this

script AimTarget;
    var
        pos : vec3d;
        newRand: integer; {MHT add new variable}
    begin
        while(GetDamage(this) > 0) do begin
            Sleep(50);
            pos := GetPlayerPosition;
            {MHT: to complex => pos.y := pos.y + 1 + (randnum(50) * 0.01); }
            newRand := randnum(50) * 0.01;
            pos.y := pos.y + 1;
            pos.y := pos.y + newRand;

            {pos.y := pos.y + 1.1;}

Note: when you fix a "not-supported" file, you need to move the .srce to supported and delete all other relted files to the broken one

u MAY also need to increase the SMEM header 🤷

HoJo215 commented 2 months ago

Okay tried the above solution but when I go to pack it up, I get hex2bin error in mht?

███╗   ███╗██╗  ██╗████████╗    ██╗   ██╗   ██████╗    █████╗
████╗ ████║██║  ██║╚══██╔══╝    ██║   ██║  ██╔═████╗  ██╔══██╗
██╔████╔██║███████║   ██║       ██║   ██║  ██║██╔██║  ╚██████║
██║╚██╔╝██║██╔══██║   ██║       ╚██╗ ██╔╝  ████╔╝██║   ╚═══██║
██║ ╚═╝ ██║██║  ██║   ██║        ╚████╔╝██╗╚██████╔╝██╗█████╔╝
╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝         ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚════╝ 2024-09
                        Coded by Sor3nt | dixmor-hospital.com
A free and open source toolkit to quickly modify Rockstar`s game Manhunt.

Identify C:\Users\H\Desktop\manhunt-toolkit-master\export\A12_Plaza#mls as Levelscript PHP Fatal error:  Uncaught ErrorException: hex2bin(): Input string must be hexadecimal string in phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Service/Archive/Mls/Build.php:107
Stack trace:
#0 [internal function]: exception_error_handler()
#1 phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Service/Archive/Mls/Build.php(107): hex2bin()
#2 phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Service/Archive/Mls/Build.php(43): App\Service\Archive\Mls\Build->buildCODE()
#3 phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Service/Archive/Mls.php(161): App\Service\Archive\Mls\Build->build()
#4 phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Commands/pack.php(77): App\Service\Archive\Mls->pack()
#5 phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/mht.php(128): include('...')
#6 C:\Users\H\Desktop\manhunt-toolkit-master\mht.phar(10): include('...')
#7 {main}
  thrown in phar://C:/Users/H/Desktop/manhunt-toolkit-master/mht.phar/App/Service/Archive/Mls/Build.php on line 107

C:\Users\H\Desktop\manhunt-toolkit-master>
Sor3nt commented 2 months ago

please post your workspace (extracted mls)

HoJo215 commented 2 months ago
{#MHT SMEM:23356 | DMEM:55516}
scriptmain genHunterScripts;
entity hSniper(hunter)01 : et_name;
var self : string[32];
    ready : boolean;
    runGoalName, guardGoalName : string[74];
    subpackName, nodeName : string[32];
    deathScript : string[32];
    sniping : boolean;
    firstSniperKilled : level_var boolean;
    gsAcRangeNear_UZI, gsAcRangeMid_UZI, gsAcRangeFar_UZI, gsAcRadiusNear_UZI, gsAcRadiusMid_UZI, gsAcRadiusFar_UZI : game_var real;
    gsAcRangeNear_DEAGLE, gsAcRangeMid_DEAGLE, gsAcRangeFar_DEAGLE, gsAcRadiusNear_DEAGLE, gsAcRadiusMid_DEAGLE, gsAcRadiusFar_DEAGLE : game_var real;
    gsAcRangeNear_SNIPER, gsAcRangeMid_SNIPER, gsAcRangeFar_SNIPER, gsAcRadiusNear_SNIPER, gsAcRadiusMid_SNIPER, gsAcRadiusFar_SNIPER : game_var real;

procedure SetGunAccuracy(modifier : real); { Use a negative value to increase accuracy, e.g. -0.2 }
    var gunType : string[32];
    begin
        if(IsNamedItemInInventory(this, CT_UZI) > 0) then begin
            gunType := 'UZI';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_UZI, gsAcRadiusNear_UZI + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_UZI,  gsAcRadiusMid_UZI + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_UZI,  gsAcRadiusFar_UZI + modifier);
        end else if(IsNamedItemInInventory(this, CT_DESERT_EAGLE) > 0) then begin
            gunType := 'DESERT_EAGLE';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_DEAGLE, gsAcRadiusNear_DEAGLE + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_DEAGLE,  gsAcRadiusMid_DEAGLE + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_DEAGLE,  gsAcRadiusFar_DEAGLE + modifier);
        end else if(IsNamedItemInInventory(this, CT_SNIPER_RIFLE) > 0) then begin
            gunType := 'SNIPER_RIFLE';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_SNIPER, gsAcRadiusNear_SNIPER + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_SNIPER,  gsAcRadiusMid_SNIPER + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_SNIPER,  gsAcRadiusFar_SNIPER + modifier);
        end;
        WriteDebug(GetEntityName(this), ' is setting accuracy settings for ', gunType, ' - with a ', modifier, ' difficulty modifier');
    end;

script CreateMe;
    begin
        SetGunAccuracy(0.0);
        self := GetEntityName(this);
        ready := false;
        sniping := false;
        deathScript := '';
        StringCat(runGoalName, 'run-', self);
        StringCat(guardGoalName, 'guard-', self);
        if(self = 'hSniper(hunter)01') then begin
            firstSniperKilled := false;
            subpackName := 'sSniper01';
            nodeName := 'nRoofWave01_Snipe01';
        end;
        if(self = 'hSniper(hunter)02') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSniper02b';
        end;
        if(self = 'hSniper(hunter)03') then begin
            subpackName := 'sSniper01';
            nodeName := 'nSnipeBillboard01';
        end;
        if(self = 'hSniper(hunter)04') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSnipeCorner01';
        end;
        if(self = 'hSniper(hunter)05') then begin
            subpackName := 'sSniper01';
            nodeName := 'nSnipeBuilding';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)06') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSnipeBillboard02';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)07') then begin
            subpackName := 'sGuardCover01';
            nodeName := 'nSnipeRooftop03';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)08') then begin
            subpackName := 'sGuardCover02';
            nodeName := 'nSnipeLow02';
        end;
        if(self = 'hSniper(hunter)09') then begin
            subpackName := 'sSniper01';
            nodeName := 'nConsSnipe01';
        end;
        if(self = 'hSniper(hunter)10') then begin
            subpackName := 'sSniper02';
            nodeName := 'nExitSnipe01';
        end;

        if  (self = 'hSniper(hunter)01') or
            (self = 'hSniper(hunter)07') or
            (self = 'hSniper(hunter)08') then begin

            if (self = 'hSniper(hunter)01') then begin
                SetHunterHitAccuracy('hSniper(hunter)01', 5);
                SetHunterGunFireMinPause('hSniper(hunter)01', 10);
            end;
            if (self = 'hSniper(hunter)07') then begin
                SetHunterHitAccuracy('hSniper(hunter)07', 5);
                SetHunterGunFireMinPause('hSniper(hunter)07', 10);
            end;
        end;

        WriteDebug(self, ' - ', subpackName, ' - ', nodeName, ' - ', guardGoalName, ' - ', runGoalName);
        AIAddHunterToLeaderSubPack('leader(leader)', subpackName, self);
        AIDefineGoalGotoNode(runGoalName, self, AISCRIPT_VERYHIGHPRIORITY, nodeName, AISCRIPT_RUNMOVESPEED, true);
        AIDefineGoalOrbitEntity(guardGoalName, '', AISCRIPT_LOWPRIORITY, 'player(player)', 1, 100, 2);
        AIGuardModifyShootOutsideRadius(guardGoalName, true);
        AIModifyGoalCrouch(guardGoalName, true);
        AIModifyGoalAim(guardGoalName, true);
        AISetIdleHomeNode(self, nodeName);
        AIAddGoalForSubpack('leader(leader)', subpackName, runGoalName);
        while(AIIsGoalNameInSubpack('leader(leader)', subpackName, runGoalName)) do Sleep(10);
        AIAddGoalForSubpack('leader(leader)', subpackName, guardGoalName);
        RunScript(self, 'SnipeLoop');
        RunScript(self, 'AimTarget');
        WriteDebug(self, ' created...');
        ready := false;
    end;

script AimTarget;
    var
        pos : vec3d;
        newRand: integer; {MHT add new variable}
    begin
        while(GetDamage(this) > 0) do begin
            Sleep(50);
            pos := GetPlayerPosition;
            {MHT: to complex => pos.y := pos.y + 1 + (randnum(50) * 0.01); }
            newRand := randnum(50) * 0.01;
            pos.y := pos.y + 1;
            pos.y := pos.y + newRand;

            {pos.y := pos.y + 1.1;}
            if(sniping) then SetHunterAimTarget(this, pos) else ClearHunterAimTarget(this);
            if(CalcDistanceToEntity(this, GetPlayerPosition) < 6.0) then begin
                if(IsEntityAlive(self)) then RunScript(self, 'MoveToDefaultSubpack');
            end;
        end;
    end;

script SnipeLoop;
    var vis, tolerance : integer;
    begin
        while(IsEntityAlive(self)) do begin
            Sleep(750);
            {if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYLOWPRIORITY)) then WriteDebug('AISCRIPT_VERYLOWPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_LOWPRIORITY)) then WriteDebug('AISCRIPT_LOWPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_MEDIUMPRIORITY)) then WriteDebug('AISCRIPT_MEDIUMPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_HIGHPRIORITY)) then WriteDebug('AISCRIPT_HIGHPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYHIGHPRIORITY)) then WriteDebug('AISCRIPT_VERYHIGHPRIORITY');}
            vis := CalcVisibility(this, GetPlayer);
            if(vis < 9) then tolerance := 10 else begin
                if(tolerance > 0) then tolerance := tolerance - 1;
            end;
            if((tolerance > 0) and (AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYHIGHPRIORITY))) then begin
                if((not sniping) and (AIIsGoalNameInSubpack('leader(leader)', subpackName, runGoalName))) then begin
                    WriteDebug(self, ' start sniping');
                    sniping := true;
                    HunterShootAtEntityAuto(self, '', AISCRIPT_HIGHPRIORITY, 'player(player)', 0, 0, 0);
                end;
            end else begin
                if(sniping) then begin
                    WriteDebug(self, ' stop sniping');
                    sniping := false;
                    HunterShootAtEntityStop(self);
                end;
            end;
        end;
    end;

script BreakCover;
    begin
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        WriteDebug(self, ' breaking cover...');
        if(self = 'hSniper(hunter)03') then begin
            if(AIIsGoalNameInSubpack('leader(leader)', subpackName, guardGoalName)) then AIRemoveGoalFromSubpack('leader(leader)', subpackName, guardGoalName);
            if(IsGoalDefined(runGoalName)) then AIDeleteGoalDefinition(runGoalName);
            AIDefineGoalGotoNode(runGoalName, self, AISCRIPT_VERYHIGHPRIORITY, 'nSnipeBreak01', AISCRIPT_RUNMOVESPEED, true);
            AIAddGoalForSubpack('leader(leader)', subpackName, runGoalName);
            AISetIdleHomeNode(self, 'nSnipeBreak01');
        end;
        if(self = 'hSniper(hunter)05') then begin
            KillScript(self, 'SnipeLoop');
            KillScript(self, 'AimTarget');
            AISetIdleHomeNode(self, 'nHackRush01');
            AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
            Sleep(100);
            AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
            AIDefineGoalGotoNode('5break1', self, AISCRIPT_VERYHIGHPRIORITY, 'nHackRush01', AISCRIPT_RUNMOVESPEED, true);
            AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '5break1');
        end;
        if(self = 'hSniper(hunter)06') then begin
            AISetIdleHomeNode(self, 'nBillSnipeRun01');
            AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
            Sleep(100);
            AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
            Sleep(1000);
            AIDefineGoalGotoNode('6break1', self, AISCRIPT_VERYHIGHPRIORITY, 'nBillSnipeRun01', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break2', self, AISCRIPT_VERYHIGHPRIORITY, 'nBillSnipeRun02', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break3', self, AISCRIPT_HIGHPRIORITY, 'nBillSnipeRun03', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break4', self, AISCRIPT_HIGHPRIORITY, 'nBillSnipeRun04', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break5', self, AISCRIPT_MEDIUMPRIORITY, 'nBillSnipeRun05', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break6', self, AISCRIPT_MEDIUMPRIORITY, 'nBillSnipeRun06', AISCRIPT_RUNMOVESPEED, true);
            Sleep(1000);
            AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break1');
        end;
    end;

script OnHunterReachedNode;
    begin
        WriteDebug(self, ' reached node...');
        if(self = 'hSniper(hunter)03') then begin
            if(not AIIsGoalNameInSubpack('leader(leader)', subpackName, guardGoalName)) then AIAddGoalForSubpack('leader(leader)', subpackName, guardGoalName);
            RunScript(self, 'SnipeLoop');
            RunScript(self, 'AimTarget');
        end;
        if(self = 'hSniper(hunter)06') then begin
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun01') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break2');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun02') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break3');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun03') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break4');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun04') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break5');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun05') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break6');
        end;
    end;

script MoveToDefaultSubpack;
    begin
        while(not ready) do Sleep(100);
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        if(AIIsInSubpack('leader(leader)', subpackName, self)) then AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
        Sleep(100);
        AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
    end;

script OnDamage;
    begin
        if(self = 'hSniper(hunter)03') then begin
            if(IsEntityAlive(self)) then RunScript(self, 'MoveToDefaultSubpack');
        end;
        RemoveThisScript;
    end;

script OnDeath;
    var pos : vec3d;
    begin
        if(IsGoalDefined(runGoalName)) then AIDeleteGoalDefinition(runGoalName);
        if(IsGoalDefined(guardGoalName)) then AIDeleteGoalDefinition(guardGoalName);
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        if(self = 'hSniper(hunter)01') then begin
            firstSniperKilled := true;
        end;

        if(self = 'hSniper(hunter)08') then begin
            pos := GetEntityPosition(this);
            pos.y := pos.y + 0.4;
            SpawnMovingEntity('G_First_Aid_(CT)', pos, 'ScriptCreateName');
        end;

        if(deathScript <> '') then RunScript('leader(leader)', 'ReinforceSniperSection');
    end;

end.

untitled untitled2 untitled3

The error occurs once I remove the "not-supported" folder and pack.

Sor3nt commented 2 months ago

Ah got it, we miss the function "AIIsEnemyInSight", the function offset is missed :( need to check how i can get it.

edit: so far i can see, only our 13#genhunter use this function, do you know any other level ?

Sor3nt commented 2 months ago

never mind, found it, here we go mht.phar.zip (note: MDL/DFF handling is broken in this version....)

HoJo215 commented 2 months ago

Looks to be throwing the same error after deleting the "not-supported" folder. Also does the same on a simple unpack and pack without editing.

███╗   ███╗██╗  ██╗████████╗    ██╗   ██╗   ██████╗    █████╗
████╗ ████║██║  ██║╚══██╔══╝    ██║   ██║  ██╔═████╗  ██╔══██╗
██╔████╔██║███████║   ██║       ██║   ██║  ██║██╔██║  ╚██████║
██║╚██╔╝██║██╔══██║   ██║       ╚██╗ ██╔╝  ████╔╝██║   ╚═══██║
██║ ╚═╝ ██║██║  ██║   ██║        ╚████╔╝██╗╚██████╔╝██╗█████╔╝
╚═╝     ╚═╝╚═╝  ╚═╝   ╚═╝         ╚═══╝ ╚═╝ ╚═════╝ ╚═╝╚════╝ 2024-09
                        Coded by Sor3nt | dixmor-hospital.com
A free and open source toolkit to quickly modify Rockstar`s game Manhunt.

Identify C:\Users\H\Downloads\mht.phar(2)\export\A12_Plaza#mls as Levelscript PHP Fatal error:  Uncaught ErrorException: hex2bin(): Input string must be hexadecimal string in phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Service/Archive/Mls/Build.php:113
Stack trace:
#0 [internal function]: exception_error_handler()
#1 phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Service/Archive/Mls/Build.php(113): hex2bin()
#2 phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Service/Archive/Mls/Build.php(43): App\Service\Archive\Mls\Build->buildCODE()
#3 phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Service/Archive/Mls.php(161): App\Service\Archive\Mls\Build->build()
#4 phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Commands/pack.php(77): App\Service\Archive\Mls->pack()
#5 phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/mht.php(108): include('...')
#6 C:\Users\H\Downloads\mht.phar(2)\mht.phar(10): include('...')
#7 {main}
  thrown in phar://C:/Users/H/Downloads/mht.phar(2)/mht.phar/App/Service/Archive/Mls/Build.php on line 113

C:\Users\H\Downloads\mht.phar(2)>
Sor3nt commented 2 months ago

-.- sry, also HunterShootAtEntityStop and HunterShootAtEntityAuto was missed 🙈 the last one is tricky i hope i got the correct offset

mht.phar.zip

HoJo215 commented 2 months ago

We're getting there. That one packed up the new mls with no errors after "not-supported" folder was deleted.

It still froze after getting off the rooftop elevator though.. So it's probably back to the complex-math stuff. Wish I can help with that stuff but I suck at math..

Anymore tests I'll be sure to try out, but don't catch a headache over it. Thanks for taking time to work with me. It's appreciated.

Sor3nt commented 2 months ago

You can help, we do not know where the problem is but you can find out :)

there is a MLS command

displaygametext('DEBUG Step 1');

you can add these line (with custom text) where ever you want, we know the 13# file create the issue so place some "displaygametext" in the code to find the problem line.

you can also add some "sleep" calls to slow down the logic

mh modding 🤷 always pain ^^

HoJo215 commented 2 months ago

I need an example. Nothing is showing up.. I tried this:

displaygametext('DEBUG Step 1');
Sleep(200);

But nothing happens.

The crash seems to happen on the rooftop after getting outside elevator.. I sniper gun a few enemies and as I move to go to the next roof, it crashes. As if something is not loading / spawning?

edit:

Found another bug. A04_SM_Nightclub crashes at the very end.. I complete the level and after the in-game cutscene plays, the fmv cutscene never comes on. Just normal unpack / pack. No editing.

The reason I was editing all mls files was to turn off hunter detection with keeping the mouse in the circle.. To try to make a mod and make it more like manhunt 1.

Sor3nt commented 2 months ago

create for the crash stuff pls a new issue...

here i added you some debug output, you can see them ingame in the top left corner (once triggered) search for displaygametext to find the lines

{#MHT SMEM:23356 | DMEM:55516}
scriptmain genHunterScripts;
entity hSniper(hunter)01 : et_name;
var self : string[32];
    ready : boolean;
    runGoalName, guardGoalName : string[74];
    subpackName, nodeName : string[32];
    deathScript : string[32];
    sniping : boolean;
    firstSniperKilled : level_var boolean;
    gsAcRangeNear_UZI, gsAcRangeMid_UZI, gsAcRangeFar_UZI, gsAcRadiusNear_UZI, gsAcRadiusMid_UZI, gsAcRadiusFar_UZI : game_var real;
    gsAcRangeNear_DEAGLE, gsAcRangeMid_DEAGLE, gsAcRangeFar_DEAGLE, gsAcRadiusNear_DEAGLE, gsAcRadiusMid_DEAGLE, gsAcRadiusFar_DEAGLE : game_var real;
    gsAcRangeNear_SNIPER, gsAcRangeMid_SNIPER, gsAcRangeFar_SNIPER, gsAcRadiusNear_SNIPER, gsAcRadiusMid_SNIPER, gsAcRadiusFar_SNIPER : game_var real;

procedure SetGunAccuracy(modifier : real); { Use a negative value to increase accuracy, e.g. -0.2 }
    var gunType : string[32];
    begin
        if(IsNamedItemInInventory(this, CT_UZI) > 0) then begin
            gunType := 'UZI';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_UZI, gsAcRadiusNear_UZI + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_UZI,  gsAcRadiusMid_UZI + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_UZI,  gsAcRadiusFar_UZI + modifier);
        end else if(IsNamedItemInInventory(this, CT_DESERT_EAGLE) > 0) then begin
            gunType := 'DESERT_EAGLE';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_DEAGLE, gsAcRadiusNear_DEAGLE + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_DEAGLE,  gsAcRadiusMid_DEAGLE + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_DEAGLE,  gsAcRadiusFar_DEAGLE + modifier);
        end else if(IsNamedItemInInventory(this, CT_SNIPER_RIFLE) > 0) then begin
            gunType := 'SNIPER_RIFLE';
            HunterSetGunAccuracyNear(this, gsAcRangeNear_SNIPER, gsAcRadiusNear_SNIPER + modifier);
            HunterSetGunAccuracyMid(this,  gsAcRangeMid_SNIPER,  gsAcRadiusMid_SNIPER + modifier);
            HunterSetGunAccuracyFar(this,  gsAcRangeFar_SNIPER,  gsAcRadiusFar_SNIPER + modifier);
        end;
        WriteDebug(GetEntityName(this), ' is setting accuracy settings for ', gunType, ' - with a ', modifier, ' difficulty modifier');
    end;

script CreateMe;
    begin

        displaygametext('DEBUG CreateMe 1');
        SetGunAccuracy(0.0);
        self := GetEntityName(this);
        ready := false;
        sniping := false;
        deathScript := '';
        StringCat(runGoalName, 'run-', self);
        StringCat(guardGoalName, 'guard-', self);
        if(self = 'hSniper(hunter)01') then begin
            firstSniperKilled := false;
            subpackName := 'sSniper01';
            nodeName := 'nRoofWave01_Snipe01';
        end;
        if(self = 'hSniper(hunter)02') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSniper02b';
        end;
        if(self = 'hSniper(hunter)03') then begin
            subpackName := 'sSniper01';
            nodeName := 'nSnipeBillboard01';
        end;
        if(self = 'hSniper(hunter)04') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSnipeCorner01';
        end;
        if(self = 'hSniper(hunter)05') then begin
            subpackName := 'sSniper01';
            nodeName := 'nSnipeBuilding';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)06') then begin
            subpackName := 'sSniper02';
            nodeName := 'nSnipeBillboard02';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)07') then begin
            subpackName := 'sGuardCover01';
            nodeName := 'nSnipeRooftop03';
            deathScript := 'ReinforceSniperSection';
        end;
        if(self = 'hSniper(hunter)08') then begin
            subpackName := 'sGuardCover02';
            nodeName := 'nSnipeLow02';
        end;
        if(self = 'hSniper(hunter)09') then begin
            subpackName := 'sSniper01';
            nodeName := 'nConsSnipe01';
        end;
        if(self = 'hSniper(hunter)10') then begin
            subpackName := 'sSniper02';
            nodeName := 'nExitSnipe01';
        end;
        displaygametext('DEBUG CreateMe 2');

        if  (self = 'hSniper(hunter)01') or
            (self = 'hSniper(hunter)07') or
            (self = 'hSniper(hunter)08') then begin

            if (self = 'hSniper(hunter)01') then begin
                SetHunterHitAccuracy('hSniper(hunter)01', 5);
                SetHunterGunFireMinPause('hSniper(hunter)01', 10);
            end;
            if (self = 'hSniper(hunter)07') then begin
                SetHunterHitAccuracy('hSniper(hunter)07', 5);
                SetHunterGunFireMinPause('hSniper(hunter)07', 10);
            end;
        end;

        displaygametext('DEBUG CreateMe 3');

        WriteDebug(self, ' - ', subpackName, ' - ', nodeName, ' - ', guardGoalName, ' - ', runGoalName);
        AIAddHunterToLeaderSubPack('leader(leader)', subpackName, self);
        AIDefineGoalGotoNode(runGoalName, self, AISCRIPT_VERYHIGHPRIORITY, nodeName, AISCRIPT_RUNMOVESPEED, true);
        AIDefineGoalOrbitEntity(guardGoalName, '', AISCRIPT_LOWPRIORITY, 'player(player)', 1, 100, 2);
        AIGuardModifyShootOutsideRadius(guardGoalName, true);
        AIModifyGoalCrouch(guardGoalName, true);
        AIModifyGoalAim(guardGoalName, true);
        AISetIdleHomeNode(self, nodeName);
        AIAddGoalForSubpack('leader(leader)', subpackName, runGoalName);
        while(AIIsGoalNameInSubpack('leader(leader)', subpackName, runGoalName)) do Sleep(10);
        AIAddGoalForSubpack('leader(leader)', subpackName, guardGoalName);
        RunScript(self, 'SnipeLoop');
        RunScript(self, 'AimTarget');
        WriteDebug(self, ' created...');
        ready := false;
    end;

script AimTarget;
    var
        pos : vec3d;
        newRand: integer; {MHT add new variable}
    begin
        displaygametext('DEBUG AimTarget 1');

        while(GetDamage(this) > 0) do begin
            Sleep(50);
            pos := GetPlayerPosition;
            {MHT: to complex => pos.y := pos.y + 1 + (randnum(50) * 0.01); }
            newRand := randnum(50) * 0.01;
            pos.y := pos.y + 1;
            pos.y := pos.y + newRand;
            displaygametext('DEBUG AimTarget 2');

            {pos.y := pos.y + 1.1;}
            if(sniping) then SetHunterAimTarget(this, pos) else ClearHunterAimTarget(this);
            if(CalcDistanceToEntity(this, GetPlayerPosition) < 6.0) then begin
                if(IsEntityAlive(self)) then RunScript(self, 'MoveToDefaultSubpack');
            end;
        end;

        displaygametext('DEBUG AimTarget 3');

    end;

script SnipeLoop;
    var vis, tolerance : integer;
    begin
        while(IsEntityAlive(self)) do begin
            Sleep(750);

                    displaygametext('DEBUG SnipeLoop 1');

            {if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYLOWPRIORITY)) then WriteDebug('AISCRIPT_VERYLOWPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_LOWPRIORITY)) then WriteDebug('AISCRIPT_LOWPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_MEDIUMPRIORITY)) then WriteDebug('AISCRIPT_MEDIUMPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_HIGHPRIORITY)) then WriteDebug('AISCRIPT_HIGHPRIORITY');
            if(AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYHIGHPRIORITY)) then WriteDebug('AISCRIPT_VERYHIGHPRIORITY');}
            vis := CalcVisibility(this, GetPlayer);
            if(vis < 9) then tolerance := 10 else begin
                if(tolerance > 0) then tolerance := tolerance - 1;
            end;
            displaygametext('DEBUG SnipeLoop 2');
            if((tolerance > 0) and (AIIsEnemyInSight('leader(leader)', 'player(player)', AISCRIPT_VERYHIGHPRIORITY))) then begin
                displaygametext('DEBUG SnipeLoop 3');

                if((not sniping) and (AIIsGoalNameInSubpack('leader(leader)', subpackName, runGoalName))) then begin
                    WriteDebug(self, ' start sniping');
                    sniping := true;
                    HunterShootAtEntityAuto(self, '', AISCRIPT_HIGHPRIORITY, 'player(player)', 0, 0, 0);
                end;
            end else begin
                displaygametext('DEBUG SnipeLoop 4');
                if(sniping) then begin
                    WriteDebug(self, ' stop sniping');
                    sniping := false;
                    HunterShootAtEntityStop(self);
                end;
            end;

            displaygametext('DEBUG SnipeLoop 5');

        end;
    end;

script BreakCover;
    begin
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        WriteDebug(self, ' breaking cover...');
        if(self = 'hSniper(hunter)03') then begin
            if(AIIsGoalNameInSubpack('leader(leader)', subpackName, guardGoalName)) then AIRemoveGoalFromSubpack('leader(leader)', subpackName, guardGoalName);
            if(IsGoalDefined(runGoalName)) then AIDeleteGoalDefinition(runGoalName);
            AIDefineGoalGotoNode(runGoalName, self, AISCRIPT_VERYHIGHPRIORITY, 'nSnipeBreak01', AISCRIPT_RUNMOVESPEED, true);
            AIAddGoalForSubpack('leader(leader)', subpackName, runGoalName);
            AISetIdleHomeNode(self, 'nSnipeBreak01');
        end;
        if(self = 'hSniper(hunter)05') then begin
            KillScript(self, 'SnipeLoop');
            KillScript(self, 'AimTarget');
            AISetIdleHomeNode(self, 'nHackRush01');
            AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
            Sleep(100);
            AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
            AIDefineGoalGotoNode('5break1', self, AISCRIPT_VERYHIGHPRIORITY, 'nHackRush01', AISCRIPT_RUNMOVESPEED, true);
            AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '5break1');
        end;
        if(self = 'hSniper(hunter)06') then begin
            AISetIdleHomeNode(self, 'nBillSnipeRun01');
            AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
            Sleep(100);
            AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
            Sleep(1000);
            AIDefineGoalGotoNode('6break1', self, AISCRIPT_VERYHIGHPRIORITY, 'nBillSnipeRun01', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break2', self, AISCRIPT_VERYHIGHPRIORITY, 'nBillSnipeRun02', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break3', self, AISCRIPT_HIGHPRIORITY, 'nBillSnipeRun03', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break4', self, AISCRIPT_HIGHPRIORITY, 'nBillSnipeRun04', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break5', self, AISCRIPT_MEDIUMPRIORITY, 'nBillSnipeRun05', AISCRIPT_RUNMOVESPEED, true);
            AIDefineGoalGotoNode('6break6', self, AISCRIPT_MEDIUMPRIORITY, 'nBillSnipeRun06', AISCRIPT_RUNMOVESPEED, true);
            Sleep(1000);
            AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break1');
        end;
    end;

script OnHunterReachedNode;
    begin
        WriteDebug(self, ' reached node...');
        if(self = 'hSniper(hunter)03') then begin
            if(not AIIsGoalNameInSubpack('leader(leader)', subpackName, guardGoalName)) then AIAddGoalForSubpack('leader(leader)', subpackName, guardGoalName);
            RunScript(self, 'SnipeLoop');
            RunScript(self, 'AimTarget');
        end;
        if(self = 'hSniper(hunter)06') then begin
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun01') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break2');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun02') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break3');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun03') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break4');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun04') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break5');
            if(AIGetHunterLastNodeName(this) = 'nBillSnipeRun05') then AIAddGoalForSubpack('leader(leader)', 'sHuntCover', '6break6');
        end;
    end;

script MoveToDefaultSubpack;
    begin
        while(not ready) do Sleep(100);
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        if(AIIsInSubpack('leader(leader)', subpackName, self)) then AIRemoveHunterFromLeaderSubPack('leader(leader)', self);
        Sleep(100);
        AIAddHunterToLeaderSubPack('leader(leader)', 'sHuntCover', self);
    end;

script OnDamage;
    begin
        if(self = 'hSniper(hunter)03') then begin
            if(IsEntityAlive(self)) then RunScript(self, 'MoveToDefaultSubpack');
        end;
        RemoveThisScript;
    end;

script OnDeath;
    var pos : vec3d;
    begin
        if(IsGoalDefined(runGoalName)) then AIDeleteGoalDefinition(runGoalName);
        if(IsGoalDefined(guardGoalName)) then AIDeleteGoalDefinition(guardGoalName);
        KillScript(self, 'SnipeLoop');
        KillScript(self, 'AimTarget');
        if(self = 'hSniper(hunter)01') then begin
            firstSniperKilled := true;
        end;

        if(self = 'hSniper(hunter)08') then begin
            pos := GetEntityPosition(this);
            pos.y := pos.y + 0.4;
            SpawnMovingEntity('G_First_Aid_(CT)', pos, 'ScriptCreateName');
        end;

        if(deathScript <> '') then RunScript('leader(leader)', 'ReinforceSniperSection');
    end;

end.
HoJo215 commented 2 months ago

It worked!

The crash happened between 'DEBUG CreateMe 3' and 'DEBUG AimTarget 2' 'DEBUG CreateMe 1 & 2' never showed up at all..

If I turn off the cpu ai and travel down to the next building.. When I turn cpu ai back on, 'DEBUG AimTarget 2' pops up and crashes.

Sor3nt commented 2 months ago

okay nice, that means we still have a math issue, i can only guess but we calculate here with INT and FLOATS the convertion between them is not very good in MLS, since the calculation is actual not soo important, i would say change it to this

{MHT: to complex => pos.y := pos.y + 1 + (randnum(50) * 0.01); }
newRand := randnum(50);
pos.y := pos.y + 1;
pos.y := pos.y + newRand;

(without " * 0.01") 🤷

or try to twist it

{MHT: to complex => pos.y := pos.y + 1 + (randnum(50) * 0.01); }
newRand := 0.01 * randnum(50);
pos.y := pos.y + 1;
pos.y := pos.y + newRand;

mht has a convertion between int and float but not for all cases

also move or add some debug line so we know exakt the problem line

HoJo215 commented 2 months ago

Tried both positions and no luck.. Sometimes it freezes at the scaffold elevator but most time on that first roof.

I tried moving debug messages around too but only the same 'DEBUG AimTarget 2' pops up if I make it to there.. I'm thinking either enemies are not spawning or enemy's sniper rifle trajectory being off?

Something I do notice is the pc and wii versions have this:

        while(IsEntityAlive(self)) do begin
            Sleep(50);
            pos := GetPlayerPosition;
                        -------------------------
            if(sniping) then SetHunterAimTarget(this, pos) else ClearHunterAimTarget(this);
            if(CalcDistanceToEntity(this, GetPlayerPosition) < 6.0) then begin
                if(IsEntityAlive(self)) then RunScript(self, 'MoveToDefaultSubpack');

and ps2 and psp versions have this:

        while(GetDamage(this) > 0) do begin
            Sleep(50);
            pos := GetPlayerPosition;
                         -------------------------
            if(sniping) then SetHunterAimTarget(this, pos) else ClearHunterAimTarget(this);
            if(CalcDistanceToEntity(this, GetPlayerPosition) < 6.0) then begin
                if(GetDamage(this) > 0) then begin
                    RunScript(self, 'MoveToDefaultSubpack');
                    RemoveThisScript;

For the same exact part in the script. Not sure it helps.