PDA

View Full Version : Ways to make CTD with script ?



Makanyane
12-08-2007, 16:49
:help:

I've had an occasional late game (100 plus turns running on auto) CTD which I think is probably due to script but can't find.

Have been through large chunk of script setting all the spawns and create_units to definitely happen within first 6 turns in hope of finding problem. Now have an occasional CTD happening at about turn 11 - which would be useful finding except I didn't set anything to happen that late :wall:

I know spawns can put two armies on same square, but when I've seen it happen its not been problem, apart from getting hold of your army to select it has to be done via the army list.

Does anyone have any idea if that could be causing random CTD on ai turn?

Also any other ideas what can cause CTD from script, only ones I've found so far and typo'd unit names, general names, or named_general without, command etc in a spawned army. Can misused conditions or counters do anything to it?

Mad Hoplite
12-08-2007, 20:08
Have been through large chunk of script setting all the spawns and create_units to definitely happen within first 6 turns in hope of finding problem. Now have an occasional CTD happening at about turn 11 - which would be useful finding except I didn't set anything to happen that late :wall:

Was the script the only thing you changed? If so, could you post it or, better yet, can you make a separate txt from it to download?

I'm no expert but I'll be glad to help.:holmes:

Makanyane
12-09-2007, 08:46
Thanks for the offer :yes:

The script was the only thing that I changed that moved the date of the CTD (changes also made it more frequent). I've got as far as narrowing it down to a set of spawns for one of the factions (by deleting big chunks of the script so that's all that's in it and its still crashing) it definitely doesn't occur on the exact turn they spawn but a while afterwards, so I think my hypothesis about it relating to getting two armies on same spot and problems when AI moves them might be right. Think I'm getting close to answer so will keep testing for a bit (then probably ask for help again!).

Makanyane
12-09-2007, 16:03
Very much simplified script - simple three spawns on same tile on subsequent turns results in randomly occuring CTD a random number of turns after last spawn. Can't duplicate reason when playing one of the spawned factions but stopping them spawning on same spot seems to stop problem (so far so good).

So need to try and add a check to see if anyone is on tile before spawning:


if whatever_conditions

;sets counter to stop spawn
if I_CharacterTypeNearTile alemanni general, 0 97,121
set_counter nospawn 2
end_if
if I_CharacterTypeNearTile alemanni family, 0 97,121
set_counter nospawn 2
end_if

;only triggers if army not on tile
if I_CompareCounter nospawn < 2
spawn_army
faction slave
character Moireabh, named character, command 1, influence 1, management 1, subterfuge 0, age 23, x 97, y 121
unit souleatergeneral, exp 1 armour 0 weapon_lvl 0
end
end_if

;reset for other if/monitors
if I_CompareCounter nospawn = 2
set_counter nospawn 0
end_if

; terminate_monitor
end_if
seems to work to just stop them spawning on exact same tile as alemanni, but would need same entry for all factions, luckily I haven't got full set of factions in use, but wonder if anyone knows of way of wording that for 'any faction' on tile that's shorter....?

Any other advice on lines of 'Scripters Guide to CTD's' might also be useful in-case there is anything else causing problem.

Myrddraal
12-10-2007, 05:47
Maybe use true_condition?

Just a wild guess :smile:

Makanyane
12-11-2007, 00:46
I did try TrueCondition at one point and it show_err'd unknown faction - though I might have missed correct way of phrasing...

anyway, I changed all spawns so they can't occur on occupied tile, which fixes the problem I induced by making all possible spawns happen in first few goes.
It doesn't however fix my random late stage CTD when used in script with proper triggers reinstated.. :wall:

Trying to isolate it is driving me slightly barmy.. Script is split basically into 5 sections with garrison and spawns for areas of map occupied by four main factions and then section for slave areas. If I run full script it CTD's fairly regularly somewhere around 150 turns in when playing via year jump started as two of the factions.

So I think ahha :idea2: remove one of the 5 sections relating to specific area of map completely and test.... lo, it doesn't CTD, so I make revised version of script with just the one suspect section I just removed in it, so I can proceed to isolate problem further..... but, the one suspect section on its own doesn't CTD either.

If you don't see me for a while its because I've thrown something heavy at computer ~:mad



Does anyone have any experience or any ideas at all about obscure hard to find ways of making script crash game???

Dol Guldur
12-11-2007, 01:26
Turn back from the Dark Side, Mak. Event scripts are evil....it's not too late...turn back now...or EoD will never be stable again... :no:

Squid
12-11-2007, 19:06
Silly question, but you're only checking for generals and family could other character types be causing the problem? If so maybe just check for the character type all.

As for the factions have you tried all for the factions you want to catch instead of doing it one faction at a time. Incidentally I have no idea if all would work or not, but it might be worth a try.

Makanyane
12-11-2007, 19:55
DG, I've been on the dark side for a Long time :P

Squid thanks for the idea but it doesn't accept all for either of those, I get faction type or character type not recognised message if I try, would have been useful if it had. I could try adding for other types specifically, still trying to work out why it seems happy to run any combination of four of my script sections just falls over (occasionally) when I have all five together ........

Makanyane
12-31-2007, 15:09
Update no.MMCXXVII for anyone I've been boring with this!

I did test and it didn't seem to mind having armies spawned on same square as agents. (it would be a lot more of a fluke for that to happen as well)


Anallein reminded me about problem with spawned_armies for human player - if they spawn outside your FOW they don't reset the FOW and you can't select them from campaign map. I'm not sure if that affects the AI when AI faction armies spawn or not but am back to testing script with a lot of spawns deliberately induced at start of game.

Getting a mixture of armies slave and faction spawned on first turn, some of which won't be visible from settlements/existing armies does indeed produce a random crash on some runs about 10/20 turns later.


Was trying to see if making the army spawn with a general instead of named character makes any difference and found it won't accept a spawned slave army with a general (though same one as named character works fine). Has anyone got any ideas on why that is, or if spawning slave armies by script is perhaps just a bad idea anyway?????

Other question is should you ensure that all spawns take place in area within line-of sight of settlement owned by spawning faction? In case AI does get version of the FOW problem....

Caius
12-31-2007, 18:30
If you are getting a CTD in the same turn with the same faction, is there any chance that faction is having the problem?

I'm a n00b at modding, but I'll help.

Makanyane
12-31-2007, 18:45
Thanks Caius, its good to see more people willing to help :2thumbsup:

unfortunately this one's not that simple. Definitely isn't same turn, lots of times it will run through 200 turns without problem. Damn thing has never done it when I can see it either, only has happened when running campaign under ai command using -ai on shortcut or when using year jump script, all with FOW on so I can't see if its any particular faction.

Attempts to watch it with FOW off (which takes a lot longer for it to go through) have so far resulted in either, it not crashing or me getting bored and looking away just before it happens..... :wall:


Having spawned armies for non-slave factions use generals and not named characters seems promising so far. My test script with a lot of armies spawned on turn one crashes about every other run through with named characters but not so far with generals.

The crashes happen quite a long while after the spawned armies have been placed and test script has terminated, so it seems there is some long term after effect to do with what happens to the spawned armies / characters later in the game..... umm, possibly..... I've been through quite a few theories on this already, and am about to go off and celebrate New Year.


Happy New Year all :clown:

Bardo
01-31-2008, 18:08
I'm interesting to know if you have discovered something new about this ctd caused by scripted army spawns.
We are using in lotr-tw a lot of army spawns, mostly using generals (not family memebers) and we do have some random ctds during ai turn that could be caused by the scripts. I'd like to know if it could be related to the command spawn army.

These are the only ctd causes that I have noticed using "spawn army":
-wrong general name (or not allowed for this faction)
-wrong unit name (or unit not allowed to this faction)
-it seems it is not possible to spawn naval units with this command: when you choose character type=admiral, and general unit=naval unit, and the position= sea tile, the army is still spawned as a land unit and this will cause ctds when some other army tries to attack it.

-once, we found a ctd caused by a wrong name in the names.txt that became much more frecuent when we used the scripts: since the scripts creates a lot of armies and the ai tends to split them, they need to use a lot of random names from the name pool of the faction and the ctds are more often if there is a misspelled name in the names.txt.
Maybe you have some kind of similar ctd here ??.

Makanyane
01-31-2008, 18:53
I'm afraid I got very fed up with testing it so didn't come up with anymore of a conclusive answer. It seems happy with the version with spawns not using named characters, is released and I'm not getting any reports of random looking CTD's.


Dol Guldur did spot for me later that I had some duplicate names for trait triggers which might have been adding to problem. Though I can't think of logical reason why it would only have crashed with script due to those.....

bad name, again I would expect to crash occasionally without script and I did spend hours/days running the damn thing with/without script and it refused ever to CTD without.


The suggestion Anallein made to me which made me consider again the spawns being possible source of problem was to do with the FOW problem you get if your faction acquires a spawned army for your faction out of your line of sight. The new army doesn't reset the FOW and is only selectable via the army list and not on the map. I was wondering if that might form some part of problem for AI, or whether spawned characters that don't get added to family tree can cause confusion later.


Does yours go frequently enough that you can get any sort of with / without scripted spawns comparison on -ai ?
(can't remember if you can get year-jump to work on Alex, that's faster if you can)

Squid
01-31-2008, 19:12
Question about the possible fow issue, first if my knowledge isn't totally wrong you should be able to turn it on and then off again in your script, if you can do that and you do that does it correctly set the FOW for out of sight spawned armies?

Anallein
01-31-2008, 20:38
Afaik resetting the FOW does not help with the problem.
The scripted armies also seem to 'swallow up' the FOW under certain conditions (to long ago to remember it all - will need to try out again) - for example if a scripted army was inside a city which was not 'lighted up' by a surrounding city or real army then the city itself becomes unavailable to select as well via the campaign map.

Squid
01-31-2008, 21:23
Well, there are two orders in which you can do the turn on, turn off of the FoW, and you might get different behaviour.

1) Spawn Army
Turn FoW Off
Turn FoW On

2) Turn FoW Off
Spawn Army
Turn FoW On

I'd figure the second way wouldn't cause any problems, because there would be no FoW to 'swallow up', and then putting it back 'should' not cause any problems.

Bardo
01-31-2008, 23:47
Vaya! I didn't know anything about this problem between spawned armies and the FOW.
Squid's solution looks ok, but I have never noticed this bug so I don't think I'll be able to verify the solution.
Just one think, this method would let the player to see all the map for a moment everytime the script spawns a new army, doesn't it?. I wonder if it would be enough to use the command "reveal_tile x,y" with the same tile than the spawned army. Do you know if the bug is related to the "fog of war" of the player or if it is related to the "field of view" of the faction that receives the army?



Does yours go frequently enough that you can get any sort of with / without scripted spawns comparison on -ai ?
I have used the comparison with -ai hundreds of times, but the results has changed with the diferent versions of the mod.
I have been using spawned armies since the beginning (2 years ago) and then I was able to play hundreds of turn without any ctd, so I'm almost sure that spawned armies can be used without causing ctds. These are things that I'm sure you can do without ctds:
-to use spawned armies including named characters (I have been using this to respawn the Nazguls for long time without any ctd).
-to spawn armies for the ai, out of the FOW of the player, and then these armies are properly used by the AI without ctds.
But I'm not sure if I have ever spawned armies out of the field of view of the faction who receives the army.

Currently, we have some random ctds, and they appear both with and without scripts activated, so I can't help much with testing. But it seems than the frecuency of our ctds are slightly more often with scripts (about 1 ctd every 50 turns or so). However, we use a big ammount of scripts, so there are many possible causes, I'm just trying to reduce the possibilities.

Squid
02-01-2008, 17:55
I had missed reveal_tile, but you may still have the same problem because depending on where an army is spawned as to how many times would need to be revealed. As for the player being able to see the entire map every time FoW was toggled, I'd think the toggle should happen quick enough that at most you'd see a flicker, but probably nothing at all.

Anallein
02-02-2008, 14:22
For the FOW issue it seems that after the character has been activated and moved he seems to be able to remove the FOW and become clickable via the strat map as well.

Here is an example script of how it works fine to spwan an army for the player and not to have the FOW problem.

monitor_event FactionTurnStart FactionType Spain
and I_TurnNumber = 1
spawn_army
faction spain
character Esugenos, named character, command 0, influence 0, management 0, subterfuge 0, age 40, , x 45, y 32
unit generic rebel general, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit aor caetrati falcata, exp 2 armour 0 weapon_lvl 0
unit rtr keltoi ambacti, exp 2 armour 0 weapon_lvl 0
unit rtr keltoi ambacti, exp 2 armour 0 weapon_lvl 0
unit rtr keltoi swordsmen, exp 2 armour 0 weapon_lvl 0
unit rtr keltoi swordsmen, exp 2 armour 0 weapon_lvl 0
unit aor iberian cavalry, exp 2 armour 0 weapon_lvl 0
unit aor iberian cavalry, exp 2 armour 0 weapon_lvl 0
unit aor iberian cavalry, exp 2 armour 0 weapon_lvl 0
unit aor iberian cavalry, exp 2 armour 0 weapon_lvl 0
end
move Esugenos, 45, 33
move Esugenos, 45, 32
replenish_action_points Esugenos
terminate_monitor
end_monitor

And 2 pics to show the effects of adding the movement and not:
https://i138.photobucket.com/albums/q262/Anallein_AAR/FOW%20issues/unabletoremovefow.jpg
https://i138.photobucket.com/albums/q262/Anallein_AAR/FOW%20issues/Solved.jpg

Red Spot
02-02-2008, 15:42
Reading up on this topic and seeing M2's campaign-scripts ... I'd almost call a few things "obvious" (though they arent in my scripts either ...:saint: )

Like making a character move after spawning solves the issue of FOW/not moving, M2's scripts move men around when spawned wich always has looked a bit odd to me, to script it as such, now it does ring a bell ...


Nice to know that moving people around after spawning has a purpose ... :)


G

Aradan
02-02-2008, 16:14
Great work on that Anallein!