Forcing the players to learn spells before using them.

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Balthasar
Posts: 32
Joined: Sun Dec 09, 2012 1:53 am

Forcing the players to learn spells before using them.

Post by Balthasar »

I would like to control spell progression through my dungeon.

For example, suppose I don't want the player to use Fireball until they 'learn' it from the scroll on floor 3 of the dungeon. Is it possible to make a consumable item that looks like a scroll, that enables use of a spell once it is used?

Is it possible to set a global variable to track if a party has learned a given spell?
User avatar
msyblade
Posts: 792
Joined: Fri Oct 12, 2012 4:40 am
Location: New Mexico, USA
Contact:

Re: Forcing the players to learn spells before using them.

Post by msyblade »

You can re define the spells, and just change the runes required to cast.
Currently conspiring with many modders on the "Legends of the Northern Realms"project.

"You have been captured by a psychopathic diety who needs a new plaything to torture."
Hotel Hades
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Forcing the players to learn spells before using them.

Post by Neikun »

Better than that, you should be able to change the spells to return false until a certain condition is met or something.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
User avatar
Diarmuid
Posts: 807
Joined: Thu Nov 22, 2012 6:59 am
Location: Montreal, Canada
Contact:

Re: Forcing the players to learn spells before using them.

Post by Diarmuid »

Because the scroll must be in the inventory to be read, you can use the new onEquipItem hook on the spell scroll, and have it set a variable to true somewhere on the first call of the hook. Then, put an onCast hook on the party and check for that variable for that spell and return false if scroll wasn't read.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Forcing the players to learn spells before using them.

Post by Grimwold »

Just to expand on the earlier solutions... for the spellbook/party hook part, add a script entity to your dungeon and name it appropriately e.g. spellbook_script

add to it the following code:

Code: Select all

spellbook = {fireburst=1,fireball=0,enchant_fire_arrow=0,fire_shield=0}

function checkSpellbook(caster,spell)
  if spellbook[spell] == 1 then
    return true
  elseif spellbook[spell] == 0 then
    hudPrint(caster:getName() .. " does not know " .. spell)
    return false
  end
end

function learnSpell(champ,spell,skill)
  if champ:getSkillLevel(skill) > 0 and spellbook[spell] == 0 then
    spellbook[spell] = 1
  end
end
note - you will need to expand the spellbook array (at the start of the script entity) to include the names of all the spells, and their initial learned state (where 1 = learnt, 0 = not learnt)

next clone the party definition, probably in init.lua as follows:

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",
   onCastSpell  = function(caster,spell)
      return spellbook_script.checkSpellbook(caster,spell)
   end,
}


Then for each spell you will need to clone the scroll for that spell as follows:

Code: Select all

	cloneObject{
		name = "scroll_fireball",
                baseObject = "scroll_fireball",
                onEquipItem = function(champion,slot)
                  spellbook_script.learnSpell(champion,"fireball","fire_magic")
                end,                  
	}
and make sure for each scroll you include the name of the relevant spell, and the skill to check for as a variable in learnSpell()

The skill check works by testing to see if the champion who equipped the scroll has the relevant skill above level 0.. so that, say, only if a fire mage equips the scroll does he get to learn fireball!
Ixnatifual

Re: Forcing the players to learn spells before using them.

Post by Ixnatifual »

This topic has been brought up before, and I agree AH's spell acquisition system could be improved upon. Making spells unavailable until you get the scroll brings some good things into the game. Scrolls are now actually useful and can give the player one of those "yay!" moments when you find one, similar to when you find a new axe for your fighter. Plus some people will be alt+tabbing less since they now can't automatically use spells as soon as they reach the right level, if they haven't found the scroll.

Of course there's now the danger of the player missing scrolls, but that's easily solved by making them easy to find, by providing an ample supply of them, or both.

I'm definitely going to check out Grimwold's script.
User avatar
Neikun
Posts: 2457
Joined: Thu Sep 13, 2012 1:06 pm
Location: New Brunswick, Canada
Contact:

Re: Forcing the players to learn spells before using them.

Post by Neikun »

Don't forget about a party with multiple mages as well.
"I'm okay with being referred to as a goddess."
Community Model Request Thread
See what I'm working on right now: Neikun's Workshop
Lead Coordinator for Legends of the Northern Realms Project
  • Message me to join in!
Ixnatifual

Re: Forcing the players to learn spells before using them.

Post by Ixnatifual »

Don't forget about a party with multiple mages as well.
I modified Grimwold's script a bit so scrolls are used similar to other items - you right click on them. If the character isn't skilled enough or already knows the spell, it says that on the screen. If it's a new spell, and the character is skilled enough, it plays a sound and tells the player he learned the spell. The way it works now the scroll doesn't disappear and can thus potentially be read by other mages in the party.

But the question is, how is a mage going to learn the spells that have no scrolls? I suppose you could create new spell scrolls, but I assume the rune images on the existing scrolls aren't dynamic, so the new scrolls would suck.
Ixnatifual

Re: Forcing the players to learn spells before using them.

Post by Ixnatifual »

Ixnatifual wrote:But the question is, how is a mage going to learn the spells that have no scrolls? I suppose you could create new spell scrolls, but I assume the rune images on the existing scrolls aren't dynamic, so the new scrolls would suck.
Found out the spell variable when put on scrolls solves this issue. I'll flesh out the stuff, based on Grimwold's code, and post it here.
User avatar
Xanathar
Posts: 629
Joined: Sun Apr 15, 2012 10:19 am
Location: Torino, Italy
Contact:

Re: Forcing the players to learn spells before using them.

Post by Xanathar »

Of course there's now the danger of the player missing scrolls, but that's easily solved by making them easy to find, by providing an ample supply of them, or both.
Actually this solution can also solve some balance/consistency problems. For example, it wouldn't make sense to make a strictly-better-than-fireball fire spell in AH system; if you have to find the scroll it makes sense to do it and simply hide the better spell in a very secret area while the standard spell could be easy to find (or in some cases even provided at game start - heck if you are a mage you are supposed to know something :D).
Waking Violet (Steam, PS4, PSVita, Switch) : http://www.wakingviolet.com

The Sunset Gate [MOD]: viewtopic.php?f=14&t=5563

My preciousss: http://www.moonsharp.org
Post Reply