ID:153851
 
Okay, I was wondering how people did their skills/attacks

Here's what I do.


From the depths of the Super Hero Bash Library Archives....
skill
parent_type = /obj
proc/Action()// we'll use this later
DblClick()
if(src in usr.skills)//if it is in the persons skills list
Action()//callt he action
else//if not
..()//regular shiznits


That's how I call the powers (you doubleclick the power in your powers statpanel and an action is perfermed)


Here is an example:

skill/superhuman// Super Human skills
superspeed // Super Speed skills
FastMove // Super Speed Skill FastMove
Action()
set src in usr
if(usr.mode== "Speed")
usr.mode = "Walk"
else
usr.mode = "Speed"


That's how most of the powers are called. If you need more examples, be sure to ask. I have some that I can give out.

I was wondering how I can make it well.... better. I don't really know what I mean but...this seems...sucky. It's more like a verb and can get mixed up alot. (Most of the Teleportation powers are like this, you can't teleport to your saved locations, well...you can. You go through everyone in your list)

Anyways, back to the point. How can I make this...errr, I don't know what I'm looking for. I just think that this is too messy. It's more like a verb. I am looking to make it easy to add in new powers. Gah...everything is just...gah... Please help.

-Sariat
Help, anybody?
Sariat wrote:
I was wondering how I can make it well.... better. I don't really know what I mean but...this seems...sucky. It's more like a verb and can get mixed up alot. (Most of the Teleportation powers are like this, you can't teleport to your saved locations, well...you can. You go through everyone in your list)

Anyways, back to the point. How can I make this...errr, I don't know what I'm looking for. I just think that this is too messy. It's more like a verb. I am looking to make it easy to add in new powers. Gah...everything is just...gah... Please help.

But it's not a verb; rather, Action() isn't. You defined that as a proc, so the "set src in usr" line is totally inappropriate. Action() is always called by a verb (DblClick()), however, so it's usr-safe.

I think this system of setting up a dummy proc and then overriding in subtypes it is just fine. I do the same myself with many things.
It seems to me what you're really asking is how to improve the way Action() operates in cases where you have to have more information, like teleporting to a destination. That I can't answer without seeing some code for those.

Lummox JR
In response to Lummox JR
Hrm, let's say that I want a power that would have an energy field around the user to protect them from harm (for a short while or until the force field is broken or something like that)

Here is what I would do:

Create a forcefield item.

For the forcefield item, whatever bumps into it (and is harmful to it's owner) gets deflected/destroyed/stopped. (via Bump() command)

When the Action() proc is called, have a forcefield item placed all around the user in a 1 tile radius.

Action()
while(energyfieldison)
subract user's endurance
if(user's endruace below 1/2 of normal)
destroy user's forcefield



How would YOU program a forcefield power?


Here's another one....

Power:Energy Blast

Create an EnergyBlast Item.

Give it a tag that shows that it is harmful and of the Energy type (just incase somebody is immune to Energy attacks)

Create a general projectile proc that shoots things out for a set amount of distance/time. It determines if the projectile is explosive, burning, acidic, etc. It also determines how much of a radius it has and what type of attack type it is. (Some people can be immune to certian powers)

When Action() is called, it calls the projectile proc.


How would you do that?

-Sariat




In response to Sariat
I'm not sure if this will help your problems exactly, but I've found it extremely useful myself for setting 'traits' on the fly (such as "harmful","energy","acidic", etc)

First, you want to make list for ATOMs, something like this:
atom
var
list
properties = new/list()

This is going to hold all traits for a particular area, turf, object, or mob.

Next, you need some procs to manipulate that list more easily and intuitively

atom
var
list
properties = new/list()

atom
proc

query_property(property) //used to find a particular property.
if(properties.Find(property))
return properties[property]

add_property(property, value) //add a property to the ATOM
if(!value)
value = 1
properties.Add(property)
properties[property] = value

remove_property(property) //remove a property from the ATOM
properties.Remove(property)


Now, if you wanted to set an object to be harmful, simply use
src.add_property("harmful")


It now has the harmful property.

To check it, a simple if statement should work fine:
if(query_property("harmful"))


The preceding statement should return true.

For your energy, acidic, etc damages, I'd use this:
add_property("damage type","acidic")

and use the same functionality, only check for specifics

if(query_property("damage type") == "acidic")


I'm not sure if you could have multiple "damage type" entries and have it still work. I haven't had the need for it so I haven't tested it.

Hope that helps some.

-<font color = #0000FF>Sapphiremagus</font>
In response to Sariat
How would YOU program a forcefield power?

A pretty common method I use for a lot of things like this is to set up an /effect datum and give atoms an effects[] associative list. Depending on what I need these sorts of effects for, I'll define a couple of procs that effects can use; for instance, one of the more common things I do is set up something like this:

/effect
var
atom/target //this points at the atom the effect belongs to

New(atom/A)
target = A
target.effects.Add(src)

Del()
if (target)
target.effects.Remove(src)

proc
Tick()

/atom
var
effects[] = list()

proc
TickCycle()
for (var/E in effects)
var/effect/F = effects[E]
F.Tick()


There's obviously quite a bit more that can go in, but hopefully you get the idea. Your forcefield effect might look something like this under such a scheme:

/effect
forcefield
var
declare a variable or list to point to the actual forcefield object(s)

New(mob/M)
. = ..()
generate a forcefield around M

Del()
delete the forcefield object(s)
. = ..()

Tick()
if (target's endurance is less than 50%)
del src


Then the actual forcefield Action() would more or less just do new /effect/forcefield (usr).

Here's another one....

Power:Energy Blast

Create an EnergyBlast Item.

Give it a tag that shows that it is harmful and of the Energy type (just incase somebody is immune to Energy attacks)

Create a general projectile proc that shoots things out for a set amount of distance/time. It determines if the projectile is explosive, burning, acidic, etc. It also determines how much of a radius it has and what type of attack type it is. (Some people can be immune to certian powers)

When Action() is called, it calls the projectile proc.


How would you do that?

Rather than having a projectile proc, I'd probably define a projectile object type. A very stripped-down implementation:

/obj
projectile
var
damageType
damage

icon = 'shooty_things.dmi'

New(NewLoc, Dir)
. = ..()
Fly()

Fly()
step(dir)
spawn(1) Fly()

Bump()
do the hurting and dying and such

/skill
superhuman
projectile
var
type
damageType
picture

proc
Action()
var/obj/projectile/P = new (usr.loc, dir)
P.damageType = damageType
P.damage = damage
P.icon_state = picture

EnergyBlast
damageType = "energy"
damage = 100
picture = "energy blast"

DeathRay
damageType = "ridiculously overpowered"
damage = 10000000000
picture = "death ray"


This way all your shooting powers inherit the one Action() proc and you can just plug in variables. For more special types of projectiles, you can either add in variable functionality (such as a radius variable that determines how big the explosion [if any] is, a homing variable, and so on) or else you can define subtypes of /obj/projectile and add a projectileType variable to your projectile power type, so that the top line of the Action() proc above would be
var/obj/projectile/P = new projectileType (usr.loc, dir)

In general I like using specialized subtypes for this sort of thing if I know all the projectile types I'm going to be needing ahead of time and know that none of them are going to overlap. Having separate types for explosive projectiles, homing projectiles, bouncing projectiles, etc. is all well and good, but then if you decide you want bouncing homing explosive projectiles you're kinda screwed.

Note that this sample code is pretty crappy and I don't claim to be a coding expert in any form, but I think it works OK.