Page 1 of 1

Aura around monster.

Posted: Thu Jul 30, 2015 10:47 pm
by Emera Nova
So I have the spell pack that was made for LOG2 and it comes with a shit ton of spells.. For the party to use.

I'm wanting to make it so one of my boss's is able to release a fire aura around him that will burn the party if they are to close to it. Below is the spell's coding

Code: Select all

defineSpell{
  name = "fire_aura",
  uiName = "Fire Aura",
  skill = "fire_magic",
  requirements = {"fire_magic", 5},
  gesture = 1458,
  manaCost = 70,
  icon = 5,
  iconAtlas = "mod_assets/textures/gui/icons.tga",
  spellIcon = 5,
  spellIconAtlas = "mod_assets/textures/gui/spellIcons.tga",
  description = "Burns ennemies in melee range. Lasts 3 seconds per willpower point.",
  onCast = function(champion, x, y, direction, elevation, skillLevel)
    local time = 3 * champion:getCurrentStat("willpower")
    spells_functions.script.soundStart("fire_elemental_burn", 10)
    delayedCall("spells_functions", time-10, "soundStop", "fire_elemental_burn", 10)
    spells_functions.script.lightStart("fire_aura", 1, 0.5, 0.25, 10, 10, 10)
    delayedCall("spells_functions", time-10, "lightStop", "fire_aura", 10)
    for i = 0, time do delayedCall("spells_functions", i, "fireAuraPulse", champion:getOrdinal()) end
  end
}
And this is the coding for the functions that belong with that spell

Code: Select all

function fireAuraPulse(champion)
  fireAuraTile(-1, -1, champion)
  fireAuraTile(-1,  0, champion)
  fireAuraTile(-1,  1, champion)
  fireAuraTile( 0,  1, champion)
  fireAuraTile( 1,  1, champion)
  fireAuraTile( 1,  0, champion)
  fireAuraTile( 1, -1, champion)
  fireAuraTile( 0, -1, champion)
end

function fireAuraTile(dx, dy, champion)
  local w = party.map:getWidth()
  local h = party.map:getHeight()
  local x = party.x+dx
  local y = party.y+dy
  if (-1<x and x<w and -1<y and y<h) then
    local a = spawn("fire_aura_blast", party.level, x, y, party.facing, party.elevation)
    a.tiledamager:setCastByChampion(champion)
  end
end
Is it possible to make the boss give off this fire aura as a defense or no? I'd like to use it as a way to deal damage to the party if they are trying to side step the boss to much.

Re: Aura around monster.

Posted: Thu Jul 30, 2015 10:57 pm
by AndakRainor
This is an old version of my pack !!! The last one has MANY more spells :lol:

This code was made to center the aura on the party as you can see... But if you want I can adapt it for your boss, if you give me a little time ;)

Re: Aura around monster.

Posted: Thu Jul 30, 2015 10:59 pm
by Emera Nova
2 points.
1 @_@yus please <3 many luvs.
2 @_@you have a new pack?! OOOHHHMYYYYGAWD, more spells yus please.. x] may have to remove the current verison from my game..

Re: Aura around monster.

Posted: Fri Jul 31, 2015 9:20 pm
by AndakRainor
Ok here is the code:
SpoilerShow

Code: Select all

defineObject{
  name = "fire_aura_blast",
  baseObject = "base_spell",
  components = {
    {
      class = "Particle",
      particleSystem = "fire_aura",
      offset = vec(0, 0, 0),
      destroyObject = true,
      onInit = function(self) self:fadeOut(2) end,
    },
    {
      class = "TileDamager",
      attackPower = 1,
      castByChampion = 1,
      damageType = "fire",
      onHitMonster = function(self, monster)
        monster:setCondition("burning", 15)
        -- mark condition so that exp is awarded if monster is killed by the condition
        local burning = monster.go.burning
        local ordinal = self:getCastByChampion()
        if burning and ordinal then burning:setCausedByChampion(ordinal) end
      end,
    },
  },
}

defineObject{
  name = "fire_aura",
  baseObject = "base_spell",
  components = {
    {
      class = "Timer",
      timerInterval = 1,
      triggerOnStart = true,
      onActivate = function(self)
        local center, range, power = self.go.data:get("center"), self.go.data:get("range") or 1.5, self.go.data:get("power") or 10
        local r,r2 = math.ceil(range), range*range
        if center then
          center = findEntity(center)
          if center then
            self.go:setPosition(center.x, center.y, center.facing, center.elevation, center.level)
          end
        end
        local w,h = self.go.map:getWidth(), self.go.map:getHeight()
        local x1,x2 = math.max(0,self.go.x-r),math.min(w-1,self.go.x+r)
        local y1,y2 = math.max(0,self.go.y-r),math.min(h-1,self.go.y+r)
        local z1,z2 = math.max(-7,self.go.elevation-r),math.min(7,self.go.elevation+r)
        for x = x1,x2 do
          local dx = x-self.go.x
          for y = y1,y2 do
            local dy = y-self.go.y
            local dxy2 = dx*dx + dy*dy
            if dxy2 <= r2 then
              for z = z1,z2 do
                local dz = z-self.go.elevation
                local d2 = dxy2 + dz*dz
                if 0<d2 and d2<= r2 then
                  local blast = spawn("fire_aura_blast", self.go.level, x, y, self.go.facing, z)
                  blast.tiledamager:setAttackPower(power/d2)
                end
              end
            end
          end
        end
      end,
    },
    {
      class = "Script",
      name = "data",
      source = [[
        data = {center = "party", range = 1.5, power = 10}
        function get(self,name) return self.data[name] end
        function set(self,name,value) self.data[name] = value end
      ]],      
    },
  },
}

defineParticleSystem{
	name = "fire_aura",
	emitters = {
		-- glow
		{
			spawnBurst = true,
			emissionRate = 1,
			emissionTime = 1,
			maxParticles = 1,
			boxMin = {0, 1, 0},
			boxMax = {0, 1, 0},
			sprayAngle = {0,30},
			velocity = {0,0},
			texture = "assets/textures/particles/glow.tga",
			lifetime = {1000, 1000},
			colorAnimation = false,
			color0 = {1.500000, 0.495000, 0.090000},
			opacity = 0.1,
			fadeIn = 0.01,
			fadeOut = 0.5,
			size = {7, 7},
			gravity = {0,0,0},
			airResistance = 1,
			rotationSpeed = 0,
			blendMode = "Additive",
		},

		-- sparkles
		{
			emissionRate = 200,
			emissionTime = 1,
			maxParticles = 300,
			boxMin = {-1.3, -0.3,-1.3 },
			boxMax = { 1.3,  1.5, 1.3 },
			sprayAngle = {0,180},
			velocity = {0.1,0.5},
			objectSpace = false,
			texture = "assets/textures/particles/glitter_gold.tga",
			lifetime = {0.4,1},
			color0 = {1.8*1.5,1.8*1.5,1.2*1.5},
			opacity = 1,
			fadeIn = 0.1,
			fadeOut = 0.1,
			size = {0.03, 0.1},
			gravity = {0,2.3,0},
			airResistance = 0.01,
			rotationSpeed = 10,
			blendMode = "Additive",
		},
	}
}
This is a version of the fire_aura_blast with some particles, as the original had no visible effects (it was just there to make monsters start the burning animation). You can replace the one from the pack with it, it will just be a little more visual.
The second object fire_aura can be placed anywhere with the game editor. Then click on it and you will see it has a script component with its code embedded, so just replace the value of center with the id of your monster ("party" => "warden_1" in your case).
Also you can change the range of the aura and its power if you want.