Please help...

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
CainOrdamoth
Posts: 34
Joined: Sun Mar 08, 2015 1:45 am

Please help...

Post by CainOrdamoth »

Hi, all. So I've recently been experimenting with making custom items and spells, but I've run into some things I need help with. They're probably very simple errors, but I'm relatively new to this whole thing, so I'd greatly appreciate help.

Firstly, I'm making some new spells. Everything works fine, the spell works if I use a spawner, but when I try to have the party cast it, I get an error. This script is something I sort of pieced together from other people's custom spells, so its probably not exactly what's needed, and I get an error under the shootProjectile component.
SpoilerShow
defineSpell{
name = "meteor",
uiName = "Meteor",
gesture = 145236,
manaCost = 60,
skill = "fire_magic",
requirements = { "fire_magic", 5 },
icon = 61,
spellIcon = 7,
onCast = function(champion, x, y, direction, elevation, skillLevel)
local dx,dy = getForward(party.facing)
playSound("fireball_launch")
shootProjectile("meteor", party.level, party.x+dx, party.y+dy, direction, 10, 0, 0, 0, 0, 0, 0, nil, true)
end
}
My next issue is probably a much simpler one. I've created a new dagger, and again it all works fine, except the gfxIndex for the power attack. I have it all set up correctly, as far as I can see. the gfxAtlas and Index for the base weapon work fine, but when I charge the power attack, the sprite uses the original Grimrock altas (in this case, the dagger morphs into a peasant's shirt when its charged up). I can't seem to get the gfxIndexPowerAttack to work off the custom atlas I made, but the regular gfxIndex is fine.
SpoilerShow
class = "Item",
uiName = "Ceremonial Dagger",
gfxAtlas = "mod_assets/textures/gui/my_items_1.dds",
gfxIndex = 6,
gfxIndexPowerAttack = 7,
impactSound = "impact_blade",
weight = 2.5,
secondaryAction = "leech",
traits = { "light_weapon", "dagger" },
Thanks for the help, I apologise if these are really nooby questions, but I'm still learning about this stuff :P. Cheers!
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Please help...

Post by minmay »

The shootProjectile() global function doesn't work in Grimrock 2, but that's okay because it is obsolete. Spawn the projectile instead (using ItemComponent:throwItem() if it is an item). Here is the skeleton for a projectile spell:

Code: Select all

onCast = function(champion, x, y, direction, elevation, skillLevel)
      local spl = spawn("fireball_large",party.level,party.x,party.y,party.facing,party.elevation)
      spl.projectile:setIgnoreEntity(party)

      -- Set cast by champion so that experience is awarded for kills.
      local ord = champion:getOrdinal()
      spl.projectile:setCastByChampion(ord)

      -- Simulate the position of a player-cast spell.
      local left = nil
      for i = 1,4 do
        if party.party:getChampion(i):getOrdinal() == ord then
          left = i == 1 or i == 3
          break
        end
      end
      local wpos = party:getWorldPosition()
      local dx = nil
      local dz = nil
      if party.facing == 0 then
        dx = left and -0.1 or 0.1
        dz = -1
      elseif party.facing == 1 then
        dz = left and 0.1 or -0.1
        dx = -1
      elseif party.facing == 2 then
        dx = left and 0.1 or -0.1
        dz = 1
      else -- party.facing == 3
        dz = left and -0.1 or 0.1
        dx = 1
      end

      spl:setWorldPosition(vec(wpos[1]+dx,wpos[2]+1.35,wpos[3]+dz))
    end,
This does not include e.g. changing the object spawned depending on skill level (this is how the default projectile spells such as frostbolt work; there are 5 different frostbolt objects, one for each skill level, each one with increased freezing chance and duration). It just creates the projectile at the correct position and assigns it to the champion for experience purposes.
CainOrdamoth wrote:My next issue is probably a much simpler one. I've created a new dagger, and again it all works fine, except the gfxIndex for the power attack. I have it all set up correctly, as far as I can see. the gfxAtlas and Index for the base weapon work fine, but when I charge the power attack, the sprite uses the original Grimrock altas (in this case, the dagger morphs into a peasant's shirt when its charged up). I can't seem to get the gfxIndexPowerAttack to work off the custom atlas I made, but the regular gfxIndex is fine.
I can't reproduce this issue...are you using an old version of the game? The current version is 2.2.4.
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.
CainOrdamoth
Posts: 34
Joined: Sun Mar 08, 2015 1:45 am

Re: Please help...

Post by CainOrdamoth »

That is fantastic, thanks for that :).

For the second issue, I am running the latest version (2.2.4). I followed Skuggasveinn's video for creating new items, so I'm not sure where I went wrong.
I have another issue actually which may be related. In the editor I get the message:

warning! [string "ModSystem.lua"]:0: File not found: mod_assets/dungeon_manifest.bin

What does this mean? It hasn't caused me any issues, so I ignored it (probably a bad idea, lol).
minmay
Posts: 2790
Joined: Mon Sep 23, 2013 2:24 am

Re: Please help...

Post by minmay »

CainOrdamoth wrote:warning! [string "ModSystem.lua"]:0: File not found: mod_assets/dungeon_manifest.bin

What does this mean? It hasn't caused me any issues, so I ignored it (probably a bad idea, lol).
dungeon_manifest.bin is a file added to exported mods that stores information like the author, description, and game version. Sometimes that error message appears when the editor is launched, for reasons that are unclear to me. I'm pretty sure it's harmless.
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.
Post Reply