PDA

View Full Version : Very strange problem with kill_character script command



SigniferOne
03-12-2006, 08:27
I am working on a background script, one part of which is supposed to invoke the "kill_character" command, when triggered through an event_monitor. The problem is, that command is not invoked all the time, even though I know that the event monitor, which it is inside of, is triggered every time. The relevant code inside the monitor is:


console_command add_money 10000
campaign_wait 10
console_command kill_character "Gaius Fabricius"
campaign_wait 10
console_command add_money 10000
campaign_wait 10

I have the "add_money" commands before and after "kill_character", so that I can observe if the monitor has been invoked (when the first addition of money happens), and when the script inside the monitor has been completed (when the second addition of money happens).


Unfortunately, if "kill_character" is in the monitor, the first batch of money is added, so I know the monitor is invoked, but the second batch is not, indicating that the script advances no further, because the character to be killed remains there as well, and the second batch of money is not added. The presence of the "kill_character" command in the event_monitor somehow arbitrarily freezes the script engine for that turn, making it unable to do anything else. However, and here's the kicker, if I just keep pressing End Turn, the monitor continues to be triggered every turn, and eventually, at some arbitrary turn later, the "kill_character" does inexplicably go through. For bunches and bunches of turns nothing happens, and then at some random next turn, the script does go through and the character is killed.

Here's a brief explanation, in pictures.

The campaign is started anew. My character, the diplomat "Gaius Fabricius", is standing there, and waiting dutifully:
https://img147.imageshack.us/img147/9971/scripterror18lf.th.jpg (https://img147.imageshack.us/my.php?image=scripterror18lf.jpg)

The script is loaded through the F1 shortcut (thanks go out to Epistolary Richard :2thumbsup: ):
https://img84.imageshack.us/img84/7285/scripterror25xe.th.jpg (https://img84.imageshack.us/my.php?image=scripterror25xe.jpg)

Okay, the script is now loaded, the monitor is in the memory, and the character should be killed next turn. The next turn comes:
https://img147.imageshack.us/img147/8514/scripterror32vb.th.jpg (https://img147.imageshack.us/my.php?image=scripterror32vb.jpg)

Nothing. Maybe next turn? Again, nothing. I keep pressing Next Turn, nothing keeps happening. Many turns later:
https://img84.imageshack.us/img84/7451/scripterror47xe.th.jpg (https://img84.imageshack.us/my.php?image=scripterror47xe.jpg)
Gaius is still standing there, while the script continues running in the background.

However, I keep pressing Next Turn, and finally, many turns after the beginning of my experiment, Gaius Fabricius is inextricably killed on that and only that turn, not before:
https://img84.imageshack.us/img84/2651/scripterror52ht.th.jpg (https://img84.imageshack.us/my.php?image=scripterror52ht.jpg)

Can someone tell me what's going on? :wall:

Here's the entire script that's being loaded from the beginning:

script

declare_counter loop
set_counter loop 0

monitor_event FactionTurnStart FactionIsLocal
;declare_show_me
;hide_ui
;disable_entire_ui
suspend_unscripted_advice true

console_command add_money 10000
campaign_wait 10
console_command kill_character "Gaius Fabricius"
campaign_wait 10
console_command add_money 10000
campaign_wait 10

suspend_unscripted_advice false
;enable_entire_ui
;show_ui
end_monitor

while I_CompareCounter loop = 0
end_while

end_script

This script, and especially the monitor, is running during each turn. The initial money is added on each turn, but nothing happens otherwise, nor is the second batch added. Then, some arbitrarily many turns later, the monitor starts operation as usual, and actually completes through.

This is a really strange issue, which I hope someone knows how to deal with. The interesting thing with "kill_character" is that it always works outside of monitors, in direct scripts (start script, do X action, end). That always works. In monitors, the command seems to seriously falter.

Epistolary Richard
03-12-2006, 11:24
Try taking out the campaign_wait commands. And you can use console_command puppify_my_love to make sure the monitor is being accessed. It's more obvious than adding money.

nikolai1962
03-12-2006, 12:15
Did I read somewhere that the cheat code for adding money to your own faction can only be used once per session? Maybe that makes your code bounce out of your monitor after the first add money?

LorDBulA
03-12-2006, 15:53
nikolai1962 you are both right and wrong at the same time. Its true that when you use add_money command in console you can use it only once, but you can use it inside script freely.

dsyrow1 your problem are wait commands. We at EB had lot of problems with them.
Its better not to use them inside monitors. Using them causes many strange behaviors.
Just drop them and your code should work fine.

SigniferOne
03-12-2006, 17:38
Thanks guys, you were right, but this effect is the most weird thing. In direct (non-monitor) scripting, I've found that not having wait after every console_command introduces weird behavior.