LastSummonerOf() issues
Galactygon
Member, Developer Posts: 412
This was a known issue in the original game and persists in BGII:EE.
Existing behavior:
LastSummonerOf(Myself) is not stored whenever the game is saved and reloaded. To test this, download and unzip the attached files into the override folder and cast Monster Summoning III until you summon an Ettercap. The Ettercap should then follow the summoner around if it gets too far. Saving the game and then reloading will break this behavior because LastSummonerOf(Myself) is not stored in the saved game.
Expected behavior:
LastSummonerOf(Myself) should be properly stored in a saved game.
Suggested implementation:
My suggestion is to use a similar stat scheme as image projection (stat 138 PUPPETMASTERID on the caster and stat 141 PUPPETID on the duplicate from stats.ids). Each time a .cre is summoned, a stat called SUMMONERID is set on the caster, which is identical to the value of a stat SUMMONEDID set on the .cre. The values themselves are automatically set ingame so each summoner has a unique id, and then unset whenever all summoned .cres of a particular summoner are unsummoned. Both stats (SUMMONERID and SUMMONEDID) would be carried as an external .eff file on the .cre so it would be possible to store them in saved games.
Because using new stat id slots for would break detectable spells and mod compatibility, I suggest using the unused hardcoded stats (143 BERSERKSTAGE1 and 144 BERSERKSTAGE2) as replacements.
Existing behavior:
LastSummonerOf(Myself) is not stored whenever the game is saved and reloaded. To test this, download and unzip the attached files into the override folder and cast Monster Summoning III until you summon an Ettercap. The Ettercap should then follow the summoner around if it gets too far. Saving the game and then reloading will break this behavior because LastSummonerOf(Myself) is not stored in the saved game.
Expected behavior:
LastSummonerOf(Myself) should be properly stored in a saved game.
Suggested implementation:
My suggestion is to use a similar stat scheme as image projection (stat 138 PUPPETMASTERID on the caster and stat 141 PUPPETID on the duplicate from stats.ids). Each time a .cre is summoned, a stat called SUMMONERID is set on the caster, which is identical to the value of a stat SUMMONEDID set on the .cre. The values themselves are automatically set ingame so each summoner has a unique id, and then unset whenever all summoned .cres of a particular summoner are unsummoned. Both stats (SUMMONERID and SUMMONEDID) would be carried as an external .eff file on the .cre so it would be possible to store them in saved games.
Because using new stat id slots for would break detectable spells and mod compatibility, I suggest using the unused hardcoded stats (143 BERSERKSTAGE1 and 144 BERSERKSTAGE2) as replacements.
1
Comments
I don't know how the engine assigns summoned creatures in an MP game, though. It should know which player summoned them.
If that's true then the IESDP needs to be amended. They are mentioned as "This stat seems never to be set." so I thought they weren't used.
http://gibberlings3.net/iesdp/files/ids/bg2/stats.htm
Do you know of any hardcoded stats that are unused? Or is it possible to combine the hardcoded stats 142, 143, and 144 into one stat without breaking anything and free up two new slots?
Other hardcoded stats I can think of (combining?) are 88 STONESKINS and 199 STONESKINSGOLEM. I do not know what the differece is between the two besides that one is used by opcode 218 and the other by opcode 314.
Other hardcoded stats I do not know the use are:
61 IDENTIFYMODE (Identify spell/scroll is hardcoded to look for particular .spl/.itm?)
196 DEADMAGIC (aren't SPELLFAILURE stats used by opcode 60 which is used in dead magic areas?)
And then there is
195 DISABLETRACKING (even infravision is more useful)
http://forums.gibberlings3.net/index.php?showtopic=6083&p=71998
EDIT: The above thread also gives answer to what BERSERKSTAGE1 and BERSERKSTAGE2 do.
stat 199 STONESKINSGOLEM is just a way to bifurcate that from 88 STONESKINS so tha TOMEGOL4.cre can kill itself. See TOMEGOL4.bcs. Might be useful to place this explanation in the IESDP.
Some trigger like IsSpellActive(I:Spell*Spell,O:Object*) or IsSpellRESActive(S:Spell*,O:Object*) would have been cooler from the legacy devs but that is something not related to this issue.
There's note from Avenger saying "245 an 246 are also modifying CHECKFORBERSERK and BERSERKSTAGE1" but unless IESDP is wrong 245 and 246 calls for 247, which sets BERSERKSTAGE to 2, aka attack friends and foe alike. Am I wrong? Is there any way to implement a BERSERKSTAGE1 where the berserker attacks only enemies?
142 CHECKFORBERSERK
This stat is set by opcode 245 to the value of parameter 2. After a few hundred tries I was unable to get that reported 1% chance of berserking. Apparently this stat (and opcode 245) does nothing. Can anyone disprove this? No .itm or .spl uses this opcode (checked via WeiDU) in the game.
143 BERSERKSTAGE1
This stat is set by opcode 246 to the value of parameter 2. Works as reported in the IESDP. No .itm or .spl in the game uses this opcode or modifies this stat.
144 BERSERKSTAGE2
This stat is set by opcode 247 to the value of parameter 2. Works as reported in the IESDP. Only SPIN852.spl modifies this stat/uses this opcode.
Deadmagic is used by the spellfailure opcode
also, maybe 198 IMMUNITY_TO_SEQUESTER can be used? AFAIK, the 'immune to sequester' opcode (312) only causes crashes.
also, what about 108 PROFICIENCYBLACKJACK, is that one even used??
So there are plenty of unused hardcoded stats for the developers to choose from should they go with SUMMONEDID and SUMMONERID.
Galactygon: yes, using opcode 60 with 3/4/5 will set dead magic instead of normal spell failure (just different message)
The surplus weapon profs are not used.
Also, does any of these is used?
75 DONOTJUMP
77 MENTALSPEED
78 PHYSICALSPEED
77 MENTALSPEED - Used by opcode #189 (casting speed modifier)
78 PHYSICALSPEED - Used by opcode #190 (attack speed factor)
See here: http://gibberlings3.net/iesdp/opcodes/bgee.htm
Just out of curiosity, has anyone ever used "protection from opcode" then set opcode 101 as the parameter? Protection from "protection from opcode".