Page 1 of 2

Disabling specific Spells Help

Posted: Sun Nov 09, 2014 8:23 pm
by Echoplex
So I'm trying to give special attention to the ambiance and lighting in levels. Id really like if folks couldn't just run around with light spell on 100% through the campaign. Is there anyway to disable a spell(specifcally the light spell) using a script that I could just copy and paste into each level?

Re: Disabling specific Spells Help

Posted: Mon Nov 10, 2014 11:04 am
by OGDA
Hi,

I'm searching for a way to check if the spell light is active or cast darkness on the party, too.
It seems that they cannot be cast by spawners. I managed to check if the party is holding a torch, but with the spells I have no clue for now.

So... push. :)

Kind regards,
Joerg

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 12:25 am
by OGDA
Hi,

I still have not solved this problem, so if anyone can help...

Here is what I do so far:

In \mod_assets\scripts\init.lua I check if the spell "light" is cast, and if this happens, the script and function script_entity_88.script:darknesscast() are called.

Code: Select all

defineObject{
	name = "party",
	baseObject = "party",
	components = {
		{
		class = "Party",  
		onCastSpell = function(party,champion,spellName)
			if spellName == "light" then
				--hudPrint(spellName)
				script_entity_88.script:darknesscast()
			end		  
		end
		}
	},
}
I noticed, that a character who casts the spells light or darkness has the Traits "Darkness" and/or "Light" in his trait window together with other traits like "Aura", "Meditation" and so on.

However, when I check with an extra script for these traits, I get no result:

Code: Select all

for i = 1,4 do
  if party.party:getChampion(i):hasTrait("Aura") then
    hudPrint("found")
  end
end
It doesn't matter if I search with hasTrait for Aura, Meditation, Light, Darkness... they are never found.
Also when I try to set or remote traits with addTrait(string) or removeTrait it doesn't work.

Has anyone an idea what's up with the trait functions?

They are from the Champion-class, setFood(number) from the same class for example works without problems:
for i = 1,4 do
party.party:getChampion(i):setFood(400)
end

Code: Select all

class Champion
    setEnabled(boolean)
    setName(string)
    setRace(string)
    setSex(string)
    setClass(string)
    setHealth(number)
    getEnabled
    getName
    getRace
    getSex
    getClass
    getDualClass
    getLevel
    getOrdinal
    setPortrait(string)
    isAlive
    gainExp(number)
    levelUp
    getSkillPoints
    addSkillPoints(number)
    getSkillLevel(string)
    trainSkill(number,string,string)
    addTrait(string)
    removeTrait
    hasTrait(string)
    setFood(number)
    getFood
    consumeFood(number)
    modifyFood(number)
    setCondition(string)
    removeCondition(string)
    hasCondition(string)
    setConditionValue(number,string,string)
    getConditionValue
    damage(string,number)
    playDamageSound(string)
    playSound
    showAttackResult(string,any)
    setBaseStat(number,string)
    modifyBaseStat(number,string)
    upgradeBaseStat(number,string)
    addStatModifier(number,string,string)
    getBaseStat(string)
    getCurrentStat(number)
    regainHealth(number)
    regainEnergy(number)
    getHealth
    getMaxHealth
    getEnergy
    getMaxEnergy
    getProtection
    getEvasion(string)
    getResistance
    getLoad
    getMaxLoad(string)
    getArmorSetPiecesEquipped(string)
    isArmorSetEquipped
    insertItem(ItemComponent,number,ItemComponent)
    removeItem(number)
    removeItemFromSlot(number)
    getItem(number)
    getOtherHandItem
    playHealingIndicator

Kind regards,
Joerg

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 12:46 am
by minmay
Can't you just redefine the light spell with defineSpell{} to have a nil gesture so it's uncastable like blob? Or if that doesn't work anymore in LoG2, redefine it and give it impossible requirements (e.g. concentration skill 500).

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 10:36 am
by OGDA
Hi,

I don't want to disable the light spell, because I think that general disabling of function is not a good design.
I want do temporarily make light unavailable in certain level areas because of the level design.

When the player casts light before he enters that area, he could get around this.
So I need to remove the light-spell/trait when he enters the area and if he casts light in the area he gets punished for it because of lore.

The punish-part is possible as I can check if light is cast and then use a normal script to check the area and do other things.

What I haven't found out is how to remove the light-trait when entering that area so that the player really has no own light in that part of the dungeon.
Or how to overwrite light with casting a darkness spell.

Kind regards,
Joerg

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 1:43 pm
by JKos
Try

Code: Select all

      onCastSpell = function(party,champion,spellName)
         if spellName == "light" then
            return false
         end       
      end
IIRC this worked in LoG1.

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 1:51 pm
by OGDA
Hello JKos,

thank you for your answer, but unfortunately this is not the desired behaviour as I don't want do disable the light spell.
I need to remove the light trait or cast a darkness spell (see posts above).

It might however be the solution for Echoplex.

Kind regards,
Joerg

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 1:57 pm
by JKos
How about this?

Code: Select all

      onCastSpell = function(party,champion,spellName)
         if party.level == 2 and spellName == "light" then
            hudPrint("Light spell doesn't seem to have effect in here...blablabla")
            return false
         end       
      end
Disables light spell on level 2 only.

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 2:03 pm
by OGDA
The problem is that the duration of the light spell is really long:

The party can cast the light spell on the stairs of level 1 and proceed to level 2.
They could have light through the whole level 2.

Re: Disabling specific Spells Help

Posted: Tue Nov 11, 2014 6:00 pm
by JKos
one possible solution is that you create your own "light spell" and implement it so that it can be turned off. You can for example try to add LightComponent to the party and then in onCastSpell you can do something like this:

Code: Select all

      onCastSpell = function(party,champion,spellName)
         if spellName == "light" then
		    --activate party.light. Don't know if it works this way.
			party.light.setDisable(false) 
			return false
         end       
      end

then you can disable it any time you want by calling party.light.setDisable(true)
This code isn't tested, and probably doesn't work, but I hope you got the idea.