Action RPG Framework

by Forum_account
Action RPG Framework
A framework for developing action RPGs.
If switch is faster, why are you using if else in front()?

        front(d, w = 0)
if(dir == NORTH)
return top(d, w)
else if(dir == SOUTH)
return bottom(d, w)
else if(dir == EAST)
return right(d, w)
else
return left(d, w)
I'd just check all mobs in obounds() and figure out which one is closest and most directly in front of the player. Letting the players target NPCs would be the most precise, that way they can press tab and be sure of who/what they're targeting.
In response to FIREking
FIREking wrote:
If switch is faster, why are you using if else in front()?

The difference is insignificant. Typically, a large portion of a program's CPU time is spent in just a few functions (those functions are called the bottlenecks). front() isn't that function. You'd have to call front() tens of thousands of times per second to increase the program's CPU usage by 1%. If you caused front() to be called thousands more times, you'd also be causing the bottlenecks to be called more often and their increased CPU time would overshadow whatever difference front() makes.

Also, switch can only improve performance when you have many conditions. With only one or two conditions, a switch statement can't be faster than an if or if/else. With four conditions, there won't be much of a difference. For this code it doesn't really matter, but if/else if/else statements are usually more readable.
In response to Forum_account
Forum_account wrote:
FIREking wrote:
If switch is faster, why are you using if else in front()?

The difference is insignificant. Typically, a large portion of a program's CPU time is spent in just a few functions (those functions are called the bottlenecks). front() isn't that function. You'd have to call front() tens of thousands of times per second to increase the program's CPU usage by 1%. If you caused front() to be called thousands more times, you'd also be causing the bottlenecks to be called more often and their increased CPU time would overshadow whatever difference front() makes.

Also, switch can only improve performance when you have many conditions. With only one or two conditions, a switch statement can't be faster than an if or if/else. With four conditions, there won't be much of a difference. For this code it doesn't really matter, but if/else if/else statements are usually more readable.

Ah, ok!
I prefer Spacebar to not open the inventory if no other interactions occur. Accidentally being positioned wrongly when attempting to talk to an NPC or something similar will end up opening my inventory and unequipping my sword or something.

Edit -
It's an extremely simple tweak that requires a few lines commented out in player-interaction.dm.

Also, there doesn't appear to be an option to clear an ability slot. Or drop/sell items... There seems to be a number of things left out, so I'm not sure whether to bother adding them myself or wait for a future version. Or maybe I'm just expecting F_a to do everything. Hmm...
In response to Kaiochao
Kaiochao wrote:
I prefer Spacebar to not open the inventory if no other interactions occur. Accidentally being positioned wrongly when attempting to talk to an NPC or something similar will end up opening my inventory and unequipping my sword or something.

Agreed.
In response to Kaiochao
I like having the option of using the space bar to open your inventory. I could put that stuff in its own proc so you can override it to change the behavior. Also, increasing the interaction range and slowing the npc's movement could help.

As for the things that are missing, I'll probably add those things eventually. I'm trying to focus on the framework so hopefully the missing features are things that would belong in the demo.
In response to Kaiochao
Kaiochao wrote:
Also, there doesn't appear to be an option to clear an ability slot. Or drop/sell items... There seems to be a number of things left out, so I'm not sure whether to bother adding them myself or wait for a future version. Or maybe I'm just expecting F_a to do everything. Hmm...

To elaborate on this... (since I was posting from my phone earlier)

Clearing abilities is something the framework should provide.

Selling items is something it should provide but I'm not sure about dropping items. There are different things you may want to happen when a player drops an item. You might want it to be destroyed or you might want it to appear on the ground for other players to be able to pick up.

Inventory
key_down(k)
..()

if(k == "d")
var/item/item = current_item()

if(item)
owner.drop_item(item)

I suppose I could add this to the framework, then leave it to the player to define what happens in owner.drop_item - currently it deletes the item but you can override it to change that. Maybe you want it to spawn an /obj/chest at the player's location and move the item to the chest, then make the chest's interact proc show a loot window so you can pick up the item.

There aren't many things I've deliberately left out - there's just a lot to add and I knew this library would be far from complete no matter when I posted it, so I figured it's best to post it early. If there's something else you think is missing it's probably because I haven't thought to add it or haven't had the time. Either way, be sure to let me know... or just add it yourself! =)
client  
key_down(k)
..()
if(k == "g")
usr << "g pressed"


when the Action RPG Framework library is enabled and the above code is added to a .dm file within the demo game, when the "g" key is pressed nothing happens.

when the library is disabled, the above code works great. somewhere within the library is a code that is interfering with the above code. can someone verify this.
demo\abilities.dm:126:error: user.distance_to: undefined proc

Getting this error with the latest download.
In response to Corax Software
Corax Software wrote:
demo\abilities.dm:126:error: user.distance_to: undefined proc

Getting this error with the latest download.

You need the latest version of the pixel movement library. If you don't have the PM library at all, BYOND will automatically download it when you download the framework. But, for some reason, if you have an old version of the PM library it won't automatically download the latest one.
In response to Kalster
Kalster wrote:
client
> key_down(k)
> ..()
> if(k == "g")
> usr << "g pressed"

when the Action RPG Framework library is enabled and the above code is added to a .dm file within the demo game, when the "g" key is pressed nothing happens.

when the library is disabled, the above code works great. somewhere within the library is a code that is interfering with the above code. can someone verify this.

The Keyboard library calls the key_down proc of whatever object has focus (as determined by the client.focus var). The Pixel Movement library and this framework both expect the focus to be your mob. If you override mob/key_down, that code will work (assuming you don't have any on-screen menus open).
Simply amazing Forum_Account. I shall now re-subscribe for a new membership because of THIS.
In response to Branks
Branks wrote:
Simply amazing Forum_Account. I shall now re-subscribe for a new membership because of THIS.

Thanks! I look forward to seeing what you can make with this =)

Since this has gotten such a good reception I might have to dust off the RTS framework I was working on a while ago.

[If there are any developer resources you like, don't forget to become a fan!]
Yut Put wrote:
It would be nice to have an included character creation system. Preferably something that could be included exclusively into any project that uses the pixel movement library(keyboard is required because of the input bar, and pixel movement is required because of freezing the player but the latter of those isnt really as necessary). I'd like something like a procedure that freezes the player and brings up a window asking for name input and a couple different options for a class which the player can click on with descriptions for the selected class. A finalize button would allow the player to close the window and then have the selected name and class.

You should be able to put the character creation stuff in the mob.new_character() proc. I'm not sure how much I can provide. The properties of the character are determined by the game, so the character creation form has to be part of the game too.

Most people would want a big fancy form, but if you're fine with something simple you can do this:

mob
new_character()
class = prompt("What class would you like to be?", "Warrior", "Ranger", "Mage")

I can add procs for different types of prompts. I was thinking about making a generic on-screen menu that looks like the game menu, game options page, or character selection menu. That way I can provide a sample character creation process without going out of my way to make some huge form and still get generic input prompts that can be used for other things.
I'll try to get an on-screen text input prompt in the next version. For now, I've just been using the client's key in the chat log so you don't even see mob names and don't need text input =)
After thinking about it some more, I'm not sure if I want to add this yet. With using maptext it'd be pretty limited. I don't think I'd allow you to use the arrow keys to move the cursor within the string (there's no easy way to show where the cursor is). You'd just be able to type symbols or press backspace to erase the last one.

I'd like to have it possible to make games that use only the keyboard, so it would be nice to have the ability to easily prompt the player to type in some text. It'd also be nice to have this use the consistent on-screen interface.
I'm already working on a game that uses it. The best way to identify features to add to the sidescroller and pixel movement libraries was to use them, I figure the same idea will apply here - I even have the story written for this game. The features I'm adding to the framework itself are starting to get pretty insignificant so I'm starting to work more on this game. Once I add some more AI-related features to the library I'll be in good shape to focus on the game.

One thing that people don't seem to realize is that you don't need to include everything the library provides. If you leave out the quest and inventory features you can make a straight-up action game. If you include all of the features you can make more of an RPG. Based on what you use, in BYOND terms, you could almost make anything from Epic to Casual Quest to Feed to Decadence.
I'm not sure if Tiny Heroes is in a functioning state. Maybe next weekend I'll look into that.
just downloaded and try to run this but ended up with a barrage of errors for some reason.
player-saving.dm:187:error: focus: undefined var
hud-inventory.dm:474:error: client.focus: undefined var
hud-inventory.dm:481:error: client.focus: undefined var
hud-inventory.dm:490:error: client.focus: undefined var
hud-shopkeeper.dm:200:error: client.focus: undefined var
player-targeting.dm:37:error: client.keys: undefined var
enemy-ai.dm:75:error: moved: undefined var
enemy-ai.dm:80:error: client.clear_input: undefined proc
enemy-ai.dm:113:error: moved: undefined var
enemy-ai.dm:114:error: moved: undefined var
hud-abilities.dm:272:error: client.focus: undefined var
hud-info.dm:49:error: moved: undefined var
player-saving.dm:236:error: client.focus: undefined var
player-overlays.dm:66:error: moved: undefined var
player-targeting.dm:29:error: client.focus: undefined var
demo\custom-hud.dm:73:error: client.focus: undefined var
demo\npcs.dm:37:error: moved_to: undefined proc
demo\mobs.dm:85:error: camera.pixel_x: undefined var
enemy-ai.dm:19:error: tick_count: undefined var
enemy-ai.dm:16:error: movement: undefined proc
hud-abilities.dm:99:error: owner.client.focus: undefined var
hud-abilities.dm:89:error: owner.client.focus: undefined var
hud-abilities.dm:61:error: key_down: undefined proc
hud-abilities.dm:144:error: owner.client.focus: undefined var
hud-info-bar.dm:88:error: owner.client.focus: undefined var
hud-info-bar.dm:108:error: owner.client.focus: undefined var
hud-quests.dm:56:error: owner.client.focus: undefined var
hud-quests.dm:60:error: owner.client.focus: undefined var
hud-quests.dm:66:error: owner.client.focus: undefined var
demo\abilities.dm:168:error: user.distance_to: undefined proc
demo\custom-hud.dm:45:error: list_box.key_down: undefined proc
demo\custom-hud.dm:35:error: key_down: undefined proc
demo\custom-hud.dm:58:error: owner.client.focus: undefined var
hud-abilities.dm:149:error: key_down: undefined proc
hud-game-menu.dm:57:error: owner.client.focus: undefined var
hud-game-menu.dm:62:error: owner.client.focus: undefined var
hud-game-menu.dm:67:error: owner.client.focus: undefined var
hud-game-menu.dm:77:error: owner.client.focus: undefined var
hud-game-menu.dm:137:error: owner.client.focus: undefined var
hud-game-menu.dm:166:error: owner.client.focus: undefined var
hud-info-bar.dm:86:error: key_down: undefined proc
hud-inventory.dm:115:error: owner.client.focus: undefined var
hud-inventory.dm:120:error: owner.client.focus: undefined var
hud-inventory.dm:125:error: owner.client.focus: undefined var
hud-inventory.dm:210:error: owner.client.focus: undefined var
hud-inventory.dm:390:error: owner.client.focus: undefined var
hud-inventory.dm:386:error: key_down: undefined proc
hud-loot-window.dm:63:error: owner.client.focus: undefined var
hud-loot-window.dm:82:error: owner.client.focus: undefined var
hud-loot-window.dm:107:error: owner.client.focus: undefined var
hud-mob-selection.dm:92:error: owner.client.focus: undefined var
hud-mob-selection.dm:82:error: key_down: undefined proc
hud-prompt.dm:139:error: c.keys: undefined var
hud-prompt.dm:114:error: key_down: undefined proc
hud-prompt.dm:196:error: owner.client.focus: undefined var
hud-prompt.dm:197:error: owner.client.focus: undefined var
hud-prompt.dm:203:error: owner.client.focus: undefined var
hud-quests.dm:40:error: key_down: undefined proc
hud-shopkeeper.dm:63:error: customer.client.focus: undefined var
hud.dm:128:error: key_down: undefined proc
hud-game-menu.dm:47:error: key_down: undefined proc
hud-game-menu.dm:127:error: key_down: undefined proc
hud-inventory.dm:111:error: key_down: undefined proc
hud-loot-window.dm:66:error: key_down: undefined proc
hud-shopkeeper.dm:60:error: key_down: undefined proc

Page: 1 2 3 4 5