Boss fight 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!
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Boss fight help

Post by WaspUK1966 »

I've followed the online video tutorial to set up and code boss fights (really helpful!). But that code uses a monster that is already placed on the map and is visible to the player once they enter the area. Is it possible to spawn a monster instead, then code it for a boss fight? That way, the player doesn't know what's coming? Or would that be too complex? (getting the spawned monster's ID etc). Any ideas?

George
User avatar
THOM
Posts: 1280
Joined: Wed Nov 20, 2013 11:35 pm
Location: Germany - Cologne
Contact:

Re: Boss fight help

Post by THOM »

I don't know, if it's possible to register a spawned monster for a bossfight. maybe by using advanced scripting skills.

But when I came to the same problem in my mod I solved it that way that I placed my monster at an unaccessable place on the map and teleported it for the bossfight near to the party...
THOM formaly known as tschrage
_______________________________________________
My MOD (LoG1): Castle Ringfort Thread
My MOD (LoG2): Journey To Justice Thread | Download
minmay
Posts: 2789
Joined: Mon Sep 23, 2013 2:24 am

Re: Boss fight help

Post by minmay »

"advanced scripting skills"
it's one line

Code: Select all

bossFightObject.bossfight:addMonster(monsterObject.monster)
or if you add it in the middle of the boss fight, two lines

Code: Select all

bossFightObject.bossfight:addMonster(monsterObject.monster)
bossFightObject.bossfight:recomputeTotal()
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.
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Boss fight help

Post by Azel »

A snippet from the script I use to auto-spawn a Uggardian:

Code: Select all

function NewFireBoss()
	local fireBoss;
	do fireBoss = spawn("uggardian", party.level, 11, 15, 1, 0);
		fireBoss.monster:setLevel(3);
		fireBoss.monster:setMaxHealth(600);
		
		boss_fight_1.bossfight:addMonster(fireBoss.monster);
	end
end
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Boss fight help

Post by Isaac »

The question seems answered already; but here is an example of a spawned boss fight that I built a few months ago.
https://www.dropbox.com/s/w2jgjrzh3y6jo ... l.zip?dl=0

It's more than a few lines. It adds six existing monsters into the Boss fight, along side of the Boss that gets spawned into the dungeon when the party steps on a trigger. This one counts down the enemies as you eliminate them, and notices the main boss by name when killed.
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Re: Boss fight help

Post by WaspUK1966 »

Thanks for that! Now I can spawn the monster as intended :

Code: Select all

function startviperBossFight()

 local viperBoss = spawn("viper_root", party.level, 17, 4, 3, 0)
boss_fight_viper.bossfight:addMonster(viperBoss.monster)
boss_fight_viper.bossfight:activate()
end

What I'm trying to do is open a gate once it dies. How do I do that? I've tried using OnDie function, or setAchievement() but can't get them to work..

George
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Boss fight help

Post by Azel »

Something like this should do it:

Code: Select all

function BossDeath

	-- end the boss fight
	boss_fight_viper.bossfight:deactivate();
	
	
	my_boss_door.door:open(); -- let the party leave

end

function startviperBossFight()
	local viperBoss;
	
	do viperBoss = spawn("viper_root", party.level, 17, 4, 3, 0);
		viperBoss.monster:addConnector("onDie", self.go.id, "BossDeath")
		
		boss_fight_viper.bossfight:addMonster(viperBoss.monster);
		boss_fight_viper.bossfight:activate();
	end	
end
User avatar
WaspUK1966
Posts: 135
Joined: Sat Aug 09, 2014 9:17 am

Re: Boss fight help

Post by WaspUK1966 »

Thanks for that, Azel. Works as intended now. Still on a learning curve as far as LOG2 coding goes. Slightly different from LOG1. Keep using old code by mistake! But I'll get there eventually. Help much appreciated as always.

George
Azel
Posts: 808
Joined: Thu Nov 06, 2014 10:40 pm

Re: Boss fight help

Post by Azel »

No problem. I too am only now pushing a bit harder to apply my programming skills more properly under the Grimrock framework. Things don't always play nice with my .Net developer experience lol.

Personally, I'm not a fan of LUA at all. It reminds me of Jquery/Ajax, and how these scripting languages "enable" the abuse that web developers put on the presentation layer of software development. I find a lot of contradictions in how LUA functions, and even in how it is explained.

Example: http://www.lua.org/pil/p1.html

The beginning of the LUA Preface:
Currently, many programming languages are concerned with how to help you write programs with hundreds of thousands of lines. For that, they offer you packages, namespaces, complex type systems, a myriad of constructions, and thousands of documentation pages to be studied.
... and then at the end of the Preface:
A great part of the power of Lua comes from its libraries. This is not by chance. One of the main strengths of Lua is its extensibility through new types and functions.
They start by chastising other programming languages for hiding large amounts of code behind libraries and type systems... and then follows up by bragging about how LUA uses libraries and type systems, which hide large amounts of code :shock:

Even the Grimrock scripting reference has contradictions that only diminish after "reading between the lines" (eg, "CrystalComponent:setCooldown(number) leads us to a successful, my_crystal.crystal:setCooldown(60)" ... whereas "MonsterAttackComponent:getAttackPower() leads to a failure if you try, my_monster.monsterattack:getAttackPower()"). Granted, once you find out what went wrong you realize it was your fault for not understanding the Scripting Reference better, but at the end of the day it still feels quite sloppy, imo.

But I digress... :P

In the Spawn code I wrote in this thread, it does hardcode X, Y, Elevation, and Facing numbers. I believe the best practice is to instead put a "dummy object" in the location that you want to spawn the monster at, and reference its coordinates instead. But I'm too lazy to do that lol

Oh and no offense to anyone who loves LUA. This is just my personal take as a non-scripter. I recognize the talent of plenty of talented LUA dev's in this community :mrgreen:
User avatar
Isaac
Posts: 3188
Joined: Fri Mar 02, 2012 10:02 pm

Re: Boss fight help

Post by Isaac »

The script_entity itself is the perfect source of coordinates.
Post Reply