Page 1 of 1
Scripting Item So Monsters Ignore Party
Posted: Tue Jan 17, 2017 10:02 pm
by Hitrison
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?
Re: Scripting Item So Monsters Ignore Party
Posted: Tue Jan 17, 2017 10:30 pm
by kelly1111
Your text seems to be missing
Re: Scripting Item So Monsters Ignore Party
Posted: Tue Jan 17, 2017 11:55 pm
by zimberzimber
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
Re: Scripting Item So Monsters Ignore Party
Posted: Wed Jan 18, 2017 12:16 am
by Hitrison
Cool, thanks!
Re: Scripting Item So Monsters Ignore Party
Posted: Wed Jan 18, 2017 12:47 am
by minmay
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
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:
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
end
This way it will behave just like an ogre that is unaware of the party while the stone is carried.
If 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
end
(BrainComponent:wander() can still fall through; self:wait(), however, will never fall through so the monster will never do anything other than move and wait)
edit: also, read the linked thread at your own risk because most of the posts in there are
completely wrong
Re: Scripting Item So Monsters Ignore Party
Posted: Wed Jan 18, 2017 12:58 am
by zimberzimber
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.
Re: Scripting Item So Monsters Ignore Party
Posted: Wed Jan 18, 2017 4:08 am
by minmay
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.
Re: Scripting Item So Monsters Ignore Party
Posted: Wed Jan 18, 2017 7:36 am
by Hitrison
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
Posted: Sun Jan 29, 2017 3:11 pm
by akroma222
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

Re: Scripting Item So Monsters Ignore Party
Posted: Sun Jan 29, 2017 3:37 pm
by zimberzimber
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

Same code minmay posted, but check for a condition and other things (like party distance) instead.
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.