Please, help with scripting new traits

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

Re: Please, help with scripting new traits

Post by CainOrdamoth »

For the shields, I actually have 2 types of shields, light shields and heavy shields. These are not defined as different objects, they all just function the same but in general light shields (like bucklers and small kite shields) give evasion as well as a small amount of protection, but the heavy shields (great shields or tower shields etc.) give higher protection but no evasion. In that way, its a bit more old-school in that shields reduce damage taken instead of avoiding it completely (like you'd expect a shield to do), but I always imagined a heavy class wielding a huge shield, and a heavy class would have very little evasion (probably 0 or negative evasion) so evasion on a huge shield wouldn't be much use anyway. I had a run through my dungeon, and even with the lowest tier of heavy armour in the dungeon my 'tank' character was pretty tanky, and my evasive character seemed pretty evasive, but its worth noting that I've included other means to mitigate damage. I'll see how things go in the late game (when I get to it) when the enemies get really nasty and tweak things as I go, but so far it seems ok.

Most of the racial traits comes as either defaults for certain races, or can be chosen by all champions regardless of race. Most of the differences between races comes from their stats, but some of their traits also change things. For example, lizardmen start with 5 or 10 protection (haven't decided yet, might go with 7, lol) to represent their hard scales. They are also less likely to suffer injuries because of it. I'm still very much working on traits right now, because of the changes I've made there are only 16 chosen traits right now (that is until I add back in the Gift traits). Others I added to races or classes by default. All this is still open to change. If I (or any testers) feel like character creation is too limiting I will change things around.

I'm glad I'm not the only one who works on different things all the time. It makes me feel really inefficient, lol. But when things come together and you realize that you actually made a lot of progress by doing it, it all feels quite good in the end. Speaking about breaking things, I made a mage weapon early on that uses a certain spell for its special attack. Safe to say when I messed around with spells shortly after the staff broke, and for a moment I didn't know why, but then I realized. It was a very simple thing to fix, but its easy to see how bigger changes could break and ruin things. Honestly, if I was more knowledgeable about how to script things I'd probably try some much more outlandish stuff. But as I only really know the basics I can only really take the existing scripts and change them a little. It can be challenging for me to realize the logic behind how scripts are structured. Like the spell script minmay gave me a while back.
SpoilerShow

Code: Select all

	onCast = function(champion, x, y, direction, elevation, skillLevel)
     		local spl = spawn("meteor",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                                                                     -- No idea what this all means for example. Well, I know what it does, but
      		for i = 1,4 do                                                                       -- I don't know how it works or why it works, or what script instances it
       			if party.party:getChampion(i):getOrdinal() == ord then                           -- is used for, etc.
          		left = i == 1 or i == 3                                                   
          		break                                                                                                      
        		end                                                                            
      		end
      			local wpos = party:getWorldPosition()                             -- I figured out all this stuff by adjusting the values and seeing what 
      			local dx = nil                                                                 -- happens, lol.
      			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,
So yeah, minmay has been a Godsend, lol. A lot of people have, you, Zimber. Can I ask where you learned all this stuff, and how you got so good at it?
I'll put working on the dungeon itself on hold for now and try to get everything else into a fully working state so I can see about putting out a version for people to test it.
Cheers guys :)
User avatar
zimberzimber
Posts: 432
Joined: Fri Feb 08, 2013 8:06 pm

Re: Please, help with scripting new traits

Post by zimberzimber »

I mostly learned myself with some help from the community where I felt totally lost.
Read how 'x' works, copy-paste it, re-purpose it into 'y', and so on and so forth.
Seeing going through other peoples mod sources and custom assets helps a lot as well.
For example, in my pack I have two objects that generate other objects that are usually tedious to place by hand.
For when you have a high cliff and you have to add 5 forest_wall_edges. So I made one objects that generates them. The mechanic behind this was inspired by AndakRainors lava object that spawns an underlava object, which keeps spawning underlava object every elevation down until it reaches the bottom floor.
My asset pack [v1.10]
Features a bit of everything! :D
Post Reply