|
Post by yahn12 on Nov 23, 2004 10:49:23 GMT -5
Ok this is more of a discussion then a question of how to.. What techniques do you find best for making your inventorys in your RPGs? Do you use Arays or another method? If you use arays how do you set it up? just inventory[0]=0 then when you pick something up assign its ID to the inventory[0] and have another object draw inventory[0].sprite_index at the location assigned for the space inventory[0].
Has anyone developed a system for agro management that their Mobs use? I can't really think of an efficient way to do something like this. How would you go about coding a system like this in a game? If you dont know what agro management is. It's when mobs target players based on the types of attacks they do and spells they cast. And that player doesn't have to be attacking the Mob to agravate it, thats the tricky part. You can't just do it based on damage either, well you could but it wouldn't be a very good system if you did.
I really need help with these topics so if you have any help for me please post. And if anyone has created a Agro system I would really like to see an example of that or something. Ty..
|
|
|
Post by megamushroom on Nov 23, 2004 11:16:47 GMT -5
i use arrays for my inventory's, so:
inven[0,0]="potion" //name inven[0,1]=3 //quantity etc, i use some more variables, but im sure you have your own.
agro, hmmmm, i havent realy heard of this, but, form what you said, id just have the mobs constantly checking the players spells and attacks.
if you store them in arrays, it will make it easier to find. once found, add 1 to agro or something.
|
|
|
Post by yahn12 on Nov 23, 2004 11:27:01 GMT -5
ahh.. using arays probably could work. how would u set it up tho? because it will only agro monsters if they are within their range.. So would you save where the spells hit as a seperate aray? And how would you go about checking that in? if distance_to_point()? I've heard that lots of distance_to_point() codes cause slow down in games. then would you have another aray for the monsters agro or just a variable and add certain amounts to it based on certain spells?
and for the inventory I never thought of setting the aray up like that for stackable items.. I guess I finally figured it out.. ty..
|
|
|
Post by IsmAvatar on Nov 23, 2004 13:58:59 GMT -5
for inventories, I use arrays, but there's no need for a second dimendion; just use a second variable. dimensions are meant to be looped through.
If d2 is just to seperate name, qty, use, quality and so on - rather than having to remember what number is what, just use another variable.
invobj[m] = "Potion" invcnt[m] += 1
|
|
|
Post by megamushroom on Nov 24, 2004 15:37:04 GMT -5
never thought of doing it like that...
not much difference in the code overall, so ill stick with my method
the distance _to_point shouldn slow down your game too much, it only checks the nearest object of that type, and im guessing the mobs are al the same type of object?
how are you actually storing your spells? if its arrays, you could use:
if distance_to_object(enemy)<100{ if spell_array[0]="fire" or if spell_array[1]="fire"{ agro+=1} }
etc
not very practical, but if you use a for loop, it wil check if ALL of the arrays have that as the name. Im a bit out of touch with gamemaker at the moment, im learning vb, so that probably isnt the best method.
Hope any of that helped
|
|
|
Post by yahn12 on Dec 19, 2004 1:06:48 GMT -5
hmm.. Ism I like the inventory idea you gave me a lot. I think it would get confusing tho, unless I would use the whole name of the object for the name of the variable, which is no big deal.. I will probably use that idea for my inventory system.
Mega I never thought of doing agro like that. But I'm not saving my spells being cast as arrays, so.. I will probably change that and modify the script to make it more like what I want.. Thank you for your help
I'm going to ask this question here because I always get good answers on this forum I have asked this and never got the right answer. You know how in games The mana and HP always take up the same amount of space. Say 100 pixels but the mana or HP can equal any amount and still only take up that much space. How would I have it draw the amount of HP for each pixel. Because it can't be exact because then you will end up getting like 1.254803 pixels for each HP and it won't know how to draw that. This is probably something simple. Can anyone help?
|
|
|
Post by Niitaka on Dec 21, 2004 15:30:53 GMT -5
Just divide the current HP by the max HP to get a percentage. Then multiply it by 100 so you can get a number, then use the floor function to get rid of the numbers after the decimal.
Ex. width_of_bar = floor((current_hp / max_hp)*100);
|
|
|
Post by IsmAvatar on Dec 21, 2004 16:45:51 GMT -5
you use a similar method if you want to make your own healthbar, and it's a special size.
divide current hp by total hp, and then multiply it by whatever the maximum width of the healtbar is.
say, 100 pixels is a lot, something more like 64 pixels is more appropriate draw_rectangle(x,y,x+hp/max_hp * 64,y+16,1)
|
|
|
Post by yahn12 on Dec 23, 2004 0:42:41 GMT -5
Ok thanks for the help ism. That worked perfect.
Now back to my agro question. I know exactly how this works and I have an idea of what I need to do but I just want to make sure this right. First thing I need is for spells to have an agro amount. Thats simple just set a variable. Next thing I need to do is have spells triger a radius depending on how threatening they are. Thats simple I just set a variable for the radius and have it check distance to objects and set their agro higher (this will slow the game down I fear so I'm looking for a better Idea) Next I need to have the mobs check to see which players are causing the most agro, so It has to save each players agro and check it. The agro also has to detereorate after a while. Now this is where I don't really know what to do. I already have a variable for who casts the spell but how am I going to save the player who cast the spells agro inside the mob and then add to it everytime it casts a threatening spell? Then the last part having it attack the target with the highest agro will not be hard. All i have to do is check for which agro is the highest and have it attack that target.
So can anyone tell me how I would script this efficently? Thank you.
|
|
|
Post by dwmitch on Jan 23, 2005 3:16:48 GMT -5
Ok thanks for the help ism. That worked perfect. Now back to my agro question. I know exactly how this works and I have an idea of what I need to do but I just want to make sure this right. First thing I need is for spells to have an agro amount. Thats simple just set a variable. Next thing I need to do is have spells triger a radius depending on how threatening they are. Thats simple I just set a variable for the radius and have it check distance to objects and set their agro higher (this will slow the game down I fear so I'm looking for a better Idea) Next I need to have the mobs check to see which players are causing the most agro, so It has to save each players agro and check it. The agro also has to detereorate after a while. Now this is where I don't really know what to do. I already have a variable for who casts the spell but how am I going to save the player who cast the spells agro inside the mob and then add to it everytime it casts a threatening spell? Then the last part having it attack the target with the highest agro will not be hard. All i have to do is check for which agro is the highest and have it attack that target. So can anyone tell me how I would script this efficently? Thank you. Personally I think that unless the abilities of the party are well known to most of the inhabitants you should have the attacks used on them determine the agro. Nothing is more frustrating than fighting enemies who have knowledge and abilities that you don't. For example, I'm currently playing Dragon Warrior 3 (I know it's an old game, but I wanted to play it when it came out, never could find it, and now I finally have a chance to play it), and you enter all of your commands at the beginning of each turn. If you're fighting an infernous crab and two flamepedes the crab will attack your pilgrim because it knows that s/he has sap, which will make it vulnerable, and the flamepedes will attack your wizard because s/he has an ice based spell while the others have fire, which does nothing to them. So there you have two types of fairly strong monster attacking the two weakest party members while your hero and warrior can't do anything other than hope that the pilgrim and wizard can hold out until the battle's over. It detracts from the overall realism (most wild animals wouldn't single out a person, they would just attack whoever they could get to) and it's highly unfair to the player. A much more realistic alternative would be if the enemy were to get the first attack to choose the target at random, and then after the player's first attack go after whoever caused the most damage in that turn (assuming it's turn based), or just wait until the player casts a specific spell and then have the enemy agro, since then it would know that the player has that spell instead of a world full of psychic animals.
|
|
|
Post by shad0w on Jan 24, 2005 2:08:50 GMT -5
Going back the inventories talk- i do it the way mega described because i find it easier, and plus it looks nicer in my opinion aswell.
I know what dwmitch means by the unfairness, but it does make the game more fun and challenging, if the computer doesn't just try and attack at random- especially later on in the game when you know the rules back to front, and they are still using the toss the coin method.
|
|
|
Post by yahn12 on Apr 11, 2005 13:23:13 GMT -5
ok I know this has been dead for a long time (thats because I gave up on my mmorpg).. but now i'm starting a much eaiser single player RPG. I'm still puzzeled on the mob AI. I have 2 arrays for this. One that stores the ids of the charecters that attack it, and one that stores the amount of hate that it caused it. First when you attack i have for(i=0;i<10,i+=1). then I have if target.agroid=0 target.agroid=id. then to add onto the hate when the spell hits i have. target.agroamount+=effect*threat. I have a lot of problems here. One it sets everything to its Id and not just the first 0, 2 it doesn't add anything to the agroamount. It leaves agroamount at 0 and sets all agroid to its id.
And i'm a little rusty on my scripting since i havn't done any in almost a month. I know you use a for loop, but how do you check for the highest and lowest amounts of an array?
PS your suggestions for the inventory worked great.
|
|
|
Post by IsmAvatar on Apr 11, 2005 13:54:01 GMT -5
i started using datasctructures instead of arrays. They are much more powerful, and faster.
But, keeping to the array idea, here's how the loop would look:
for (m = 0; m < 10; m += 1) { if target.agroid=0 { target.agroid=id i = 10 //this is so it breaks out of the loop } }
|
|
|
Post by yahn12 on Apr 11, 2005 14:41:38 GMT -5
that sets i=10 though ?? i need to use the i its using so that i can set the second array too. and if you know of a way thats better with datastructures i'm interested in that. TY.
|
|
|
Post by IsmAvatar on Apr 11, 2005 17:41:42 GMT -5
pos = 10 for (i = 0; i < 10; i += 1) { if target.agroid[i]=0 { target.agroid[i]=id pos = i i = 10 //this is so it breaks out of the loop } }
pos stores the last index.
|
|