Ressurection spell code

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!
Post Reply
User avatar
LordGarth
Posts: 500
Joined: Mon Jun 18, 2012 5:07 pm
Location: Colorado USA

Ressurection spell code

Post by LordGarth »

Here is code for a ressurection spell.

I will heal dead champions for 25 health
and do nothing for champions that are alive.




defineSpell{
name = "rez",
uiName = "Ressurection",
skill = "water_magic",
requirements = { "water_magic", 5, "earth_magic", 5 },
icon = 71,
spellIcon = 4,
gesture = 2365478,
manaCost = 150,

description = "Conjures a Light of Life that ressurects dead champions.",

onCast = function(champion, x, y, direction, elevation, skillLevel)
local dX,dY = getForward(party.facing) --Directional offsets
if party.map:isWall(party.x+dX, party.y+dY, party.elevation) then
dX,dY = 0,0 --Targets Party's cell if cast on a wall
end
--spell cast and tagged for the champion who cast it.
spawn("earthheal", party.level, party.x, party.y, party.facing, party.elevation)
local heal_amount = math.random(125,175)
hudPrint(champion:getName() .. " Casted Ressurection.")
for i=1,4 do
local c = party.party:getChampion(i)
if (c:getBaseStat("health") == 0) then
party.party:getChampion(i):modifyBaseStat("health", 25)
else
party.party:getChampion(i):modifyBaseStat("health", 0)
end

playSound("heal_party")
end
end

}



defineObject{
name = "earthheal",
baseObject = "base_spell",
components = {
{
class = "Particle",
particleSystem = "teleport_screen",
offset = vec(0, 1.5, 0),
},
{
class = "Light",
offset = vec(1.5, 1.0, 0),
color = vec(0.5, 0.5, 0.25),
brightness = 7,
range = 5,
fadeOut = 13,
disableSelf = true,
},
{
class = "CloudSpell",
attackPower = 0,
damageInterval = 2,
damageType = "fire",
duration = 1,



},

},
}
Dungeon Master and DOOM will live forever.
User avatar
Zo Kath Ra
Posts: 937
Joined: Sat Apr 21, 2012 9:57 am
Location: Germany

Re: Ressurection spell code

Post by Zo Kath Ra »

I don't mean to sound rude, but this has been bothering me for a while.

Why do people post code without indentation?
Indentation makes it *much* easier to read.

I'd also recommend using the

Code: Select all

[code]
[/code]tags.
Code enclosed in these tags can be copied quickly:
1) CODE:SELECT ALL
2) Ctrl-C

Code: Select all

for i = 1, 5 do
	hudPrint("Hello World!")
end
User avatar
Isaac
Posts: 3185
Joined: Fri Mar 02, 2012 10:02 pm

Re: Ressurection spell code

Post by Isaac »

Zo Kath Ra wrote:I don't mean to sound rude, but this has been bothering me for a while.

Why do people post code without indentation?
Indentation makes it *much* easier to read.
It's likely just unfamiliarity.

Indentation requires the tab key; afaik, forum software tends to strip out tabs and multiple spaces. One cannot use the tab key in the browser because it's used to change the focus.
Instead, one must generate [or copy/paste] the tab character to have indentation in manually typed code. When one pastes indented script into their post in or outside of code tags, it looks indented in the post-edit box, but if it's not wrapped in code tags, it gets stripped of its spaces and tabs when posted.
Post Reply