Spells

(A framework for adding new spells)

The mod contains a number of spells. Each spell has an alignment (evil, neutral or good), an alignment level and a skill level.

Spells can only be cast on teen, adult or elder humanoids (ie not dogs or cats) that are alive. Spells cannot be cast on working NPCs (eg the newspaper girl, or the mail man); some spells cannot be cast on sleeping sims. Some spells cannot be cast on the caster.

When the player directs a Sim witch to cast a spell, only spells appropriate to the casters alignment and skill level are displayed.

Spells that a witch could cast, but has insufficient reagents for are greyed out.

Before casting the spell, the witch will stand and approach the target. If not possible, the spell will not be cast.

Spell casting starts, reagents are consumed and wand waving begins. There is a chance the witch will fail to correctly cast the spell, in extreame cases this will cause the spell to backfire. The failure chance decreases the more skillful the witch is relative to the spell level, so a witch of skill 900 will have a lower chance of failure casting a spell of level 500 than a witch that has only just reached the 500 skill level.

Assuming the spell is cast correctly, any wants/fears will be triggered.

The target will start to glow/sparkle (colours depend on the alignment of the spell).

The target may "save" (depending on their motives/skills) against the spell, in which case the target will suffer no effects from the spell, and any STR/LTR changes between the caster and the target will be halved.

Assuming the target doesn't save, the target will be affected by the spell, the caster will gain any alignment and/or skill changes from casting the spell, and any STR/LTR changes between the caster and target will be applied. Depending on the spell, there may also be STR/LTR changes between the onlookers and the caster applied.

Finally the caster will react, depending on the spell they may laugh at the target, just nod their head, or any other of the many possible Sim reactions.

This mod also provides a framework for making the task of adding new spells easier. Most of the code for casting spells is common, with just the conditions (reagents, alignment, skill, etc) and outcome being spell specific. The framework is mainly configured via BCONs for most spell casting actions, with just the outcome needed to be coded in BHAVs.


Included Spells

1 - Bladder Failure: The target pee's themself. On an "epic fail" the caster pee's themself.

2 - Energy Failure: The target passes out. On an "epic fail" the caster passes out.

3 - Steal Life Force: The target loses 1-3 days of their life (depends on witch's skill level) and passes out, while the caster gains these days. This spell takes a lot of energy, so the witch may also pass out. On an "epic fail" the witch will lose 1 to 3 days of their life and pass out.

4 - Light Fingers: The caster 'pickpockets' $50 to $150 from the target. On an "epic fail" the witch loses $50 to $150.

5 - Force to Clean: The target cleans (like Influence to Clean but without deducting influence points). NOTE: the animations are not as desired, as the caster approaches the target to 'ask' them to clean

6 - Force to Repair: The target repairs any broken items (same caveats as Force To Clean)

7 - Force to Garden: The target gardens (same caveats as Force To Clean)

8 - Force to Cook: The target cooks a meal (same caveats as Force To Clean)

9 - Force to do Assignment: The target will write an assignment for the caster (same caveats as Force To Clean)

10 - Force to do Term Paper: The target will write some of the caster's term paper (same caveats as Force To Clean)

11 - Force to Pay Rent: The target will pay any outstanding rent (same caveats as Force To Clean)

12 - Change Wants: Rerolls the targets wants (note, usually this achieves nothing!)

13 - Boost Motives: The targets motives (energy, hunger, social, et al) receive a boost of between 50 and 100, the exact boost depends on the skill level of the caster, the higher the skill the better the boost!


Configuration

Configuration of included spells is via BCONs. It is assumed you know how to open the .package file with SimPE and make these kind of changes.

BCON 0x1002 "General Parameters" is used to configure general aspects of the mod

  • 0x00: 'Number of spells' do NOT change this unless adding new spells (see section below)
  • 0x01: 'Explain invalid targets' set this to 0 to disable the notifications explaining why the caster will not cast the spell (eg on a working NPC)
  • 0x02: 'Room proximity limit' is the distance in 'tiles' that a caster in the same room as the target will be before they approach nearer
  • 0x03: 'Base cast failure%' is the base percentage change that the caster will fail to correctly cast the spell. This chance decreases as the caster's skill level relative to the skill level required to cast the spell increases. That is, a higher level witch is less likely to fail casting a spell than a lower level one.
  • 0x04: 'Saving throw limit' is the maximum a value in BCON 0x1004 'Saving Throw Parameters' can have. Do NOT change this value or the 16-bit mathmatics will break!
  • 0x05: 'Caster reaction - target saves' is the reaction (value from global BCON 0x0120) the caster gives if the target "saves" against a spell
  • 0x06: 'Caster reaction - cast fails' is the reaction (value from global BCON 0x0120) the caster gives when they fail to cast a spell
  • 0x07: 'Epic fail divisor' is the value used to determine if a failed casting is an "epic fail", ie, the spell backfires in some manner (eg the caster pee's themself instead of the target). If the caster's chance of failure is 15% and this value is set to 5, then their "epic fail" chance would be 3% (15% / 5)
  • 0x08: 'Explain casting failures' set this to 0 to disable the notifications explaining why the spell failed (eg the target saved, or the caster messed up)

Each of the four following BCONs contain SIX entries per spell. Entries 0x00 to 0x05 are unused by the code and are just used for labels. To calculate which BCON entry to change, multiply the spell number by 6 and add the number of the label, eg to change the skill level (label 2) of "Light Fingers" (spell 4) you would need to change entry number 0x1A (4 * 6 + 2 = 26, or 0x1A in hex)

BCON 0x1000 "Spell Parameters" is used to configure the spell casting requirements - alignment, skill level, etc and also the caster's reaction

  • 0x00: 'Alignment - Evil (-1 to -1000)' works in conjunction with entry 0x01, see below
  • 0x01: 'Alignment - Good (1 to 1000)' with entry 0x00 controls what type of witch can cast the spell. If this entry is positive AND entry 0x00 is zero or positive, this is a 'good' spell and can only be cast by witches with an aligment greater than or equal to this entry. If this entry is zero or negative AND entry 0x00 is negative, this is an 'evil' spell and can only be cast witches with an alignment less than or equal to entry 0x00. Otherwise, this is a 'neutral' spell and can only be cast by witches with an alignment greater than entry 0x00 and less than this entry
  • 0x02: 'Skill - Level (0 to 1000)' controls the required skill level for casting. Can only be cast by witches of the appropriate alignment (see entries 0x00 and 0x01) who have a skill greater than or equal to this entry
  • 0x03: 'Alignment change' controls the amount added to, or subtracted from if negative, the witches alignment for each successful cast of the spell
  • 0x04: 'Skill change' controls the amount added to the witches skill for each successful cast of the spell.
  • 0x05: 'Flags (hi byte) and reaction (from BCON 0x0120) (lo byte)' two values jammed into one entry, sorry about that. Consider this entry as two values 0xYY (lo-byte) and 0xZZ (hi-byte) stored as 0xZZYY. The lo-byte entry (0xYY) is a value taken from the global BCON 0x0120 (eg 0x0A - Laught At) and is used to control the casters reaction towards the target after casting the spell; a value of 0x00 is no reaction. The hi-byte entry is a set of 'flags' used to control aspects of the spell - see following
    • Flag 1 (0x01) - controls if the caster can cast the spell on themself (1=yes/0=no)
    • Flag 2 (0x02) - controls if the spell is disabled (ie doesn't appear on the menu of castable spells) (1=disabled/0=enabled)
    • Flag 3 (0x04) - controls if "sparkles" appear over/around the target when the spell is cast (1=glow only/0=glow+sparkles)
    • Flag 4 (0x08) - controls if the target can save against any motive/skill will an associated non-zero value in BCON 0x1004 'Saving Throw Parameters' of if they have to save against all of them (1=all/0=any)
    • Flag 5 (0x01) - controls if the spell can only be cast on awake targets (1=awake only/0=awake+sleeping)
    • Flags 6 thru 8 (0x04 thru 0x80) - currently unused

BCON 0x1001 "Reagents Parameters" is used to configure the amount of each reagent the spell consumes

  • 0x00: 'Dragon Scales'
  • 0x01: 'Essence of Light'
  • 0x02: 'Eye of Newt'
  • 0x03: 'Mystic Dust'
  • 0x04: 'Crystallized Moonbeams'
  • 0x05: 'Viper Essence'

BCON 0x1003 "STR/LTR Parameters" is used to configure the change to STR and LTR casting the spell causes

  • 0x00: 'STR change witch -> target'
  • 0x01: 'LTR change witch -> target'
  • 0x02: 'STR change target -> witch'
  • 0x03: 'LTR change target -> witch'
  • 0x04: 'STR change 3rd party -> witch'
  • 0x05: 'LTR change 3rd party -> witch'

BCON 0x1004 "Saving Throw Parameters" is used to configure the percentage chance a target has to save against the spell per point of their specific motive/skill value. Note these values are "times 100", so a value of 50 is half a percent.

  • 0x00: 'vs Body skill'
  • 0x01: 'vs Logic skill'
  • 0x02: 'vs Mechanical skill'
  • 0x03: 'vs Creativity skill'
  • 0x04: 'vs Energy motive'
  • 0x05: 'vs Social motive'

Note: A negative value "inverts" the saving throw, for example, a Sim with a creativity skill of 200 beinging targetted by a spell with a saving throw vs creativity of 50 would have a (200/10 * 50/100) = 10% chance of saving, the same Sim being targeted by a spell with a saving throw vs creativity of -50 would have a 90% chance of saving (for example, a "Have Nightmares" spell, where a Sim with less imagination would be more immune to its effects)


Conflicts

The mod has its own GUID so will not conflict with other mods.

  • Known NOT to conflict with the PandoraSims spells
  • Suspected NOT to conflict with Midge The Tree's spell mod (ie HCDU reports no conflicts)

Notes

  • Probably requires Ultimate Collection (M & G)

Adding a Spell

To add a new spell, you will need to perform the following steps

  • write (at least) TWO BHAVs (to cast and receive spell), refer to the "Social - Cast/Receive Spell - Xyz" BHAV pairs (eg 0x1100 and 0x1101)
  • add ONE string into STR#:"Action prim string set" (0x012E)
  • add TWO strings into TTAs
  • add TWO entries into TTAB, be careful how you clone these, they are subtly different! The "Cast" entry should have visitor unchecked (Flags Value = 0x0C31), while the "Receive" entry should have visitor checked (Flags Value = 0x0C30)
  • add SIX entries into the BCON:"Spell Parameters" (0x1000)
  • add SIX entries into the BCON:"Reagents Parameters" (0x1001)
  • add SIX entries into the BCON:"STR/LTR Parameters" (0x1003)
  • add SIX entries into the BCON:"Saving Throw Parameters" (0x1004)
  • increment the BCON:"General Parameters":"Number of spells" (0x1002:0x00) value

Techy Stuff

The main BHAV is 0x101A "Sub - Witch - Cast spell (index in P1) on P0 (OID) via P2 (OID)". If this BHAV returns true, the spell has been cast, the target has been affected and the associated "Social - Receive Spell" interaction has been pushed onto the targets queue. If this BHAV returns false, the spell has failed in some way and Temp 0 can be used to ascertain why.

  • 0x00 - spell not cast - target left lot, insufficient reeagents, invalid target, can't reach target, etc
  • 0x01 - target sleeping - spell can still take effect (eg lowering bladder to -100) but animations should not be played
  • 0x02 - casting failed - the witch messed up somehow. If 'Explain casting failures' is enabled, a text notification will be displayed.
  • 0x03 - target saved - the target saved. If 'Explain casting failures' is enabled, a text notification will be displayed.
  • 0x04 - epic failure - the witch messed up big time. Can be used to make the spell backfire, eg, the caster pee's themself or loses an amount of money.

This social mod has its own GUID. The Original GUID has been set to the mod's GUID and the Fallback GUID has been set to 0x00000000, so is Super-Duper Hug bug proof.

A lot of code has been taken from "Controller - Witch" (Group 0x7F6EB322), especially the code in BHAVs "Sub - Witch - Get wand in hand" (0x101C) and "Sub - Witch - Suceed or Fail FX" (0x101D)

The "Steal Life Force" spell is based on code from the "Elixir Of Life" object (GUID 0x6DA6AF29, Group 0x7F8E06DB)

The "Force to Clean" spell is based on code from the "Social - Influence Sim" object (GUID 0xAE815CB5, Group 0x7FD1A4B4) and the BHAV of the same name


Simblr Links


Credits

  • Inspired by posts #11408 to #11410 here
  • pandorasims for the original 'Bladder Buster' spell, traces of which can be found in this mod!
  • The developers of SimPE.
  • The Compressorizer.

Testing

The following areas of the framework have been tested and believed to be working for all spells

  • Spells being added (unless disabled flag set)
  • Spell icon colour being set (black/white/white)
  • Target is being checked (not me - unless flagged, only teen or older, no animals, no ghosts, no working NPCs)
  • Target rejection reason is being displayed (if configured)
  • Reagents are being checked
  • Skill level is being checked
  • Alignment is being checked
  • Target is being approached, if necessary
  • Turning to face target, when near enough not to approach
  • Correct spell is being cast
  • Failure to cast is being checked (base failure% * (1000 - caster skill + spell skill) / 1000)
  • Epic failures
  • Spell glow/sparkles dependant on spell flag
  • Spell sparkle/effect colours dependant on alignment of witch/spell
  • Target saves against motives (energy and social), skills (body, logic, mechanical and creatitity), any of multiple, all of multiple, inverted
  • STR/LTR witch <-> target are being changed (unless casting on self)
  • Half STR/LTR changes when target saves
  • STR/LTR bystanders -> witch are being changed (evil witches invert scores)
  • Skill level is changing
  • "Epic fail" decreases skill level
  • Alignment is changing
  • Reagents are being consumed
  • Wants are being fulfilled

Issues/Ideas

The following are issues that need resolving and ideas for future development

  • Issue: Force to Xyz - influence action is appearing in caster's queue
  • Issue: Force to Xyz - after casting, witch approaches target and "asks" them to xyz - this should not happen!
  • Issue: Force to Xyz - there is no "epic fail" outcome

Files