(question) creating weird weapons

Talk about creating Grimrock 1 levels and mods here. Warning: forum contains spoilers!
Post Reply
Treybor
Posts: 93
Joined: Wed Jun 06, 2012 3:13 am

(question) creating weird weapons

Post by Treybor »

Can someone point me in the direction of a LUA script format for Grimrock to create weird weapons?
I've seen some for standard weapons, but how would you go about scripting a magicall effect based on a hit?
the lightning blades and fire blades have this, but I've not seen a script for it.

I'd like to create an item that has a draining effect on monsters and temporarily boost the party.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: (question) creating weird weapons

Post by akroma222 »

Hey Treybor,

To replicate the element effects of fire/lightning blades you need to add:
SpoilerShow
damageType = "fire", --(or "lightning")
to the weapon definition in items.lua
>> as far as poison goes, I have not seen anything that can result in a monster taking constant poison damage after a hit -- I am sure it is indeed possible but I do not think simply adding damageType = poison will do this (although the attack is still of poison type for immunity purposes)
>> for cold damage, not much happens either except if the monster is killed with the attack... and then the death dust particle effect is replaced by an ice shattering effect

If you want a weapon to act as a wand (with a standard asset pack or custom spell) you can create the weapon as a wand, like this:
SpoilerShow

Code: Select all

defineObject{
	name = "arrowflash_bow",
	class = "Item",
	uiName = "Arrowflash Bow",
	model = "assets/models/items/longbow.fbx",
	gfxIndex = 165,
	skill = "missile_weapons",
	requiredLevel = 32,
	gfxIndex = 165,
	attackPower = 18,
	resistFire = 20,
	dexterity = 2,
	coolDownTime = 1.5,
	attackMethod = "castWandSpell",
	spell = "fireball_greater",
	description = "This bow has been gifted with speed and efficiency. And fire.",
	wandPower = 22,
	charges = 9,
	rangedWeapon = false,
	emptyItem = "arrowflash_bow_empty",
	weight = 1.7,
}

defineObject{
	name = "arrowflash_bow_empty",
	class = "Item",
	uiName = "Arrowflash Bow",
	model = "assets/models/items/longbow.fbx",
	gfxIndex = 165,
	description = "This bow has been gifted with unrivalled speed and efficiency.",
	gfxIndex = 165,
	skill = "missile_weapons",
	requiredLevel = 32,
	attackPower = 18,
	resistFire = 20,
	dexterity = 2,
	coolDownTime = 1.5,
	attackMethod = "rangedAttack",
	attackSound = "swipe_bow",
	impactSound = "impact_blunt",
	rangedWeapon = true,
	ammo = "arrow",
	weight = 1.7,	
}
You can something similar for other items too... like put the custom "healing" spell on an amulet, like this:
SpoilerShow

Code: Select all

cloneObject{
	name = "amulet_life",
	baseObject = "spirit_mirror_pendant",
	uiName = "Amulet of Life",
	attackMethod = "castWandSpell",
	spell = "healing",
	gfxIndex = 74,
	vitality = 1,
	willpower = 1,
	charges = 9,
	wandPower = 40,
	emptyItem = "amulet_life_empty",
	description = "The jewel embedded within this amulet makes you feel an unfamiliar kind of relaxation.",
	gameEffect = "",
}

cloneObject{
	name = "amulet_life_empty",
	baseObject = "spirit_mirror_pendant",
	uiName = "Amulet of Life",
	gfxIndex = 74,
	vitality = 1,
	strength = 1,
	description = "The jewel embedded within this amulet makes you feel an unfamiliar kind of relaxation.",
	gameEffect = "",
}
As for weapons that produce spell and draining effects - I would direct you to a thread I have posted that covers both of these things

As for constant magical effects created by weapons, I have used a script that LordGarth posted a while ago (and which is now included in a thread about weapon scripts I posted recently - viewtopic.php?f=14&t=4088)... Basically you need to place a script in init.lua (this method uses the onAttack party hook), calling a function from a script entity in your dungeon. The set up I have posted in the thread my seem a little complicated as I am trying to handle multiple kinds of weird weapons, but essentially you can just add this to init.lua:
SpoilerShow

Code: Select all

cloneObject{
	name = "party",
	baseObject = "party",
	onAttack = function(champion, weapon, skill)
		if (weapon ~= nil) and (weapon.name == "ice_sabre") then   --(replace ice sabre with your weird weapon)
		if party.facing == 0 then
			spawn("frostburst", party.level, party.x, party.y-1, party.facing)
		end
		if party.facing == 1 then
			spawn("frostburst", party.level, party.x+1, party.y, party.facing)
		end
		if party.facing == 2 then
			spawn("frostburst", party.level, party.x, party.y+1, party.facing)
		end
		if party.facing == 3 then
			spawn("frostburst", party.level, party.x-1, party.y, party.facing)
		end
	end
end
}
Now, for draining weapons (also included in the weapon script thread) I have used some code Grimwold created for a spell to replicate the lifeleech gameEffect (you can also restore energy or your food counter if you want). For this, I also use the onAttack hook > call a function from a script entity in the dungeon which checks for the weapon's name, makes sure the monster in front of the party is included in a table and then carries out the desired effect - drain health/energy... this is the code:

onAttack hook for init.lua:
SpoilerShow

Code: Select all

cloneObject{
	name = "party",
	baseObject = "party",
	onAttack = function(champion, weapon, skill)
		return attackingWeaponScripts.specialWeaponAttacks(champion, weapon, skill)
	end
}
For script entity named "attackingWeaponScripts" in your dungeon
SpoilerShow

Code: Select all


function specialWeaponAttacks(champion, weapon, skill)
       if (weapon ~= nil) and (weapon.name == "psionic_blade") then
		return attackingWeaponScripts.psionicBlade(champion, weapon, skill)
	end
	if (weapon ~= nil) and (weapon.name == "reaper_axe_empty") then
		return attackingWeaponScripts.reaperAxe(champion,weapon,skill)
	end
end

monstersList = {"amber_slime","ancient_horde","ancient_warrior","bone_slime","crab","crowern","cube","dark_elf_temple_skeleton_archer","dark_elf_temple_skeleton_archer_patrol", "exotic_crab_purple", "dark_elf_temple_skeleton_warrior","dark_elf_temple_skeleton_patrol","goromorg","green_lizard","green_slime","herder","herder_big","herder_small","herder_swarm","high_elf_temple_skeleton_archer","high_elf_temple_skeleton_archer_patrol","high_elf_temple_skeleton_warrior","high_elf_temple_skeleton_patrol","ice_slime","isgardian","laguardian","liche","maggot_slime","ogre","red_slime","scavenger","scavenger_swarm","shrakk_torr","skeleton_archer","skeleton_archer_patrol","skeleton_patrol","skeleton_warrior","slug","snail","spider","spider_dark_orange","spider_red","stone_slime05","stone_slime06","stone_slime10","stone_slime11","tentacles","trash_slime","uggardian","urgardian","venom_wyvern","warden","warden_exploding","water_slime","wyvern"}

--(change to include the monsters in your mod)			

vamp_monster = ""

function isInMonsterTable(table, element)
  for _,value in pairs(table) do
    if value == element then
      return true
    end
  end
  return false
end


function whichMonster(level,eggs,why)
  for i in entitiesAt(level,eggs,why) do
    if isInMonsterTable(monstersList,i.name) then
      return i.id
    end
  end
  return ""
end


----------------------Vampric weapons------------------------------------------------
function reaperAxe(champion,weapon,skill)
  local dx,dy = getForward(party.facing)
  vamp_champ = champion
  vamp_monster = whichMonster(party.level,party.x+dx,party.y+dy)
  if vamp_monster == "" then
    return true
  end
  local skill = champion:getSkillLevel("axes")
  party:playScreenEffect("damage_screen")
  vamp_champ:modifyStat("health", (skill/3))
  return true
end

--------------------Syphon weapons---------------------------
function psionicBlade(champion,weapon,skill)
  local dx,dy = getForward(party.facing)
  syph_champ = champion
  vamp_monster = whichMonster(party.level,party.x+dx,party.y+dy)
  if vamp_monster == "" then
    return true
  end
  local skill = champion:getSkillLevel("swords")
  party:playScreenEffect("damage_screen_blue")
  syph_champ:modifyStat("energy", (skill/2))
  return true
end
**I have used a particle effect 'damage screen blue' for draining energy - can be found in the thread

Hopefully this helps you on your way!
Also in the thread is a script that Marble Mouth very kindly wrote for weapons that can only be equipped by certain races/classes (and when they have the required skill level)- and will boost stats and or add certain traits while equipped in hand.

Currently, I am trying to get something similar working for unarmed_combat "gauntlet" type weapons... will hopefully be adding a script for that soon :D

EDIT - having said all that, these methods do not utilise Jkos' Framework hooks... nor Diarmuid's EXSP spell system. I am sure they could both run rings around the code I have posted here. Their systems make a lot of new things possible, I have just not converted my items or spells over completely yet ;)
Treybor
Posts: 93
Joined: Wed Jun 06, 2012 3:13 am

Re: (question) creating weird weapons

Post by Treybor »

@akroma : This was immensly helpful! Thank you so much!
I'll let you know what I figure out.
User avatar
akroma222
Posts: 1029
Joined: Thu Oct 04, 2012 10:08 am

Re: (question) creating weird weapons

Post by akroma222 »

No probs!
If you have any more questions or ideas for weird weapons let me know ;)
Post Reply