Custom textures for items/props

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Batty
Posts: 509
Joined: Sun Apr 15, 2012 7:04 pm

Re: Custom textures for items/props

Post by Batty »

Thanks for the hammer, looks great & fits right in. We need more higher level weapons. I remember playing that arcade game too!

edit: it looks awesome when you throw it, speed is right too.
Szragodesca
Posts: 59
Joined: Sun Oct 14, 2012 7:13 am

Re: Custom textures for items/props

Post by Szragodesca »

Batty wrote:Thanks for the hammer, looks great & fits right in. We need more higher level weapons. I remember playing that arcade game too!

edit: it looks awesome when you throw it, speed is right too.
Now someone just needs to figure out how to get the thrown hammer back in the player's hand when it stops moving (hit or miss) so they can make weapons that return. Make a thrower that much more useful without weighing them down with a ton of hammers, lol. (and it lets you make your Wulfgar clones and whatnot)
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Custom textures for items/props

Post by Grimwold »

Batty wrote:Thanks for the hammer, looks great & fits right in. We need more higher level weapons. I remember playing that arcade game too!

edit: it looks awesome when you throw it, speed is right too.
I agree the hammer looks very cool.

Szragodesca wrote: Now someone just needs to figure out how to get the thrown hammer back in the player's hand when it stops moving (hit or miss) so they can make weapons that return. Make a thrower that much more useful without weighing them down with a ton of hammers, lol. (and it lets you make your Wulfgar clones and whatnot)
Might be possible by checking the party onAttack hook... e.g. if weapon.name = "throwing_hammer"... spawn a timer to add a slight delay (could even adjust delay for distance between party and monster) then destroy the original hammer and spawn a new one that flies back at the party... finally destroy the returning hammer and spawn one in the characters hand and destroy the timer.

There's potential for a spell here too... "enchant throwing weapon".. that converts a weapon in hand to a returning version of same.

EDIT - now I'm thinking the monster hook onProjectileHit() might be a better bet for triggering the projectile return... hammer would only return if it hit a monster.

Would require you to add the hook to every monster (or every monster from which the hammer could return).
Last edited by Grimwold on Mon Oct 15, 2012 4:42 pm, edited 1 time in total.
Belblindd
Posts: 27
Joined: Tue Oct 09, 2012 4:13 pm

Re: Custom textures for items/props

Post by Belblindd »

I think the idea of a returning hammer is cool, but for a magical hammer (Thor's *cough, cough*).
I mean I don't really know about throwing weapons but I guess it would be impossible to throw one as heavy as that to return to the thrower.
Wouldn't it be better to let it be a heavy, fight-initiating throwing hammer, so heavy, you might just carry a maximum of 2...?
Yes, Grimrock doesn't intend to be realistic and it's a fantasy game... but I don't know, non-magical, returning throwing hammers?!
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Custom textures for items/props

Post by Grimwold »

I have scripted a very rudimentary returning axe (should be easy to modify to a hammer). By rudimentary I mean it currently teleports back into the thrower's hand... With a bit more work I'm sure I can add a projectile of the axe flying back etc.

It makes use of the party hook - onAttack to determine the thrower of the weapon and a monster hook - onProjectileHit to determine what the projectile was, and when to return it.

add this hook to a clone of the party... probably in init.lua

Code: Select all

cloneObject{
   name = "party",
   baseObject = "party",

   onAttack = function(champion,weapon)
      return party_script.weaponCheck(champion,weapon)
   end,

}
add this script to your monsters.lua file to clone every monster listed and add the onProjectileHit hook

Code: Select all

local monstersList = {
"crab","crowern","cube","goromorg","green_slime","herder","herder_big","herder_small","herder_swarm","ice_lizard","ogre","scavenger","scavenger_swarm","shrakk_torr","skeleton_archer","skeleton_archer_patrol","skeleton_patrol","skeleton_warrior","snail","spider","tentacles","uggardian","warden","wyvern"
}

for i=1,# monstersList do 
  cloneObject{
  name = monstersList[i],
  baseObject = monstersList[i],
  onProjectileHit = function(monster, weapon)
    return party_script.projectileCheck(monster,weapon)
  end,
}
end
note party_script refers to a script entity in your dungeon.. i tend to use this entity for any party related hooks (and because I am storing a value in a variable I needed to use this for the monster hook too!)

create this object in items.lua

Code: Select all

cloneObject{
  name ="returning_throwing_axe",
  baseObject="throwing_axe",
  uiName = "Throwing Axe of Returning",
  sharpProjectile = false,
  stackable = false,
}
I made it non-stackable so that the champion would have an empty hand once he'd thrown it... I also made it non-sharp so that it doesn't get 'carried' by the monster.. otherwise the call to destroy() the item will crash the game.

finally add these scripts to a party_script entity in your dungeon

Code: Select all

function weaponCheck(champion,weapon)
  if weapon ~= nil 
  then
    if weapon.name == "returning_throwing_axe" then
      thrower = champion
      -- hudPrint(thrower:getName())    
    end
  end  
end

function projectileCheck(monster,weapon)
  if weapon.name == "returning_throwing_axe" then
    -- hudPrint("Returning Throwing Axe with ID " .. weapon.id)
    if findEntity(weapon.id) ~= nil then
      -- hudPrint(thrower:getName())
      weapon:destroy()
      if thrower:getItem(7) == nil then
        thrower:insertItem(7,spawn("returning_throwing_axe"))
      elseif thrower:getItem(8) == nil then
        thrower:insertItem(8,spawn("returning_throwing_axe"))
      end
    end
  end
end
When I have more time I'll work on having the axe look like it's fly back from the monster.
Last edited by Grimwold on Tue Oct 16, 2012 1:55 am, edited 1 time in total.
User avatar
Merethif
Posts: 274
Joined: Tue Apr 24, 2012 1:58 pm
Location: Poland

Re: Custom textures for items/props

Post by Merethif »

I'm glad you're liking throwing hammer. A returning throwing hammer is great idea. I don't even mind it magically teleports back to the player hands. After all it's magical hammer so it can do such tricks.

I don't see a problem with having both weapons at the same time: regular, stackable, non-magical and not-returning hammers and magical Hammer of Storms that inflict lightning damage, is not stackable and returns back to the player.

I'll try to retexture such magical throwing hammer from Ogre Hammer so polish your script Grimwold ;-)
User avatar
HaunterV
Posts: 676
Joined: Mon Apr 16, 2012 9:54 pm
Location: Barrie, Ontario, Canada

Re: Custom textures for items/props

Post by HaunterV »

Friggn awesome. Everyone that's played my dungeon, knows I love me some gobelins.
Grimrock Community 'FrankenDungeon 2012. Submit your entry now!: http://tinyurl.com/cnupr7h
SUBMIT YOUR ASSETS! Community Asset Pack (C.A.P.): http://tinyurl.com/bqvykrp
Behold! The HeroQuest Revival!: http://tinyurl.com/cu52ksc
User avatar
JohnWordsworth
Posts: 1397
Joined: Fri Sep 14, 2012 4:19 pm
Location: Devon, United Kingdom
Contact:

Re: Custom textures for items/props

Post by JohnWordsworth »

If only we had the power to add enemy AI, I could picture a spiritual hammer spell, which would essentially summon a monster on your side that would just be a glowing, floating, attacking hammer. I guess the bad guys could still have it. Ahhh, D&D. :)
My Grimrock Projects Page with links to the Grimrock Model Toolkit, GrimFBX, Atlas Toolkit, QuickBar, NoteBook and the Oriental Weapons Pack.
User avatar
Grimwold
Posts: 511
Joined: Thu Sep 13, 2012 11:45 pm
Location: A Dungeon somewhere in the UK

Re: Custom textures for items/props

Post by Grimwold »

I've had a play with getting the axe to appear as if it's returning, and I'm honestly not sure... here's the script (this replaces everything in the party_script entity (relating to this feature)

Code: Select all

-- get distance between party and monster
function getDistance(obj1,obj2)
  local distance = 0
  local XNumber = math.max(obj1.x,obj2.x) - math.min(obj1.x,obj2.x)
  local YNumber = math.max(obj1.y,obj2.y) - math.min(obj1.y,obj2.y)
  distance = XNumber + YNumber
  return distance
end


-- party onAttack

thrower = party:getChampion(1) -- this sets champion 1 as the initial thrower.. purely for the case that you first throw the axe from the mousepointer!

function weaponCheck(champion,weapon)
  if weapon ~= nil 
  then
    if weapon.name == "returning_throwing_axe" then
      thrower = champion
      -- hudPrint(thrower:getName())    
    else
    --  hudPrint("Other Weapon")
    end
  else
   -- hudPrint("Unarmed")
  end
end


-- Monster onProjectile Hit

function projectileCheck(monster,weapon)
    if weapon.name == "returning_throwing_axe" then
      -- hudPrint("Returning Throwing Axe with ID " .. weapon.id)
      if findEntity(weapon.id) ~= nil then
        -- hudPrint(thrower:getName())
        weapon:destroy()
        local distance = getDistance(party,monster)
        local facing = (party.facing + 2)%4
        local dx,dy = getForward(facing)
        shootProjectile("returning_throwing_axe", party.level, monster.x+dx, monster.y+dy, facing, 2*distance, 1, 1, 0, 0, 0, 0, false, true)
        if thrower:getItem(7) == nil then
          thrower:insertItem(7,spawn("returning_throwing_axe"))
        elseif thrower:getItem(8) == nil then
          thrower:insertItem(8,spawn("returning_throwing_axe"))
        else
          spawn("returning_throwing_axe",party.level,party.x,party.y,party.facing)
        end
      end
    end
end
If I went this route, this wouldn't be the finished version because there's no delay in materialising the axe.. so it appears in the champion's hand before it has flown back... however there are some odd things that happen..
1) if I throw it and then sidestep, the axe continues to fly past (you can turn sideways and watch it) and yet still appears in the champion's hand
2) some monsters move so quickly that they get hit twice with the axe, leading to a second axe being spawned if the champion has 2 free hands.
3) despite a damage rating of 0 for the returning axe projectile, a champion in the front of the party still sometimes takes 1 damage.

Have a look and see what you think... but personally I might be tempted to stick with the weapon magically returning to the champion.


(note I have changed the monsters.lua script above so that it now cycles through all monsters and adds my onProjectileHit hook)
Last edited by Grimwold on Wed Oct 17, 2012 1:35 pm, edited 1 time in total.
Szragodesca
Posts: 59
Joined: Sun Oct 14, 2012 7:13 am

Re: Custom textures for items/props

Post by Szragodesca »

JohnWordsworth wrote:If only we had the power to add enemy AI, I could picture a spiritual hammer spell, which would essentially summon a monster on your side that would just be a glowing, floating, attacking hammer. I guess the bad guys could still have it. Ahhh, D&D. :)
I don't recall which game it was, but there was a Dungeon Master-ish D&D game where you could cast Spiritual Hammer and either attack with it in melee, or right-click it and have it thrown. Maybe Dungeon Hack. . . I played that one a lot back in the day. Would be a good way to utilize the Spiritual Hammer idea, no? Attack with left click, throw with right click? :)

Looks like Grimwold is well on the path to having the throwing bit down.
Post Reply