Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (525)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (592)
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 1221 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:
1  
2  
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?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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.


jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Evil-Devil

Senior Devvie


Medals: 2


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?

jocks rule the highschools. GEEKS RULE THE WORLD MWAHAHAHA!!
captain failure test game
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: 2


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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

toopeicgaming1999 (67 views)
2014-11-26 15:22:04

toopeicgaming1999 (58 views)
2014-11-26 15:20:36

toopeicgaming1999 (12 views)
2014-11-26 15:20:08

SHC (24 views)
2014-11-25 12:00:59

SHC (24 views)
2014-11-25 11:53:45

Norakomi (29 views)
2014-11-25 11:26:43

Gibbo3771 (24 views)
2014-11-24 19:59:16

trollwarrior1 (37 views)
2014-11-22 12:13:56

xFryIx (76 views)
2014-11-13 12:34:49

digdugdiggy (53 views)
2014-11-12 21:11:50
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!