Jump to content


Photo

Equiping items


  • Please log in to reply
14 replies to this topic

#1 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 09 June 2012 - 10:57 AM

Hey, so I've created an inventory menu that appears when you press "X" it draws in text everything in your inventory.

Each item has a randomly generated name + randomly generated stats. I just have no idea how to equip these items.

The stats they have are

atk_raise
def_raise
spd_raise
luck_raise
health_raise
mana_raise
fatigue_raise

If you need more clarification, when you pick up an item it executes these 2 scripts


//Script 1
switch(choose(1,2,3))
{
case 1: {atk_raise = 1; break;}
case 2: {atk_raise = 2; break;}
case 3: {atk_raise = 3; break;}
}

switch(choose(1,2,3))
{
case 1: {def_raise = 1; break;}
case 2: {def_raise = 2; break;}
case 3: {def_raise = 3; break;}
}


switch(choose(1,2,3))
{
case 1: {luck_raise = 1; break;}
case 2: {luck_raise = 2; break;}
case 3: {luck_raise = 3; break;}
}


switch(choose(1,2,3))
{
case 1: {spd_raise = 1; break;}
case 2: {spd_raise = 2; break;}
case 3: {spd_raise = 3; break;}
}


switch(choose(1,2,3))
{
case 1: {health_raise = 5; break;}
case 2: {health_raise = 10; break;}
case 3: {health_raise = 15; break;}
}

switch(choose(1,2,3))
{
case 1: {mana_raise = 5; break;}
case 2: {mana_raise = 10; break;}
case 3: {mana_raise = 15; break;}
}


switch(choose(1,2,3))
{
case 1: {fatigue_raise = 5; break;}
case 2: {fatigue_raise = 10; break;}
case 3: {fatigue_raise = 15; break;}
}

//Script 2
name1 = choose("Staff", "Wand", "Mace");
name2 = choose("of the")
name3 = choose("Bear","Wolf", "Lion", "Shamans", "Kings", "Theives");
name4 = choose("Damaged" , "Broken" , "Perfect");

name = name4 + " " + name1 + " " + name2 + " " + name3;

Than the Items menu draws what's = to the name.
  • 0

#2 Blake

Blake

    GMC Member

  • GMC Member
  • 443 posts
  • Version:GM:Studio

Posted 09 June 2012 - 11:50 AM

What exactly do you want from us? You haven't specified what you need help with.
  • 0

#3 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 09 June 2012 - 12:11 PM

What exactly do you want from us? You haven't specified what you need help with.


Equiping / Unequiping items.
  • 0

#4 CrazyGuyGames

CrazyGuyGames

    YYGF Member

  • GMC Member
  • 194 posts
  • Version:GM8.1

Posted 09 June 2012 - 12:34 PM

Thats too plain -.-.

Well try
global.equipment=0

and in the draw event

if global.equipment=1
draw_sprite(wathever, make sure to adapt the sprite to your player)
if global.equipment="
draw_sprite(PD: this codes go in the player make sure to draw him too)
  • 0

#5 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 09 June 2012 - 12:52 PM

Thats too plain -.-.

Well try
global.equipment=0

and in the draw event

if global.equipment=1
draw_sprite(wathever, make sure to adapt the sprite to your player)
if global.equipment="
draw_sprite(PD: this codes go in the player make sure to draw him too)


Sorry for the plain reply lol. Let me clarify more.


1)When I click where the text is, that becomes equipped and the players stats raise accordingly. And I can unequip which removes the stats. The problem is that if I have the items page create buttons, when I move the screen the buttons don't follow as quickly as text and it looks off. I think I might just use an inventory example if this proves too difficult.
  • 0

#6 CrazyGuyGames

CrazyGuyGames

    YYGF Member

  • GMC Member
  • 194 posts
  • Version:GM8.1

Posted 09 June 2012 - 01:15 PM

Add in the draw code of your butons
draw_sprite(sprite_index,image_index,x,y)
  • 0

#7 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 09 June 2012 - 04:59 PM

Add in the draw code of your butons
draw_sprite(sprite_index,image_index,x,y)


But how do I actually equip it and unequip it, was my question. Drawing the sprites is easy.

Also, do I use coordinates to see which equip button they press?
  • 0

#8 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 11 June 2012 - 12:32 AM

bump

Edited by aaabbbccc, 11 June 2012 - 12:32 AM.

  • 0

#9 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5401 posts
  • Version:GM:Studio

Posted 11 June 2012 - 01:01 AM

well, move it to the equipment slot (or tag it as equipped using a variable) and apply the stats, when unequiped, take away the stats and put it back in the inventory

1)When I click where the text is, that becomes equipped and the players stats raise accordingly. And I can unequip which removes the stats. The problem is that if I have the items page create buttons, when I move the screen the buttons don't follow as quickly as text and it looks off. I think I might just use an inventory example if this proves too difficult.

this gives the imperssion that you already got the main question solved, but the problem is that the inventory objects can't keep up with the view moving, the view cordinates are changed just before the draw event, so you might want to draw them where they should be in the view, instead of having them follow it..

Also, do I use coordinates to see which equip button they press?

are they drawn, then I guess you have to do that or use some math .. (top left corner - mouse cordinate) / slot size = row and column .. if objects then you also got the click events.. but we have no information on them
  • 0

#10 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 11 June 2012 - 01:59 PM

well, move it to the equipment slot (or tag it as equipped using a variable) and apply the stats, when unequiped, take away the stats and put it back in the inventory


Yes, this is what I need help with.

1)When I click where the text is, that becomes equipped and the players stats raise accordingly. And I can unequip which removes the stats. The problem is that if I have the items page create buttons, when I move the screen the buttons don't follow as quickly as text and it looks off. I think I might just use an inventory example if this proves too difficult.

this gives the imperssion that you already got the main question solved, but the problem is that the inventory objects can't keep up with the view moving, the view cordinates are changed just before the draw event, so you might want to draw them where they should be in the view, instead of having them follow it..


Everything keeps up with it now because the inventory deactivates everything. So that's solved.

Also, do I use coordinates to see which equip button they press? are they drawn, then I guess you have to do that or use some math .. (top left corner - mouse cordinate) / slot size = row and column .. if objects then you also got the click events.. but we have no information on them


yes they are drawn. That's why I'm unsure.
  • 0

#11 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5401 posts
  • Version:GM:Studio

Posted 11 June 2012 - 05:49 PM

Hey, so I've created an inventory menu that appears when you press "X" it draws in text everything in your inventory.

Each item has a randomly generated name + randomly generated stats. I just have no idea how to equip these items.

that the item get stats and that you draw your inventory when pressing X does not tell us mutch about how your inventory works at all..

well, move it to the equipment slot (or tag it as equipped using a variable) and apply the stats, when unequiped, take away the stats and put it back in the inventory

Yes, this is what I need help with.

that was pretty mutch step by step how you do it .. and you kinda answered it yourself aswell:

When I click where the text is, that becomes equipped and the players stats raise accordingly. And I can unequip which removes the stats.


so here is a guess for a possible code which should do pretty mutch what you said (I do not know the name of your player object of the variables you want to increase):

create:
equiped = false;
// set all the other stats to 0 here

on click:
if !equiped {
  equiped = true;

  obj_player.atk += atk_raise;
  obj_player.def += def_raise;
  obj_player.spd+= spd_raise;
  obj_player.luck += luck_raise;
  obj_player.hp += health_raise;
  obj_player.max_hp += health_raise;
  obj_player.mp += mana_raise;
  obj_player.fat += fatigue_raise;
}else{
  equiped = false;

  obj_player.atk -= atk_raise;
  obj_player.def -= def_raise;
  obj_player.spd-= spd_raise;
  obj_player.luck -= luck_raise;
  obj_player.hp -= health_raise;
  obj_player.max_hp -= health_raise;
  obj_player.mp -= mana_raise;
  obj_player.fat -= fatigue_raise;
}
when pressed it set equiped to true, and add the stats .. click again to and it set it to false and removes the stats (and I'm aware that it could have been written with half the size)
  • 0

#12 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 12 June 2012 - 11:57 PM

Hey, so I've created an inventory menu that appears when you press "X" it draws in text everything in your inventory.

Each item has a randomly generated name + randomly generated stats. I just have no idea how to equip these items.

that the item get stats and that you draw your inventory when pressing X does not tell us mutch about how your inventory works at all..

well, move it to the equipment slot (or tag it as equipped using a variable) and apply the stats, when unequiped, take away the stats and put it back in the inventory

Yes, this is what I need help with.

that was pretty mutch step by step how you do it .. and you kinda answered it yourself aswell:

When I click where the text is, that becomes equipped and the players stats raise accordingly. And I can unequip which removes the stats.


so here is a guess for a possible code which should do pretty mutch what you said (I do not know the name of your player object of the variables you want to increase):

create:
equiped = false;
// set all the other stats to 0 here

on click:
if !equiped {
  equiped = true;

  obj_player.atk += atk_raise;
  obj_player.def += def_raise;
  obj_player.spd+= spd_raise;
  obj_player.luck += luck_raise;
  obj_player.hp += health_raise;
  obj_player.max_hp += health_raise;
  obj_player.mp += mana_raise;
  obj_player.fat += fatigue_raise;
}else{
  equiped = false;

  obj_player.atk -= atk_raise;
  obj_player.def -= def_raise;
  obj_player.spd-= spd_raise;
  obj_player.luck -= luck_raise;
  obj_player.hp -= health_raise;
  obj_player.max_hp -= health_raise;
  obj_player.mp -= mana_raise;
  obj_player.fat -= fatigue_raise;
}
when pressed it set equiped to true, and add the stats .. click again to and it set it to false and removes the stats (and I'm aware that it could have been written with half the size)


I honestly can't believe I didn't think of that haha. Thanks. And also, what way can you make it shorter?
  • 0

#13 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5401 posts
  • Version:GM:Studio

Posted 13 June 2012 - 02:23 AM

switching the variable to its opposite (true becomes false and opposite) .. then multiply the values with -1 or 1 based on if they should be added or not ..

(equiped - !equiped) works depending on the value is true or false
if true: (1-!1) = (1-0) = 1
if false: (0-!0) = (0-1) = -1
equiped = !equiped;

obj_player.atk += atk_raise * (equiped - !equiped);
obj_player.def += def_raise * (equiped - !equiped);
obj_player.spd += spd_raise * (equiped - !equiped);
obj_player.luck += luck_raise * (equiped - !equiped);
obj_player.hp += health_raise * (equiped - !equiped);
obj_player.max_hp += health_raise * (equiped - !equiped);
obj_player.mp += mana_raise * (equiped - !equiped);
obj_player.fat += fatigue_raise * (equiped - !equiped);
enjoy
  • 0

#14 aaabbbccc

aaabbbccc

    GMC Member

  • GMC Member
  • 525 posts

Posted 13 June 2012 - 06:53 PM

switching the variable to its opposite (true becomes false and opposite) .. then multiply the values with -1 or 1 based on if they should be added or not ..

(equiped - !equiped) works depending on the value is true or false
if true: (1-!1) = (1-0) = 1
if false: (0-!0) = (0-1) = -1

equiped = !equiped;

obj_player.atk += atk_raise * (equiped - !equiped);
obj_player.def += def_raise * (equiped - !equiped);
obj_player.spd += spd_raise * (equiped - !equiped);
obj_player.luck += luck_raise * (equiped - !equiped);
obj_player.hp += health_raise * (equiped - !equiped);
obj_player.max_hp += health_raise * (equiped - !equiped);
obj_player.mp += mana_raise * (equiped - !equiped);
obj_player.fat += fatigue_raise * (equiped - !equiped);
enjoy


I have another problem, I have no idea how to get the atk_raise stats. Because what happens is this

1) I pick up an item
2) The first available slot (say global.item_slot0) becomes = to the name
3) Than it randomly gets stats (like I said in my original post)

However, how do I draw these stats? I can't do global.item_slot0.atk_raise
  • 0

#15 FoxInABox

FoxInABox

    GMC Member

  • GMC Member
  • 5401 posts
  • Version:GM:Studio

Posted 13 June 2012 - 08:58 PM

2) The first available slot (say global.item_slot0) becomes = to the name

if this is a object inventory, then you would rather give it the id of the item object then the name .. that way you can do what you have written in 3
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users