Jump to content

Codeing help?


Whix

Recommended Posts

Hey guys, trying to make a character mod and i was wondering how i would go about making it so that monsters/creatures in the game do not attack unless provoked while it's raining only. Not sure if there's a way but if there is could anyone lend me a hand?

Thanks for reading.

Link to comment
Share on other sites

Alright been looking through the already existing code, figuring out event handlers and all that and i think that affecting the stategraphs is probably the best way of at least making it so creatures will not be hostile towards my character but the issue i am having now is trying to figure out how to change the state of say the spider from investigate to something that isn't investigate.

(i could be completely wrong about how i am going about it but this is just what i have seen so far from looking through a couple other forums on here and what the scripts look like)

Link to comment
Share on other sites

triggercreep = false on if something. using the event handler on that would work i think. and also you could use it to apply certain tags such as spiderwhisperer (pigs attack) or giving the effect of spiderhat at a certain level of wetness. i am unfamiliar on how to code events and stategraphs, but i assume this is useful info.

Link to comment
Share on other sites

An idea just hit me while trying to figure this problem out. I noticed the tags that were used in the scripts and thought couldn't i add those tags to my character so the hostile mobs see me as one of them and don't attack but on attack the tag changes to the default character tag i guess?


An idea just hit me while trying to figure this problem out. I noticed the tags that were used in the scripts and thought couldn't i add those tags to my character so the hostile mobs see me as one of them and don't attack but on attack the tag changes to the default character tag i guess?

Link to comment
Share on other sites

I think i have discovered how to do this, it is a million times more simple than what i was thinking, simply by looking through the creatures files and looking at what tags they have, taking those tags and adding it to my character makes him "invisible" to the monsters constantly. The next challenge making this only happen when it's NOT raining.

Link to comment
Share on other sites

all the tags:

inst:AddTag("ghost")
inst:AddTag("monster")
 
inst:AddTag("spider")
 
inst:AddTag("insect")
    inst:AddTag("smallcreature")
 
inst:AddTag("hound")
 
inst:AddTag("knight")
inst:AddTag("chess")
 
inst:AddTag("tallbird")
 
     inst:AddTag("animal")
inst:AddTag("largecreature")
     inst:AddTag("spiderqueen")
 
inst:AddTag("WORM_DANGER")
 
inst:AddTag("epic")
     inst:AddTag("hostile")
     inst:AddTag("bearger")
     inst:AddTag("largecreature")
 
inst:AddTag("beefalo")
 
inst:AddTag("deerclops")
 
inst:AddTag("dragonfly")
 
inst:AddTag("frog")
 
inst:AddTag("Goose")
 
inst:AddTag("mosquito")
 
inst:AddTag("guard")
inst:AddTag("werepig")
 
inst:AddTag("bee")

Well that's most of them, i'm sure i am missing many.
 
Also i need to find a way to stop my character from running at anything (and fix conflicts) if seems like certain monsters like to automatically attack others 
Link to comment
Share on other sites

Alright now that i got that part sorted out now i am trying to remove those tags when it rains and i know the way i have done it is completely wrong. Basically what i have done is i found frograin and the line "inst:ListenForEvent "rainstart", function() and i have that but no idea where i should put it to make it work on my character script and how to adapt it so that it works for the tags i have added. Any tips on where i should be looking to put it?

Link to comment
Share on other sites

Are pigmen really neutral that way?!

 

Also epic tag may screw up your fight music.

 

EDIT: from combat.lua, may be interesting alternatives  (less mad-hack :razz:):

 

in retargetfn:

116- newtarget:HasTag("notarget")

 

in validtarget:

229- or (target:HasTag("shadow") and not self.inst.components.sanity)

 

in canbeattacked:

749- if self.canbeattackedfn then
750-    can_be_attacked = self.canbeattackedfn(self.inst, attacker)
751-end

(my personal recommendation, as you could implement the rain factor at the same time)

Link to comment
Share on other sites

Yea the normal pigmen are neutral until provoked, even to each other they can fight. I had a look in there and that looks like it could be another way of doing it, but for me i simply gave my character certain tags that allows him to be "invisible" to the other creatures and then at certain times (when raining) simply take away those tags.

 

Edit: actually i tried the ("notarget") tag and that is actually way better than what i was doing haha, i had them all written out but that actually is all of them into one and fixed the bug of my character randomly running up to another creature saying "go for the eyes" so thank you for finding that.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

×
  • Create New...