Page 1 of 1

Ressurection spell code

Posted: Sun Dec 04, 2016 9:37 pm
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,



},

},
}

Re: Ressurection spell code

Posted: Sun Dec 04, 2016 10:19 pm
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

Re: Ressurection spell code

Posted: Mon Dec 05, 2016 12:18 am
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.