spawn_agent crashes game [Mount & Blade]

Users who are viewing this thread

Hello everybody,

I encountered this problem some weeks ago, and I posted in the general mod makers Q&A thread about it. Unfortunately, nobody there could help me fix it. So I'm gonna try my luck by making a new thread for this problem, where there's no distraction by other problems.

The problem is simple: whenever I call the operation (spawn_agent, troop_id), the game will hang for a few seconds, then crash-to-desktop. I've tried lots of possible combinations of ode before calling this one, but nothing works. I simplified the code as much as possible to ensure that it wasn't affected by some other script, but it wtill causes a CTD.

I already searched the forums, and found some threads that had the same problem and got it solved, but when I tried to follow their steps it didn't work for me. Any help would be much appreciated.

The current code is as follows
Code:
("testing_uniquename_debug",
	 [(get_player_agent_no, ":player_no"),
	 (agent_get_team, ":team", ":player_no"),
	 (agent_get_position, pos1, ":player_no"),
	 (position_move_y, pos1, 150),
         (set_spawn_position, pos1),
	 (spawn_agent, "trp_xykon_zombie"),
	 (assign, ":new_agent", reg0),
	 (agent_set_position, ":new_agent", pos1),
	 (agent_set_team, ":new_agent", ":team"),
	 ]),
It's called from a mission_template that calls this script when [key_k] is pressed. I'm using normal Mount&Blade, not Warband or WFaS. One other thing I'm worried about which I think might be causing the crashes is the fact that I added a lot of new troop_slots, 56 to be precise. Perhaps they are causing this bug? This is the one thing I can't really test, as taking them out will make about two-thirds of my current code invalid, meaning it won't compile anymore.

Thanks in advance,
~~ArcaneSaint
 
try moving the code to the mission template instead of inside a script, I once found out you can't set animations inside script, maybe you can't spawn agent either...
 
Troop slots won't matter, since agents have their own slots. You don't need to use agent_set_position afterward. Make sure you don't have any conflicting ti_on_agent_spawn triggers. Try it with a different troop, and see if it's a problem with equipment.
 
@Ikaguia: I'm gonna try that out right away, but I don't think it will work in the long run as this is the extracted piece of code. It was originally part of a larger script.
EDIT: Nope, didn't work.  :sad:

Oh, something I forgot to mention. This code used to work fine, I used it in my mod before and it worked. It's only now (after adding the new slots, scripts and presentations) that it suddenly refuses to work properly. Although now that I think about it, in the previous version there was a presentation running when the script was cast, and it was triggered (and called) from inside that presentation's code instead of a mission_template trigger code.

I'll also try and see if that's the cause of the problem. Though doing  that will involve rewriting a couple of scripts and might take a while, so if anyone knows it that could actually be the problem let me know (weird that I never thought of that possibility).
 
Have you tried to put :
(set_fixed_point_multiplier, 100),
above the get position operation?

May be, with defaut fixed point multiplier (=1), position_move_y can make the pos1 beyond the map border.
 
HAHA! I got it fixed!

It works perfectly fine when called from a presentation, like this:
Code:
	   (try_begin),
	    (key_clicked, key_k),
	    (call_script, "script_testing_ootsmod_debug"),
	   (try_end),

but not when used from a mission template, like this:
Code:
common_battle_ootsmod_debugger = (
	0,0, 0, [], 
	[
	(key_clicked, key_k),
	 (call_script, "script_testing_ootsmod_debug"),
	])

Thanks for all the suggestions and offered advice! Though now the question arises, why is it that the spawning troop code won't work when called from a mission_template trigger, but does work when called from inside a presentation trigger? Was that done on purpose or is that because of a bug in the Module System?
 
Back
Top Bottom