Skip to content
This repository has been archived by the owner on Apr 9, 2024. It is now read-only.

Commit

Permalink
Fixed saving of underworld spell effects to load properly in vanilla
Browse files Browse the repository at this point in the history
Spreadsheets of underworld spells and effects
  • Loading branch information
hankmorgan committed May 24, 2017
1 parent ac184b8 commit 54ca866
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
6 changes: 3 additions & 3 deletions UnityScripts/scripts/Magic/Magic.cs
Expand Up @@ -260,7 +260,7 @@ public void castSpell(GameObject caster, string MagicWords, bool ready)
case "In Lor": //Light
{
SetSpellCost(1);
Cast_LightSpells(caster,SpellEffect.UW1_Spell_Effect_Candlelight);
Cast_LightSpells(caster,SpellEffect.UW1_Spell_Effect_Light);
break;
} //il
case "Bet Wis Ex"://Locate
Expand All @@ -278,7 +278,7 @@ public void castSpell(GameObject caster, string MagicWords, bool ready)
case "Bet In Sanct"://Resist Blows
{
SetSpellCost(1);
Cast_ResistanceSpells(caster,SpellEffect.UW1_Spell_Effect_ResistBlows_alt01);
Cast_ResistanceSpells(caster,SpellEffect.UW1_Spell_Effect_ResistBlows);
break;
}//BIS
case "Sanct Hur"://Stealth
Expand Down Expand Up @@ -307,7 +307,7 @@ public void castSpell(GameObject caster, string MagicWords, bool ready)
case "Uus Por"://Jump
{
SetSpellCost(2);
Cast_UusPor(caster,SpellEffect.UW1_Spell_Effect_Leap_alt01);
Cast_UusPor(caster,SpellEffect.UW1_Spell_Effect_Leap);
break;
}//up
case "In Bet Mani"://Lesser Heal
Expand Down
2 changes: 1 addition & 1 deletion UnityScripts/scripts/Magic/SpellEffects/SpellEffect.cs
Expand Up @@ -726,7 +726,7 @@ public class SpellEffect : UWEBase {

///The number of ticks the effect last for and the the stability of the spell effect.
public int counter;
///The length of time of a tick.
///The length of time of a tick before a spell reduces it stability
public int TickTime =10;
///Effect Id of the current spell effect
public int EffectID;
Expand Down
Expand Up @@ -6,7 +6,7 @@ public class SpellProp_Light : SpellProp{
public override void init (int effectId, GameObject SpellCaster)
{
base.init (effectId,SpellCaster);
this.counter=5;//Should counter be a function of the casters casting ability
this.counter=5;//Should counter be a function of the casters casting ability as this drives the stability of the spell.
switch(effectId)
{//TODO:Review these light values.
case SpellEffect.UW1_Spell_Effect_Darkness: this.BaseDamage=1; break;
Expand Down
58 changes: 41 additions & 17 deletions UnityScripts/scripts/Player Character/SaveGame.cs
Expand Up @@ -503,7 +503,7 @@ public static void WritePlayerDat(int slotNo)

FileStream file = File.Open(Loader.BasePath + "save" + slotNo + "\\playertmp.dat",FileMode.Create);
BinaryWriter writer= new BinaryWriter(file);
int ActiveEffectIndex=0;
int NoOfActiveEffects=0;
int runeOffset=0;

//update inventory linking
Expand Down Expand Up @@ -594,27 +594,51 @@ public static void WritePlayerDat(int slotNo)
case 0x3E : /// character level (play_level)
DataLoader.WriteInt8(writer,GameWorldController.instance.playerUW.CharLevel);break;
case 0x3F:
case 0x41:
case 0x43://Active spell effect
//Active spell effect
{
for (int e = 0; e<3;e++)
{
if (GameWorldController.instance.playerUW.ActiveSpell[ActiveEffectIndex]!=null)
{
int effectId= GameWorldController.instance.playerUW.ActiveSpell[ActiveEffectIndex].EffectID;
//int effectID= ((val & 0xf)<<4) | ((val & 0xf0) >> 4*/
int byteToWrite =((effectId & 0xf0)>> 4) | ((effectId & 0xf) <<4);
DataLoader.WriteInt16(writer,byteToWrite);
}
else
{//No effect leave empty
DataLoader.WriteInt16(writer,0);
if (GameWorldController.instance.playerUW.ActiveSpell[e]!=null)
{
int effectId= 0;
int byteToWrite=0;

switch (GameWorldController.instance.playerUW.ActiveSpell[e].EffectID)
{//Fix spell effects that do not work with the nibble swap
case SpellEffect.UW1_Spell_Effect_Speed:
effectId=178;break;
case SpellEffect.UW1_Spell_Effect_Telekinesis:
effectId=179;break;
case SpellEffect.UW1_Spell_Effect_FreezeTime:
effectId=176;break;
case SpellEffect.UW1_Spell_Effect_RoamingSight://Should not appear in a save game
effectId=183;break;
default:
effectId=GameWorldController.instance.playerUW.ActiveSpell[e].EffectID;
break;
}
ActiveEffectIndex++;
break;
int stability = GameWorldController.instance.playerUW.ActiveSpell[e].counter;
byteToWrite =(stability <<8) | ((effectId & 0xf0)>> 4) | ((effectId & 0xf) <<4);

//int effectID= ((val & 0xf)<<4) | ((val & 0xf0) >> 4*/

DataLoader.WriteInt16(writer,byteToWrite);
NoOfActiveEffects++;
}
else
{//No effect leave empty
DataLoader.WriteInt16(writer,0);
}

}
break;
}

case 0x41:
case 0x43:
case 0x3F+1:
case 0x41+1:
case 0x43+1://Active spell effect. 2nd byte do nothing here.
case 0x43+1://Active spell effect. Addl. byte do nothing here.
break;
case 0x45://Runebits
case 0x46://Runebits
Expand Down Expand Up @@ -714,7 +738,7 @@ public static void WritePlayerDat(int slotNo)
break;
}
case 0x60 : /// bits 2..5: play_poison
DataLoader.WriteInt8(writer,GameWorldController.instance.playerUW.play_poison<<2);
DataLoader.WriteInt8(writer, (((NoOfActiveEffects & 0x3) <<6)) | GameWorldController.instance.playerUW.play_poison<<2);
break;
case 0x65: // hand, Gender & body, and class
{
Expand Down
Binary file added spell effects.xls
Binary file not shown.
Binary file added underworld spells.xls
Binary file not shown.

0 comments on commit 54ca866

Please sign in to comment.