Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Monster Handler script request

Hello i was wondering if anyone could help me out with a script to handle roaming monsters that would attack within a certain range if they are facing the player.
Right now i have it working fairly well by making all the monsters a parallel process event with the events doing all the work. The problem is that when i get to around 4-6 monsters it runs too slow. So i was hoping that someone might could help me out with a script that would check the name of all events on the map find ones with "monster" or something in the name. Check the distance between the monster and the player and check to see if the monster is facing the player or not. At this point if it could just trigger a self-switch in the event that it is checking. I think should speed things up quite a bit. Any help would be greatly appreciated i understand programming lingo fairly well just not ruby very well so i wouldn't mind adjusting it myself. I just need something to start from and an understanding of what needs to be done.

If someone can tell me how to copy an event page and paste it in anything else ill post the monster event i am using now.

Thanks in Advance :smile:
 
Ok, here are my 2 cents.

check the game map where it updates the events, in that loop, just check for the event name, and if it is facing the player #Do whatever here.

I don't have XP/VX Installed so i can't give further explanations, hope it helps, if it doesn't I will just pop back once I get home.
 
See thats the problem i hardly know ruby.
so i don't know how to check the event name, the event x,y or for that matter the player x,y. much less i have no idea how to go about triggering a self switch in script. like i said im not to good at scripting i can just normally understand it.
(to put it another way i was pretty good with qbasic back in the day and then went on to vbasic made a few crappy games then tried C++ but never really got the hang of it and then never really did any programming for about 7 years. so i basically understand the flow and the math of ruby but i don't understand the language itself.)

I actually tried to do this once by modifying a anti-lag script that checked all the events but couldn't get it to actually do anything..... didn't crash but didn't seem to be checking anything ether so i gave up on it.
 

Atoa

Member

Search fo an strong anti-lag (For me the best one is Zeriab Anti-Lag).

With it you can limit a range of event processing (by default, only events on the screen process) so they will move to the player only if they're on screen.
 
Thanks Atoa that helped quite a bit. I had tried a couple other anti-lag scripts before but none of them seemed to work very well with parallel processes.(they where also about a 1/10 the size of Zeriab's script though) I would still love to find a way to make the monsters non-parallel processes just so i could have more on the screen at once.

Thanks

P.S
Atoa
I can't wait to get an update on enu's side view system your working on and i hope you reconsider abandoning it. I think its a great system with just a few annoying bugs.
 

Zeriab

Sponsor

What Atoa meant is that you can put the monsters on Approach (Autonomous Movement) and Event Touch as Trigger.
Then do a battle processing as the list of event commands.

The monsters will attack as they come into sight, so it won't be them only attacking when 'facing' the player. The bright side is that the approach is really fast. While I only have tried it with my own antilag I believe it's a property of most anti lags.
Try it out. I personally feel it works rather well.

*hugs*
 
Thanks Zeriab thats actually almost exactly how i had them in the beginning..... but then i wanted some intellegnce out of my monsters so i made them P.Processes so they could have normal wondering around habits(Autonomous Movement) while checking the distance and facing, then if they are within X distance and facing the player they would switch to a secound page that switches the autonomous movement to approach and this second page is still a P. Process that checks the distance so that if the player can get Y distance away the monster will give up and go back to its normal habits.
The battle processing is triggered on ether page when the distance is less than 1 (when the distance = 1 "through" gets turned on so that the distance CAN become less than 1).
Hope all that makes since...I really don't want to have to dumb down my monsters. And i was thinking that since the event processing is the same on all the monsters (except the distance they attack and the distance they give up) that it might be possible to make a simple script that could do the checks then just flip a self-switch on the event its checking.... But maybe that is more complicated than i thought.

Ether way i appreciate the help on the matter. :biggrin:
 
I'm not really sure what your trying to say there Darth J. Yes it is a event(as i stated) i don't think that a common event can check the names of other events or change their switches so i would have to have a different common event for every map. I'm trying to get help putting in script form to speed up the process. Thus allowing multiple monsters on the screen at once. WITHOUT making them mindless drones that just always run after the player.

Something like this but in Ruby instead of english the event names that are monsters would have names something like "monster 5 10" where the 5 is the distance it chases the player and the 10 is the distance it goes back to its normal habits

if the word "monster" is in the name of the event then
-distance x = players x - this events x
-if distance x > 0 then
--if event is facing right then
---face switch = true
--end if
-else
--distance x = x * -1 <----to make a negative vaule positive
--if event is facing left then
---face switch = true
--end if
-end if
-distance y = players y - this events y
-if distance y > 0 then
--if event is facing down then
---face switch = true
--end if
-else
--distance y = y * -1 <----to make a negative vaule positive
--if event is facing up then
---face switch = true
--end if
-end if
-total distance = distance x + distance y
-if total distance < (first number in event name after the word monster) and face switch = true then <------- checks to see if monster is facing player and within a certain distance.
--this events self switch a = true
-end if
-if total distance > (second number in event name) then this events self switch a = false
end if



hope that makes since... its pretty much how i have the events set up now with obvious differences......again any help is always appreciated.

------- Thanks ---------
 
Ok sorry about my unclearnes. A common event when called can alter self-switches in the event that called it as a common event can be just a block of events that would be used a lot. So there you have it a common event will do the job you want.
 
well i feel dumb i swear i had tried flipping self-switches before in a common event and it didn't work but your right i moved everything over to 2 common events added some variables and everything works fine and faster. Thanks for the heads up on that.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top