Timeline for How to do monster AI movement and attacks server side?
Current License: CC BY-SA 3.0
14 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 11, 2015 at 1:31 | history | tweeted | twitter.com/#!/StackGameDev/status/619680358154506240 | ||
| Mar 12, 2015 at 3:08 | answer | added | acheo | timeline score: 1 | |
| Feb 26, 2015 at 6:03 | comment | added | Nick Newman | And once he activates a mob (I already do this by div collision detection [I will need to do this serverside as well later for security, but for now it's fine], I then activate the game attack ticker that will run and send packet data from the gameserver to the client's screen every xx seconds, correct? If so, I would need achieve some type of setInterval function in PHP to do this, I guess this is why PHP would be a bad programming choice for this. Hmm. Thanks for the help thus far, I think I have an idea of how I'm going to do the ticker. I'm going to be playing around in php socket server. | |
| Feb 26, 2015 at 6:03 | comment | added | Nick Newman | Okay, yeah I totally understand where you're coming from now. All that is what I did on my old rpg project last year which was a RTS style Pokemon game. It was boring as crap because monsters didn't have AI. (In my opinion), that is why I'm trying to create this monster auto attack system where there is atleast some type of challenge that is presented to the player (moving the mouse around, paying attention, incorporating monster attack speed using microtime in php, etc). That is what I really want to do now. So what I get from you is, once the character enters the game. | |
| Feb 26, 2015 at 5:57 | comment | added | tkausl | if the last attack was a reasonable amount of time ago, and then update the corresponding entity (hp, aggro, ...) or denies the request, depending on the data he has (is the entity even there? was the last hit only .1 second ago? is the entity to far away?). And if it finishes this run, it either starts a new round instantly or waits a little bit to hit its tickrate correctly. | |
| Feb 26, 2015 at 5:56 | comment | added | tkausl | Yes, exactly, thats what your server has to do. I don't know if it is easy in php, but it should be possible somehow. This is essentially how it works: Your server starts to tick all entities, this means, run their logic, which involves walking around or attacking if there is someone in range, removing dead entities, spawn new entities, maybe regenerate some health of all online players, and then (or even before the update) handle input, which means, if the player attacks, the server gets the attack-request, it checks if its even possible, | |
| Feb 26, 2015 at 5:48 | comment | added | Nick Newman | Oh Yeah tkausl, the game client is really there just for the client side display shenanigans. I'm definitely still using the gameserver for everything. That is my problem now though, I'm trying to use the game server for when the mobs are attacking, but just don't know how. You said a tick-loop. Is this possible with a php socket server? I think we're getting close. Cause I would need to tick the attacks that the mob did to my character ON THE game server, then display it to the client.. Right? (Until the character is dead ofc). That's what I'm thinking anyways. Hmm... We're getting closer. | |
| Feb 26, 2015 at 5:42 | comment | added | tkausl | Well, if you're using a socket-server already, thats okay. But PHP isn't the best language for this (horrible to work with threads). I would do it in Java or C(++) but thats just my preference, it should also work in PHP if you are comfortable with it, you just need to implement a tick-loop, which updates everything on the world. As far as i understand you, the client does all the work and the server just keeps track of the state, thats the wrong way. The server should do all the work, mob movements, attacks and so on and the client just has to show what the server tells it to show. | |
| Feb 26, 2015 at 4:43 | history | edited | Kromster | CC BY-SA 3.0 | deleted 49 characters in body |
| Feb 26, 2015 at 4:39 | comment | added | Nick Newman | Well, it only uses javascript to communicate with the php websocket server with packet senders. And ofcourse javascript to update and move the character around the map. So I guess in essence, it's, a JavaScript game. Hmm.. How would it be done with nodejs though? Anything that is written in javascript can be done in PHP though, right? I don't know if it's worth it to re-write my gameserver into nodejs. I mean, it works and I am more comfortable with PHP for sure. Then again, nodeJS has the setTimeout and setInterval functions that would be very useful for monster AI. I guess? Hmm..I'm lost. | |
| Feb 26, 2015 at 4:33 | comment | added | tkausl | You don't. At least not with PHP. If its a JavaScript game, google for JavaScript sockets and write a Server in NodeJS or some other language you like. | |
| Feb 26, 2015 at 4:28 | history | edited | Nick Newman | CC BY-SA 3.0 | added 145 characters in body |
| Feb 26, 2015 at 4:26 | review | First posts | |||
| Feb 26, 2015 at 8:13 | |||||
| Feb 26, 2015 at 4:22 | history | asked | Nick Newman | CC BY-SA 3.0 |