ID:156753
 
I am going to divide this up and hopefully you can get what I am trying to say. :)

Scenario:
Ok say you chose a race of being an attacker and then you choose a person like a sword staff or dagger. Ok I choose the person with a staff. I start off with one attack, that also tells me how many times i can use that attack, in a panel named "Attacks" and when I level up i get more attacks in that same panel.

Question:
How do i make it to where when i choose that certain race, a cat. or a panel appears called attacks and it already shows my first attack for that person along with how many uses i have with that attack. Also to make it appear so that way the other races wont have the same attacks as the other races. (Like: Fire spell wont appear if you choose a warrior person something like Lunge would appear if you chose it)

Thought:
again say i chose a staff person and the first attack is something like a fire spell. ok a fire spell shows up in the attacks column along with like 25 uses of it. So when i click the attack it will be used and one of the uses for the fire spell when have gone down by one.


Thanks Roflmao!

These are some really rudimentary questions, and the root of the problem is that you aren't actively TRYING to learn. Instead of trying to make a game, you really ought to spend your first few months trying to program by trying to fail.

In other words, you need to follow some tutorials. Then, once you have basic programming concepts and skills under your belt, you should set out to make a few small things. Don't start out with large aspirations. Just make some small, but increasingly complex systems.

Eventually, you are going to run into problems. These problems are not a bad thing, they are a good thing. We learn the most from something we struggle with and not from something that is easy.

Once you get your first few problems, try to solve them. Do not immediately ask someone else to riddle it out for you until you have been thoroughly stumped for several hours or days.

This will build your skill faster than anything else.
In response to Ter13
i did try....... when i choose this race the attack panel doesnt show up nor at least the attack itself. For the record I read that long godforsaken guide and my freakin brain melted from all that info. all i asked for was a simple response either showing me at least a boost so i can do the rest not a remark like that. I know its probably the truth of what you are saying but instead putting other folks down how about helppin them first. >_>

this is how i have it so far

mob
Stat()
statpanel("Attacks")
stat(src)
stat(new/obj/Attack/Fire_Spell)



In response to Roflmao1298
Well i'm not a programmer so I can't just make whatever you need but I'm fairly certain you can't put new/obj/Attack/Fire_Spell inside of a stat panel. If you want the attack to be a function you need to make it a verb.

???
In response to UmbrousSoul
you might be right, but that still doesnt explain why it doesnt at least show up in a column though.


Tbh this was how a library done it so, and it worked for the library. So i tried to use some similarites from the library. but it neva worked though.
In response to Roflmao1298
Well like I said I'm not a programmer so I can't really help you like you need but I can contemplate the problem with you.

The library probably has it defined in a certain way so that it does work.

Best bet is to look at the library a bit more complex and try to trail where the function is defined, and copy that over to your project.

But they say that a bad library is one that you have to take snippets from, insert into your game, and change it to make it work. I don't know, a lot of libraries are exactly that.
In response to UmbrousSoul
hmm true, and yea i know at least you did wat you could though.

I am tryin to analyze the coding of the library so I can figure out how they did it.
In response to Roflmao1298
I suggest you reconsider the tone of my last post. It was meant to be quite helpful, and not a complete shutdown.

Your first post was not a complex theoretical design question, it is something extremely basic, and it is generally frowned upon to post a question of how to do something so basic without a show of good faith (I.E. code). Now that you've done that, I'll be more than happy to help you with your problem, and explain why it's not working! =D

mob
Stat()
statpanel("Attacks")
stat(src)
stat(new/obj/Attack/Fire_Spell)


The real problem here, is that you aren't actually giving the Stat() proc anything to work with. Also, Stat() is called every tick(), and so is garbage collector. Nothing is referencing the new attack you are creating, and as such, it's deleted by the engine since nothing is using it. Something has to be referencing the object in order for the engine to hang on to it, and not just immediately delete it.

In this case, it's not only completely useless to do something like this, it's also highly flawed from a memory usage perspective. If the garbage collector wasn't deleting this object, it would be generating 10 attacks every second per attack per player. Meaning 20 players with 25 attacks each would be generating 5000 new objects per second. That's just bad practice!


Criticism is all well and good, and helps you understand where you went wrong, but it certainly doesn't help you fix your problem, now does it?

I assume you want to make it so that the attack is used when you click on it?

For starters, you're going to need to keep track of which players have which attacks. You are also going to need a way to keep track of the attacks themselves.

In most games, I've seen amateur developers put a list of objects in the player's variables to keep track of their attacks, but I find this to be somewhat inconvenient from a usage standpoint, and could easily be replaced by a much less memory-hungry version of the code:

Putting the attacks in global space:

var
list/attacks = list()
proc
generate_attacks()
var/list/gen = typesof(/obj/attack)
for(var/v in gen)
//if using text key
global.attacks += "[v]"
global.attacks["[v]"] = new v()
/*
//if storing index/object only
global.attacks += new v()
*/


obj/attack
proc
used(var/mob/user)
//define how the attack is used in here
Click()
src.used(usr)

world
New()
. = ..()
spawn()
//called after all the default behavior finishes.
global.generate_attacks()
return .


Now that we have all of our attacks sitting in the global space, how exactly do we use them? Well, that's pretty simple. Numbers! Just supply the player with a list of numbers that sync up with the attacks inside of the global list, and you're good to go!

Of course, you can always just leave store the type, name, whatever as the key in the global linked list, or you can go even further by doing away with the key altogether and just reference it by position, or you can just add the object itself of the mob's attacks while keeping the object in the global scope so that you don't have 20 different attacks for each player when the attacks are basically the same anyway.

mob/var
list/attacks = list()

Stat()
statpanel("Attacks")
for(var/v in src.attacks)
stat(global.attacks[global.attacks[v]]) //if storing numeric index
//stat(global.attacks[v]) //if storing text or number with no key
//stat(v) //if storing the object itself


Make sure you add a reference to the global object in the player's attack variable however you manage it.