Page 124 of 396

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 08, 2016 9:39 pm
by zimberzimber
Isaac wrote:You can tag the tile damager as coming from a specific PC like this:

Code: Select all

onCast = function(champ, x, y, direction, skill)
      local dx,dy = getForward(party.facing)
        
         spawn("wall_fire", party.level, party.x+dx, party.y+dy, direction, party.elevation).tiledamager:setCastByChampion(champ:getOrdinal())
            
   end,
Oh yes, this what I was looking for. Thank you, and minmay!

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 08, 2016 9:59 pm
by Isaac
It works ~in the sense that you can check it with [object_id].tiledamager:getCastByChampion()... but in practice I don't see any special XP treatment. :?

I just tested it with Zero XP characters, and found that after killing a monster with it, the whole party got the same experience bonus; actually PC 1 & 4 (humans) got 220xp, and PC 2&3 got 200xp. Only the mage ever damaged the monster [via the spell]... so I'm starting to wonder what setCastByChampion() is really for. :(

But they do get the XP... Unrelated tiledamagers that kill, don't award XP to the party.

Re: Ask a simple question, get a simple answer

Posted: Wed Jun 08, 2016 10:50 pm
by minmay
It doesn't matter which champion killed the monster in Grimrock 2, it just matters that a champion did it. You could always set the castByChampion to 1 if you wanted and it would work fine.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 11:57 am
by zimberzimber
Isaac wrote:I just tested it with Zero XP characters, and found that after killing a monster with it, the whole party got the same experience bonus; actually PC 1 & 4 (humans) got 220xp, and PC 2&3 got 200xp. Only the mage ever damaged the monster [via the spell]... so I'm starting to wonder what setCastByChampion() is really for. :(
As Minmay already said, it is used to check whether the party should receive XP, and it can be used with other scripts like checking how much damage a hero did, or other damage modifiers.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 2:42 pm
by Isaac
... But like minmay said, it doesn't seem to matter that any specific party member did the damage.
It may as well have been :setCastByParty(true) :(

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 7:20 pm
by zimberzimber
Isaac wrote:... But like minmay said, it doesn't seem to matter that any specific party member did the damage.
It may as well have been :setCastByParty(true) :(
Yes, if you don't plan on doing anything related to damage dealt by a champion or DPS checking.
For example, if a monster is immune to damage unless dealt by specific champion or by a champion that has a certain trait or item.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 9:08 pm
by Isaac
Updated that firewall spell to include environment checks. Now it appropriately reacts to doors and walls.

Code: Select all

defineSpell{
   name = "fireWall",
   uiName = "Firewall",
   gesture = 14,
   manaCost = 25,
   skill = "fire_magic",
   requirements = { "fire_magic", 3},
   icon = 60,
   spellIcon = 1,
   description = "Summons forth a fiery wall to incinerate your foes",
   
   onCast = function(champ, x, y, direction, skill)
      local dx,dy = getForward(party.facing)
      local test = party.map:checkObstacle(party, party.facing)
      if not test or test == "dynamic_obstacle" then
               spawn("wall_fire", party.level, party.x+dx, party.y+dy, direction, party.elevation).tiledamager:setCastByChampion(champ:getOrdinal())    
       else    spawn("wall_fire", party.level, party.x, party.y, direction, party.elevation).tiledamager:setCastByChampion(champ:getOrdinal())      
      end            
   end,
}

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 9:42 pm
by AndakRainor
Hey guys, making spells is way more complex than that ;)
You also have to test elevation when spawning ground spells! And if you want your fire wall to spawn on more than one tile, you will have to test every tiles :twisted:

Code: Select all

function checkGround(x, y)
  if party.map:getElevation(x, y) == party.elevation then return true end
  for e in party.map:entitiesAt(x, y) do
    if e.platform and e.platform:isEnabled() and e.elevation == party.elevation then return true end
  end
  return false
end

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 10:09 pm
by zimberzimber
AndakRainor wrote:Hey guys, making spells is way more complex than that ;)
You also have to test elevation when spawning ground spells!
Isn't that part of what isBlocked() does?
AndakRainor wrote:And if you want your fire wall to spawn on more than one tile, you will have to test every tiles
Or you can just give it an iceShards component which does that automatically.

Re: Ask a simple question, get a simple answer

Posted: Thu Jun 09, 2016 10:23 pm
by AndakRainor
zimberzimber wrote:Isn't that part of what isBlocked() does?
No, you have at least to test if the party is not in front of a tile with a lower elevation, in that case the ice shards spell does nothing.