Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (636)
Games in Android Showcase (178)
games submitted by our members
Games in WIP (687)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  alternatives to per-frame functions?  (Read 1477 times)
0 Members and 1 Guest are viewing this topic.
Offline deepthought
« Posted 2011-11-03 00:36:34 »

 i noticed that in quake, the AI is written as a set of functions, with one function for each frame.
in each function, it tells the game which to call next. it looks something like:
attack1(){ modelframe =1; nextthink=attack2;}
attack2(){modelframe=2; nextthink = attack3; damage(enemy); nextthink=run1}

and so on.
if you save, say, in mid-attack, and load, the enemy will be in exactly the same position he was when you save.
however, i think that if you write the AI as one large function, when you load, the enemy will revert to idle position and have to spot you again.

is there any way to preserve the progress of an enemy when you save other than frame functions?
maybe if you serialize while the method is still executing, or will that cause an error?

or should i use an interpreted script?

Mad Scientist
Offline lhkbob

JGO Knight

Medals: 32

« Reply #1 - Posted 2011-11-03 05:36:22 »

Why not remember the state of each bot in the game.  So if they see you and are attacking, they have some set of state for attacking, ex: (PLAYER_SEEN=TRUE, MOVING_TO_ATTACK=FINISHED, RAISING_WEAPON=TRUE, FIRED=FALSE).  Of course some of this state should probably be stored in the animation state that needs to be saved, if you really want to get detailed.

They just grouped their AI and animation state together inside the function calls, but that doesn't mean it's the only or best way.

Offline deepthought
« Reply #2 - Posted 2011-11-04 01:11:09 »

hmmm... how can i make this easier for modders?

maybe have a program to add the state checks where certain function calls are present and set a variable to tell where it is and if statements to skip over already visited code.

Mad Scientist
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Evil-Devil

Senior Devvie

Medals: 3

Fir Tree Master

« Reply #3 - Posted 2011-11-04 09:33:43 »

I don't suggest to safe the actual situation. That could cause the player to run amok Wink Depending on your game the player should restart at the last possible checkpoint. Restarting directly in the action could be pretty annoying.

Thats just my point of view. For the question, yes i think this kind of per frame function is the only way, when you don't have something like a global tick that controls the whole gameflow. Then you could save the last tick state and start from there.
Offline deepthought
« Reply #4 - Posted 2011-11-04 12:19:08 »

i know i can save which frame it's on and what sequence it's playing, but how do i save where it is in the code?

how does this global tick work?

Mad Scientist
Offline Cero
« Reply #5 - Posted 2011-11-04 14:08:44 »

If you serialize "enough" you should be fine ?

Offline Evil-Devil

Senior Devvie

Medals: 3

Fir Tree Master

« Reply #6 - Posted 2011-11-07 10:23:21 »

how does this global tick work?
It does work independently on your renderer. In the unreal engine for example the whole logic is determined by the Tick. So when a pawn enters a specific state, you could save that state and even subanimation info. I think you could even save the position of the animation or recalculate it on the current tick value. Lets say the walking state was entered on Tick 5.000 and now the player likes to save his game. Current Tick is 5.025 and the walking animation takes 7 ticks to be done. That would make up 3 full walking sequences and the fourth is at 3/7 in his animation.

Sounds plausible Wink
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Dwinin (72 views)
2015-11-07 13:29:08

Rems19 (81 views)
2015-10-31 01:36:56

Rems19 (77 views)
2015-10-31 01:32:37

williamwoles (107 views)
2015-10-23 10:42:59

williamwoles (93 views)
2015-10-23 10:42:45

Jervac_ (110 views)
2015-10-18 23:29:12

DarkCart (135 views)
2015-10-16 00:58:11

KaiHH (117 views)
2015-10-11 14:10:14

KaiHH (156 views)
2015-10-11 13:26:18

BurntPizza (172 views)
2015-10-08 03:11:46
Rendering resources
by Roquen
2015-11-13 14:37:59

Rendering resources
by Roquen
2015-11-13 14:36:58

Math: Resources
by Roquen
2015-10-22 07:46:10

Networking Resources
by Roquen
2015-10-16 07:12:30

Rendering resources
by Roquen
2015-10-15 07:40:48

Math: Inequality properties
by Roquen
2015-10-01 13:30:46

Math: Inequality properties
by Roquen
2015-09-30 16:06:05

HotSpot Options
by Roquen
2015-08-29 11:33:11 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!