Majesty Gold HD

Majesty Gold HD

Customize Majesty!
Create and upload new Quests and Mods for Majesty HD!
Weird debugger behaviour + questions about it
(1) So I would like to see all the function calls an agent makes.
- So I press the "|" key, debug window opens.
- Then I debug - http://puu.sh/twFoB/51540ff484.png
- Then I click on "Step Into" to step into the PerformAction function.
- But I end up in another funtion of ANOTHER ranger - http://puu.sh/twFpt/e011150fc0.png

(2) Also I'd like to see what function called the funtion I am debugging right now, is it possible to see? I have nightmares on figuring out how to stop heroes berserking, but I have to see what function call called the berserk function

(3) So I'am debugging. I'd like to see ALL the function the hero is making. But if I use "step into" or "step out" the debugger just exites as soon as the root function is done. Is not possible to observe ALL the functions a hero does?

(4) Lets say we have a task "function berserk_defend(agent thisagent)". In that, if the hero killed all the monsters he does "thisagent's "activescript" = thisagent's "basicscript";" So that the hero returs to normal activities. But where exactly does the code lead after that point? Where is the activescript gets evaluated?

ps. What I am trying to do is to have the hero to flee, instead of berserk. Sadly I fail to do it, they just keep berserking, even if I change the berserk behaviour to flee.
Last edited by Nice Bump! (chat off); 23 Jan, 2017 @ 4:58am
< >
Showing 1-8 of 8 comments
Cyberlore Dev  [developer] 1 24 Jan, 2017 @ 9:20pm 
The $PerformAction function you are trying to step into is a C++ side function, not a GPL function so the debugger can 'step' into it. The debugger is just going to run that function and try to return to the debugger at the next GPL operation. However, that call you show is at the end of the function you are debugging. i.e. There are only 'end' opcodes, which can't be stopped on, so essentially, once you say Step Into on that $PerformAction, the debugger is not going to be able to stop until another GPL function is called, which is why you are seeing it stop on some other Ranger's function.

In answer to (2), pressing the Callstack button in the debugger shows how the function was called, with the current function at the top of the list and what called it below. The C++ side calls the script functions that are attached to the object, i.e. its "Activescript" so off the bottom of the list is "C++ code that called the script"

(3) seems like you want a new type of breakpoint, similar to pressing the | key when a unit is selected, but keeping the breakpoint active until you say otherwise. I will look into this.

(4) Once an agent's "ActiveScript" is set, it is not immediately run. The rest of the current function is run, then the "ActiveScript" will be run the next time the agent is given some processing time. So in your example, the whatever the agent's basicscript was pointing to will be run at the agent's next update cycle.

Are you making an override function for Berserk? You should just be able to make a new GPL file with something like this (I have'nt compiled it) and add it to your mod

function berserk(agent thisagent) begin $flee_absolute(thisagent, #intent_flee_scared); end

You will probably have to override berserk_defend as well.

p.s. There seems to be a crash bug with the debugger if you try and use it again after starting a second game in the same session. I will fix it in the next update.
Alfryd 28 Jan, 2017 @ 7:37am 
Thanks for taking a look. If you're poking around with the debug functions, could you just double-check whether DebugOut calls are showing up in the logs? Neither amantalado or I could get those to work last time I checked.
Cyberlore Dev  [developer] 1 29 Jan, 2017 @ 4:15pm 
Originally posted by Alfryd:
Thanks for taking a look. If you're poking around with the debug functions, could you just double-check whether DebugOut calls are showing up in the logs? Neither amantalado or I could get those to work last time I checked.

It seems to be working for me. Do you have UseGPLDebugger set to 1 in your MajXPrefs? That needs to be on for the logging to be enabled. Do you see anything in the gpl.log file? The game should at least print out that it has started and will print the bytecode files it has loaded when you start a quest.
Alfryd 30 Jan, 2017 @ 5:28am 
My PC's not usable at the moment, but I'll check it later this week once I have the mouse/trackpad sorted.
Alfryd 1 Feb, 2017 @ 7:46am 
Yeah, I actually have UseGPLDebugger set to 1 along with UseDebugWindow, so in principle any log output is being flushed to the screen. Where would I normally find gpl.log?

Below is a sample of a simple adjustment I made to add log output to the Blessing spell, along with log output when I tried casting on a couple of passing henchmen. It doesn't look like the specific DebugOut arguments are showing up. Or am I doing something wrong?

https://s28.postimg.org/xrnmkkect/gpl_script_excerpt.png
https://s28.postimg.org/9zeb91cbv/debug_window_output.png
Alfryd 1 Feb, 2017 @ 8:29am 
(Just to verify that the .gpl was being compiled correctly, I tried bumping up the dodge/parry etc. stat bonuses from the blessing spell itself, and that showed up in the game just fine. But no sign of DebugOut.)
Last edited by Alfryd; 2 Feb, 2017 @ 4:05am
Alfryd 5 Feb, 2017 @ 9:21am 
Is that enough info to go on, or would you like me send on machine specs, etc.?
Alfryd 19 Apr, 2017 @ 4:51am 
I think there was a separate thread for this bug, but unfortunately I've forgotten the title, so I'll just post these here:

https://s16.postimg.org/5wy1g74g5/error_1.png
https://s16.postimg.org/ipm5g4g1x/error_2.png

Script error: Call Sequence was: $Release_Guards( (), Palace2#18) $IsHidden(false, ??#90) - line 106 ; Function $InsideBuilding( agent#90 ) failed: unit no longer exists Script error: Call Sequence was: $Release_Guards( (), Guardhouse1#22) - line 104 ; foreach list contains a NULL value in function $Release_Guards().
< >
Showing 1-8 of 8 comments
Per page: 1530 50