Scripting Item So Monsters Ignore Party
Scripting Item So Monsters Ignore Party
Hi folks. Sorry if this is obvious or has been asked before (or even if there's already something in the game that does this), but I would like some help with scripting (which I have little experience with, as you'll be able to tell). I want to write a script so that when the party has a specific item the forest ogres on that floor will ignore them, but I'm not sure exactly what the best way to go about doing that would be. Thanks.
edit: This is in Grimrock 2, btw.
edit 2: Words, what are those?
edit: This is in Grimrock 2, btw.
edit 2: Words, what are those?
Last edited by Hitrison on Tue Jan 17, 2017 11:08 pm, edited 1 time in total.
Re: Scripting Item So Monsters Ignore Party
Your text seems to be missing
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Scripting Item So Monsters Ignore Party
You add an onThink function to the ogres brain (you have to define a new monster for this), check if the party is carrying the item (party.party:isCarrying(string)), and set the sight radius to 0.
The monster might still react to the party if they stand too close, but that can be easily fixed with disabling the attack components.
Here is a very useful thread for monster brains: viewtopic.php?f=22&t=9720
The monster might still react to the party if they stand too close, but that can be easily fixed with disabling the attack components.
Here is a very useful thread for monster brains: viewtopic.php?f=22&t=9720
Re: Scripting Item So Monsters Ignore Party
Cool, thanks!
Re: Scripting Item So Monsters Ignore Party
Setting sight radius is a bad hack that is unlikely to do what you want (consider what happens when the monster gets attacked for example). It's more likely that you want this:zimberzimber wrote:You add an onThink function to the ogres brain (you have to define a new monster for this), check if the party is carrying the item (party.party:isCarrying(string)), and set the sight radius to 0.
The monster might still react to the party if they stand too close, but that can be easily fixed with disabling the attack components.
Here is a very useful thread for monster brains: viewtopic.php?f=22&t=9720
Code: Select all
onThink = function(self)
if party.party:isCarrying("stone_of_ogre_ignorance") then
return self:wander()
else
return false -- use original brain behaviour
end
endIf you additionally want the ogre to NEVER attack change it to this:
Code: Select all
onThink = function(self)
if party.party:isCarrying("stone_of_ogre_ignorance") then
return self:wander() or self:wait()
else
return false -- use original brain behaviour
end
endedit: also, read the linked thread at your own risk because most of the posts in there are completely wrong
Last edited by minmay on Wed Jan 18, 2017 4:05 am, edited 4 times in total.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Scripting Item So Monsters Ignore Party
I did self:wander, and the monster just ignored that command.
About the linked thread, I don't know whats in the comments, but the main post covers whats needed.
EDIT: Missed the return part, but the monster will still occasionally use attacks. Looks the same as setting sight radius to 0 in terms of monster behavior, so you still have to disable melee attacks and such.
About the linked thread, I don't know whats in the comments, but the main post covers whats needed.
EDIT: Missed the return part, but the monster will still occasionally use attacks. Looks the same as setting sight radius to 0 in terms of monster behavior, so you still have to disable melee attacks and such.
Re: Scripting Item So Monsters Ignore Party
It's not the same as setting sight radius to 0. The code I posted makes it just like the ogre is unaware of the party, what you're noticing is that being unaware doesn't prevent monsters from attacking. (I can write a full explanation of BrainComponent:wander() and OgreBrain if you're really interested.) I amended the post with a version that will never attack or charge.
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.
Grimrock 2 resources
I no longer answer scripting questions in private messages. Please ask in a forum topic or this Discord server.
Re: Scripting Item So Monsters Ignore Party
The "self:wander() or self:wait()" code seems to be working well. And yes, if the party has the item (in my mod, called a hall pass) I don't want the ogres to attack at all.
Re: Scripting Item So Monsters Ignore Party
Hey All,
seems like the right thread for it - has anyone tried / succeeded in recreating the Invisibility condition??
Im going to be making a custom condition (Stealth) similar to Invisibility and was wondering how the nuts and bolts of it works...
Akroma
seems like the right thread for it - has anyone tried / succeeded in recreating the Invisibility condition??
Im going to be making a custom condition (Stealth) similar to Invisibility and was wondering how the nuts and bolts of it works...
Akroma
Labyrinth of Lies (viewtopic.php?f=14&t=4400)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
Legacy of Lies (viewtopic.php?f=22&t=12983&hilit=+legacy)
- zimberzimber
- Posts: 432
- Joined: Fri Feb 08, 2013 8:06 pm
Re: Scripting Item So Monsters Ignore Party
Same code minmay posted, but check for a condition and other things (like party distance) instead.akroma222 wrote:Hey All,
seems like the right thread for it - has anyone tried / succeeded in recreating the Invisibility condition??
Im going to be making a custom condition (Stealth) similar to Invisibility and was wondering how the nuts and bolts of it works...
Akroma
I think it will still put the monster out of a guarding position, but I think you can fix this by checking if it was guarding, and tell it to guard again.