Action RPG Framework

by Forum_account
Action RPG Framework
A framework for developing action RPGs.
ID:1458967
 
Valoesdte wrote:
i like this a lot but im having a problem adding custom skills. I would add in a skill give it to player but I seem to not understand the whole Bind_key function. bind_key("q", abilities[1]) the 1 number? What is it linked to. how do I find the number for my own custom abilities I add to the game? Thanks


Hi, sorry if starting a new thread is inconvenient, but I feel like it's better than clogging up the general thread. Other people might have similar questions regarding bind_key and list/abilities, so separation is plus there too.

What you're seeing in /demo/mobs.dm is below new_character
        // give the player some attacks
abilities += new /Ability/MeleeAttack()
abilities += new /Ability/Cleave()
abilities += new /Ability/Poison()
abilities += new /Ability/Fireball()
abilities += new /Ability/ShootArrow()

// and a crafting ability
abilities += new /CraftingAbility/MakeSword()

// Bind MeleeAttack and Cleave to the 1 and 2 keys.
// The on-screen ability bar will automatically be
// updated to show these key bindings.
bind_key("1", abilities[1])
bind_key("2", abilities[2])

// bind the crafting ability to 6.
bind_key("6", abilities[6])


First lets break apart bind_key(k, Ability/ability) and then I'll point out how he added the abilities to list/abilities.
bind_key("*/key you're binding to*/", abilities/*this is a list!*/[*/num/spot of ability you want to bind from list/abilities*/])


You can look in player-abilities.dm to find bind_key, and list/abilities = list() but first let me point out the order of the abilities += new. They take the order of 1-6, and after that, when you ability += new it will be 7, then 8, etc. So, if you're not giving the ability to a player at creation there, your custom ability will be abilities[7] and so on. I hope this helps.
okay so I get that now how does this work with cooldowns. I make a new skill and it is firing off every second i press the button. for example I put the cooldown for the ability to 30 but it says in teh game it has a 1 sec cooldown. Is there somewhere in the framework i need to put individual cooldowns?
Show us your new Ability and how you're using cooldown(cooldown_name, cooldown_duration). Also a reminder, that those numbers are divided by tick_lag which is 0.25, so 30 is only 1.2 seconds (I think this is true).
Not sure of the code on here to quote code but here is a screenshot. http://gyazo.com/84893f5168494660f3d892a6bf890739
So the cooldown shown in that picture says 100. What's your cooldown for Soulbane now?

edit: also the tags are <> and its dm to start and /dm to close
Try this, and if it works I'll explain why.

Goto demo\abilities.dm and replace "Soulbane" in can_use() with "soulbane", and "fireball" under effect to "soulbane". Next, change your new /projectile/ to soulbane, then add a soulbane projectile like so. Just go to the bottom of demo\abilities.dm and you'll see projectile datum.

projectile
fireball
damage = 15
icon_state = "fireball"

pwidth = 20
pheight = 16
pixel_x = -6
pixel_y = -5

move_speed = 5

// make it use the MagicCombat object to deal damage
hit(mob/m)
MagicCombat.attack(owner, m, damage)

movement()
effect("flame", layer = layer - 1)
..()

// *** The above was already at the end demo\abilities.dm

soulbane
damage = 25
icon_state = "fireball"

pwidth = 20
pheight = 16
pixel_x = -6
pixel_y = -5

move_speed = 5

// make it use the MagicCombat object to deal damage
hit(mob/m)
MagicCombat.attack(owner, m, damage)

movement()
effect("flame", layer = layer - 1)
..()
nope I changed it to
Soulbane
name = "Soul Bane"
icon_state = "soulbane"
description = "Shoot out a blast from your sword that deals ARCANE DAMAGE"
animation = "attacking"
mana_cost = 5
cooldown = 100
// fireball also has a cooldown
can_use(mob/user)
if(user.on_cooldown("soulbane", "attack"))
return 0
else
return ..()

effect(mob/user)

user.cooldown("fireball", cooldown)
user.cooldown("attack", 10)

// All we do is create the projectile, everything is handled
// by the /projectile/fireball definition and the built-in
// behavior of the /projectile type.
//
// If your target is null, the projectile's New proc (as defined
// by the framework) will fire the projectile in the direction
// you're facing. If your target isn't null, the projectile will
// be fired in the precise direction of your target. That doesn't
// mean it's guaranteed to hit your target, but it's better than
// only being able to shoot in 8 directions.
new /projectile/fireball(user, user.target)

user.noise('fire.wav', frequency = rand(0.7, 1.3))
No change. Its like its ignoring cooldown all together and as long as you have mana for it you can keep spamming it.
and here is the projectile
 projectile
fireball
damage = 15
icon_state = "fireball"

pwidth = 20
pheight = 16
pixel_x = -6
pixel_y = -5

move_speed = 5

// make it use the MagicCombat object to deal damage
hit(mob/m)
MagicCombat.attack(owner, m, damage)

movement()
effect("flame", layer = layer - 1)
..()
soulbane
damage = 25
icon_state = "fireball"

pwidth = 20
pheight = 16
pixel_x = -6
pixel_y = -5

move_speed = 5

// make it use the MagicCombat object to deal damage
hit(mob/m)
MagicCombat.attack(owner, m, damage)

movement()
effect("flame", layer = layer - 1)

..()
Oh hey, look at the cooldown underneath effect(mob/user), and change it from fireball to soulbane, and it will work.
Thanks! I got it. lmao thanks for sticking in there with me. You mind if I message you if I have any more questions in the future?
Thanks for helping out here, Gandalf!

One thing that might make it easier is to pass src.name to the on_cooldown and cooldown procs - that way if you copy and paste the ability to make a new one, you don't have to change "soulbane" to something new, it'll automatically use the ability's name for tracking the cooldown.