by loafingcoyote » Sun Sep 23, 2012 12:09 am
As promised, here is
Super Madball!
This isn't likely to make it to the archive anytime soon, but it is an effective demonstration game and I hope it's at least a little entertaining. Like I said before, this game is sometimes going to be hurt by too many characters doing too many things. I was able to implement some message compression, mostly when characters score points and when they recover from losing a fight. But that's only a small part of what happens in this game.
I would prefer to package this with the source, but it's too rough and the core RAP code needs to be revised. I will however, share a little bit about how it works:
The extension is broken into two parts. The core simply cues up the actions that have been defined in their proper order. If an action can't be taken then it is skipped and other actions are tried until one is executed successfully. The resulting code is small and efficient.
The second part is made up mostly by what I've termed "action tokens" or just "tokens", for short. The extension will come with a standard library of these tokens. They will work for very simple character behavior(i.e. picking up and dropping specific items, opening and closing containers, locking and unlocking objects, ect...)
This is fine for very simple behavior. But to have characters react to more specific situations in your game, it will be necessary to modify these existing tokens or write your own. Writing an action token is as simple as making a routine that defines a discrete action that you want a character to take. A silly example:
Code: Select all
! KickObject
!
! Makes a character kick an object, giving it the "kicked" attribute.
!
! requires:
! obj1 [object to be kicked]
routine KickObject
{
if test_plan.obj1 is kicked
{
if test_plan.priority = 20: test_goal is special
! This simply tells the core
! of the RAP that if the can is
! already kicked and all lower
! priority items behind it should
! be skipped as they are not needed.
plan_flag = false ! plan_flag set to false when an action isn't taken.
return false ! Always return false when an action isn't taken
}
if Contains(parent(char_obj), test_plan.obj1)
{ ! Is the defined object(in this case a can)
! in the same place as the character?
test_plan.obj1 is kicked
if Contains(location, char_obj)
{
CThe(cha_obj)
" kick";
MatchSubject(char_obj)
" ";
The(test_plan.obj1)
"."
return true ! Always return true when an action is taken.
}
plan_flag = false ! The can wasn't kicked, but it wasn't accessible to
return false ! the character either, so no action was taken.
}
}
The object that called this token routine could be given whatever priority is required. The higher the priority, the sooner it's checked. If it's given a priority of 20 and the can already has the "kicked" attribute, then no lower priority action tokens are tried that are in the same cue. Other items in the same cue as this one might include moving the character to the can or taking the can from another character. And, of course, other higher or lower priority cues can easily coexist with this one. So if your character happened to find a gold coin, then he could pick it up and then continue on his quest to kick the can next turn.
That's the bare bones version. I'll work on the RAP and try to make it presentable soon. For the time being, enjoy the game!
-lc
As promised, here is [url=https://dl.dropbox.com/u/11102009/madball.zip][i]Super Madball![/i][/url]
This isn't likely to make it to the archive anytime soon, but it is an effective demonstration game and I hope it's at least a little entertaining. Like I said before, this game is sometimes going to be hurt by too many characters doing too many things. I was able to implement some message compression, mostly when characters score points and when they recover from losing a fight. But that's only a small part of what happens in this game.
I would prefer to package this with the source, but it's too rough and the core RAP code needs to be revised. I will however, share a little bit about how it works:
The extension is broken into two parts. The core simply cues up the actions that have been defined in their proper order. If an action can't be taken then it is skipped and other actions are tried until one is executed successfully. The resulting code is small and efficient.
The second part is made up mostly by what I've termed "action tokens" or just "tokens", for short. The extension will come with a standard library of these tokens. They will work for very simple character behavior(i.e. picking up and dropping specific items, opening and closing containers, locking and unlocking objects, ect...)
This is fine for very simple behavior. But to have characters react to more specific situations in your game, it will be necessary to modify these existing tokens or write your own. Writing an action token is as simple as making a routine that defines a discrete action that you want a character to take. A silly example:
[code]
! KickObject
!
! Makes a character kick an object, giving it the "kicked" attribute.
!
! requires:
! obj1 [object to be kicked]
routine KickObject
{
if test_plan.obj1 is kicked
{
if test_plan.priority = 20: test_goal is special
! This simply tells the core
! of the RAP that if the can is
! already kicked and all lower
! priority items behind it should
! be skipped as they are not needed.
plan_flag = false ! plan_flag set to false when an action isn't taken.
return false ! Always return false when an action isn't taken
}
if Contains(parent(char_obj), test_plan.obj1)
{ ! Is the defined object(in this case a can)
! in the same place as the character?
test_plan.obj1 is kicked
if Contains(location, char_obj)
{
CThe(cha_obj)
" kick";
MatchSubject(char_obj)
" ";
The(test_plan.obj1)
"."
return true ! Always return true when an action is taken.
}
plan_flag = false ! The can wasn't kicked, but it wasn't accessible to
return false ! the character either, so no action was taken.
}
}
[/code]
The object that called this token routine could be given whatever priority is required. The higher the priority, the sooner it's checked. If it's given a priority of 20 and the can already has the "kicked" attribute, then no lower priority action tokens are tried that are in the same cue. Other items in the same cue as this one might include moving the character to the can or taking the can from another character. And, of course, other higher or lower priority cues can easily coexist with this one. So if your character happened to find a gold coin, then he could pick it up and then continue on his quest to kick the can next turn.
That's the bare bones version. I'll work on the RAP and try to make it presentable soon. For the time being, enjoy the game!
-lc