Multiple magic schools spells pack

Ask for help about creating mods and scripts for Grimrock 2 or share your tips, scripts, tools and assets with other modders here. Warning: forum contains spoilers!
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Multiple magic schools spells pack

Post by zimberzimber »

Isaac wrote:Image

I also discovered interesting potential: This spell would allow for lateral movement on the way down, if I hadn't disabled it. Perhaps that effect could go in another spell; or as part of a rappelling effect with a custom rope asset.
Holy cow
I am definitely going to use that (if I don't forget about it :D)
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Multiple magic schools spells pack

Post by Isaac »

AndakRainor wrote:The slow fall effect comes from minmay's asset pack, with this code:

Code: Select all

if party.gravity:getFallingSpeed() > 7 then party.gravity:setFallingSpeed(7) end
It is interesting you used -1 instead, I think this is how you got the lateral movement allowed. But did you check if it prevents damage when you fall two maps lower? This is the problem sargris talked about. In Isle of Nex it can be seen in the crystal mine.
It does, and also the player has the option to cast it half-way down the pit, or even just before impact. That said, there seems to be an engine quirk that I need to look into (and fix the spell script). I cannot work on it until later tonight, but in tests [in editor only], there were times when the party reached the bottom, and didn't land... but rather just stopped slightly above ground, and remained that way even after the spell expired. :(
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Multiple magic schools spells pack

Post by minmay »

There's a reason the standard game only allows movement on one axis at a time. By allowing movement while falling/rising you're opening a huge can of very ugly worms.

The damage for falling down multiple consecutive pits is special. You've probably noticed that the damage from falls on a single level is directly proportional to the party's velocity when they hit the ground. But pits work differently: you can fall down 100 consecutive pits and won't get any more velocity than from falling down 1 pit, but the resulting damage will be a lot higher. Basically what happens is that when the party lands, both their velocity and the number of pits fallen through are used to compute the damage. When I originally made the Air Cushion spell I forgot about this behaviour and forgot to test it with multiple consecutive pits.
Grimrock 1 dungeon
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Multiple magic schools spells pack

Post by akroma222 »

Ok, it's possible I 'may' have found a way to do this...
Ive used my own Feather Foot condition (adapted from minmay's) in the example
- but all refs to sounds + fx have been commented out
condition : "feather_foot_1"
SpoilerShow

Code: Select all

defineCondition{
	name = "feather_foot_1",
	uiName = "Feather Foot",
	description = "\nYou Ignore Falling Damage/Injury",
	icon = 19,
	--iconAtlas = "mod_assets/textures/gui/conditions2.tga",
	beneficial = true,
	harmful = false,
	tickInterval = 0.1, 						-- will tick once per frame  0.00001
	onStart = function(self, champion, new)
		----------------------------------------
		if champion:hasCondition("slow") then
			champion:setConditionValue("slow", 0)
		end
		----------------------------------------
		conditionScripts.script.setFeather(champion, true)
		-----------------------------------------------------------------------------
	end,
	onTick = function(self, champion)
		--------------------------------------------fallingSpeed
		if party.gravity:getFallingSpeed() > 7 then 
			party.gravity:setFallingSpeed(6) 
		end	
		-------------------------------------------fall & landing FX
		if party.party:isFalling() then
			if not conditionScripts.script.checkFalling() then
				for i = 1,4 do
					if not party.party:getChampion(i):hasTrait("prevent_fall_injury") then
						party.party:getChampion(i):addTrait("prevent_fall_injury")
					end
				end
				conditionScripts.script.fallingNow(true)
				playSound("wind_01_short")
			end
			if self:getDuration() <= 1 then
				self:setDuration(3)
			end
			
		elseif not party.party:isFalling() then
			if conditionScripts.script.checkFalling() then
				playSound("magic_launch_06")
				delayedCall("conditionScripts", 0.02, "fallingNow", false)
				--conditionScripts.script.fallingNow(false)
				party.party:playScreenEffect("feather_landing")
				party.party:shakeCamera(0.5, 0.5)
				for i = 1,4 do
					if party.party:getChampion(i):hasTrait("prevent_fall_injury") then
						party.party:getChampion(i):removeTrait("prevent_fall_injury")
					end
				end
			end
		end
		-----------------------------------------------------------------------------
	end,
	onStop = function(self, champion)
		---------------------------------------------------------------
		conditionScripts.script.setFeather(champion, false)
		---------------------------------------------------------------stop enchant
		--partyEnchantmentScripts.script.featherFootStop()
		--------------------------------------------------------------------------------
	end,
}
hidden trait : "prevent_fall_injury"
SpoilerShow

Code: Select all

defineTrait{
	name = "prevent_fall_injury",
	uiName = "Prevent Fall Injury",
	icon = 0,
	hidden = true,
	description = "",
	onReceiveCondition = function(champion, cond, level)
		if level > 0 then
			if cond and (cond == "leg_wound" or cond == "feet_wound") then
				return false
			end
		end
	end, 
}
 
script_entity : "conditionScripts"
SpoilerShow

Code: Select all

----------------------------------------------partyFalling, fallTime
partyFalling = false	
fallTime = 0
---------------------------------------------checkFalling(), getFallTime(), 
function checkFalling()
	return partyFalling
end
function getFallTime()
	return fallTime
end
------------------------------------------------fallingNow(bool)
function fallingNow(bool)
	if isPartyFalling() == bool then
		partyFalling = bool
	end
	if not partyFalling then
		fallTime = 0
	end
end
------------------------------------------------isPartyFalling()
function isPartyFalling()
	local fall = party.party:isFalling()
	if fall then
		fallTime = fallTime + 1
		partyFalling = true
		--print("partyFalling =", partyFalling, fallTime)
		return true
	else
		fallTime = 0
		partyFalling = false
		--print("partyFalling =", partyFalling, fallTime)
		return false
	end
end
----------------------------------------------FEATHER SOFTFALL
featherActive = false
featherSafeLanding = false
featherOrds = {false, false, false, false}
-----------------------------------------------
function checkFeatherLanding()
	return featherSafeLanding
end
-------------------------------------setFeather(champion, bool)		
function setFeather(champion, bool)
	local ord = champion:getOrdinal()
	if bool and champion:hasCondition("feather_foot_1") then
		featherOrds[ord] = bool	
	elseif not bool and not champion:hasCondition("feather_foot_1") then
		featherOrds[ord] = bool	
	end
	if featherOrds == {false, false, false, false} then
		featherActive = false
	else
		featherActive = true
	end
	--print("Feather Foot Ords =", table.values(featherOrds))
end
----------------------------------getFeatherActive(champion)	
function getFeatherActive(champion)	
	local ord = champion:getOrdinal()
	return featherOrds[ord]
end	
and onDamage (add to your party hooks)
SpoilerShow

Code: Select all

onDamage = function(self, champion, damage, damageType)
	if damageType == "physical" then	
		if not party.party:isFalling() then
			if conditionScripts.script.checkFalling() then
				if champion:hasTrait("prevent_fall_injury") then
					--playSound("magic_launch_06")
					delayedCall("conditionScripts", 0.02, "fallingNow", false)
					--party.party:playScreenEffect("feather_landing")
					party.party:shakeCamera(0.5, 0.5)
					return false
				end
			end
		end
	end
end
EDIT: friendly with ceiling teleporters too :)
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Multiple magic schools spells pack

Post by Grimfan »

This should be a simple matter for most of the people frequenting these boards (you know who you are ;) ), but for some reason I can't successfully modify the custom frozen_champion condition in your spellpack Andak so that it is removed when the party has an ongoing cold protection effect like frost_shield. As I've said in another post I'm relearning lua after a long break and there are still things that are difficult for me to grasp, including modifications that SHOULD be straightforward. :(
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Multiple magic schools spells pack

Post by AndakRainor »

Try that:

Code: Select all

defineCondition
{ name = "frozen_champion",
  uiName = "Frozen",
  description = "You can't move, cast spells or attack.",
  icon = 0,
  iconAtlas = path.."textures/gui/conditions/frozen.tga",
  beneficial = false,
  harmful = true,
  tickInterval = 1,
  onStart = function(self, champion)
    GameMode.setGameFlag("DisableMovement", true)
    for i = 1,4 do if party.party:getChampion(i):getEnabled() and not party.party:getChampion(i):hasCondition("frozen_champion") then return end end
    GameMode.setGameFlag("DisableMouseLook", true)
    GameMode.setGameFlag("DisableKeyboardShortcuts", true)
  end,
  onStop = function(self, champion)
    playSound("ice_hit")
    GameMode.setGameFlag("DisableMouseLook", false)
    GameMode.setGameFlag("DisableKeyboardShortcuts", false)
    local o = champion:getOrdinal()
    for i = 1,4 do if i ~= o and party.party:getChampion(i):getEnabled() and party.party:getChampionByOrdinal(i):hasCondition("frozen_champion") then return end end
    GameMode.setGameFlag("DisableMovement", false)
  end,
  onTick = function(self, champion)
    if champion:hasCondition("frost_shield") then self:setDuration(0) end
  end,
}
With tickInterval = 1, the condition will call the onTick function I added every second. You can also use any other interval, 0 included (in this case the onTick function will be called every frame, it is just a little more performance heavy but the function itself is very light). This condition is special because a simple remove will not work with it, unlike other conditions. To remove it properly, we need to trigger its onStop function, that is why I used self:setDuration(0) instead.
Grimfan
Posts: 369
Joined: Wed Jan 02, 2013 7:48 am

Re: Multiple magic schools spells pack

Post by Grimfan »

Thank-you for your help Andak. I was so close to getting it as well. Hope you have a great weekend and thank-you for your ongoing contribution to the modding scene. :)
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Multiple magic schools spells pack

Post by AndakRainor »

Don't forget to test it a little in different scenarios, I did not test it myself :P
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Multiple magic schools spells pack

Post by AndakRainor »

Hi!

Just some news of the mod, the new version 3.0 is ready.
I am starting a new game with level 1 characters just now to test it before I release it in a few days :)
I replaced the multiple elemental shields with mage armor spells that increase some schools spell power and decrease others until canceled.
I also added a new alchemy system with a new mortar GUI, new potions and recipes, with custom models, textures and visual effects.
Also all bosses health has been reduced...
Many more little things have been improved like conditions, some new monsters and monster attacks. Among others things, the haste potion, spell and alter time can now be combined together :o

I will also update the spell pack, and maybe share a separate alchemy module in the downloads (many new potions use the spells pack functions).
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: Multiple magic schools spells pack

Post by akroma222 »

Most Excellent!
Looking forward to seeing the new changes :)
Akroma
Post Reply