Quick scripting question.

Post Reply
uwill99
Posts: 61
Joined: Tue Aug 12, 2014 11:28 pm

Quick scripting question.

Post by uwill99 » Thu Sep 17, 2015 3:25 am

EDIT: I just looked in my updated sourcecode and saw this isn't how spells are done anymore. I'm stuck a few revisions back (5kb/sec download with frequent interrupts from satelites hitting these damn redwoods that surround my house, so I'll be out of date for a bit) so ignore, unless someone cares.

Settings.lua contains a variable stat, SPELL_POWER (along with others, ITEM_POWER, etc.) I copied the style in which hi_potion+3 worked, and came out with this to have spells reflect the SPELL_POWER setting.

Code: Select all

-----------------------------------------

require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
-----------------------------------------
-- OnSpellCast
-----------------------------------------

function onMagicCastingCheck(caster,target,spell)
	return 0;
end;

function onSpellCast(caster,target,spell)
	--doDivineBanishNuke(V,M,caster,spell,target,hasMultipleTargetReduction,resistBonus)
	local dmg = doDivineBanishNuke(180*SPELL_POWER,1,caster,spell,target,false,1.0);
	return dmg;
end;
My question is this: will mobs that cast Banishga II now absolutely rape? I'm asking beforehand because I started doing every spell before I took that in mind. If the way I'm doing it will result in overpowered mob casters giving me a taste of my own medicine, then could anyone provide an example of how to add SPELL_POWER to a spell, so that I can fix the rest?
Last edited by uwill99 on Thu Sep 17, 2015 4:46 am, edited 1 time in total.

uwill99
Posts: 61
Joined: Tue Aug 12, 2014 11:28 pm

Re: Quick scripting question.

Post by uwill99 » Thu Sep 17, 2015 4:15 am

And one more scripting question (now that I've basically just decided to plow ahead), which one of these luas is better than the other in determining spell damage:

Code: Select all

-----------------------------------------
-- Spell: Quake
-- Deals earth damage to an enemy.
-----------------------------------------

require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
-----------------------------------------
-- OnSpellCast
-----------------------------------------

function onMagicCastingCheck(caster,target,spell)
	return 0;
end;

function onSpellCast(caster,target,spell)
	--calculate raw damage
	local dmg = calculateMagicDamage(577*SPELL_POWER,2,caster,spell,target,ELEMENTAL_MAGIC_SKILL,MOD_INT,false);
	--get resist multiplier (1x if no resist)
	local resist = applyResistance(caster,spell,target,caster:getStat(MOD_INT)-target:getStat(MOD_INT),ELEMENTAL_MAGIC_SKILL,1.0);
	--get the resisted damage
	dmg = dmg*resist;
	--add on bonuses (staff/day/weather/jas/mab/etc all go in this function)
	dmg = addBonuses(caster,spell,target,dmg);
	--add in target adjustment
	dmg = adjustForTarget(target,dmg,spell:getElement());
	--add in final adjustments
	dmg = finalMagicAdjustments(caster,target,spell,dmg);
	--doElementalNuke(V,M,caster,spell,target,hasMultipleTargetReduction,resistBonus)
	local dmg = doElementalNuke(577,2,caster,spell,target,false,1.0);
	return dmg;
end;
or this:

Code: Select all

-----------------------------------------
-- Spell: Fire
-- Deals fire damage to an enemy.
-----------------------------------------

require("scripts/globals/magic");
require("scripts/globals/status");
require("scripts/globals/settings");
-----------------------------------------
-- OnSpellCast
-----------------------------------------

function onMagicCastingCheck(caster,target,spell)
	return 0;
end;

function onSpellCast(caster,target,spell)
	--doElementalNuke(V,M,caster,spell,target,hasMultipleTargetReduction,resistBonus)
	local dmg = doElementalNuke(133*SPELL_POWER,1,caster,spell,target,false,1.0);
	return dmg;
end;
Is one spell less up to date? I've only seen a few .luas that are in long form, and then the smaller, more compact ones seems to be missing out on stave calculations (unless that is done elsewhere). Anyway, thanks for your time, effort, and energy concerning these two posts.

Post Reply