Ask a simple question, get a simple answer

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: Ask a simple question, get a simple answer

Post 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!
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: Ask a simple question, get a simple answer

Post 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.
minmay
Posts: 2780
Joined: Mon Sep 23, 2013 2:24 am

Re: Ask a simple question, get a simple answer

Post 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.
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
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post 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.
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: Ask a simple question, get a simple answer

Post 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) :(
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post 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.
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: Ask a simple question, get a simple answer

Post 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,
}
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post 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
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Ask a simple question, get a simple answer

Post 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.
My asset pack [v1.10]
Features a bit of everything! :D
User avatar
AndakRainor
Posts: 674
Joined: Thu Nov 20, 2014 5:18 pm

Re: Ask a simple question, get a simple answer

Post 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.
Post Reply