Dropping Objects

Omega
23 Jan 2014, 20:40Ok so now i have this problem where I need monsters to drop objects when they are dead.
Now I was able to make one monster die and get it to drop its item. BUT
If i put another monster of same name type (goblin) and have the same item (rupee) it wont drop it because it's a different name. (rupee1).
This is part of my code that has the outcome if monster dies it drops rupee. How do i make the second goblin drop its rupee in the other room?
thanks.
MoveObject (Rupee, west pass3)
Now I was able to make one monster die and get it to drop its item. BUT
If i put another monster of same name type (goblin) and have the same item (rupee) it wont drop it because it's a different name. (rupee1).
This is part of my code that has the outcome if monster dies it drops rupee. How do i make the second goblin drop its rupee in the other room?
msg ("The monster dies in a puff of smoke.")
monster.dead = true
Rupee.drop = true
if (Rupee.drop = true) {
msg ("Monster dropped a rupee.")
thanks.
MoveObject (Rupee, west pass3)
george
23 Jan 2014, 21:15Try giving all your rupees the alias of 'rupee'. Then they can have unique names but you can use 'rupee' alias in code.
http://quest5.net/wiki/Alias
http://quest5.net/wiki/Alias
HegemonKhan
23 Jan 2014, 22:02these questions of yours deals with code design and game design... and there's a lot of things that can be done, and simple vs complex, of those things.
there's many structures or methods, the below is just a few examples, of concepts, structures, or methods of doing only a few (of many more) various things.
---------------
you don't want to be moving around 255 "rupee" Objects...
rather you should use attribute alteration (transactions):
(no "rupee" Object at all is used; no "rupee" object ever made~exists)
if (Goblin.dead=true) {
-> firsttime {
->-> player.rupees = player.rupees + Goblin.rupees
-> }
}
~OR~
if (Goblin.dead=true) {
-> player.rupees = player.rupees + Goblin.rupees
-> Goblin.rupees = 0
}
so for example:
<object name="player">
-> <inherit name="editor_object" />
-> <inherit name="editor_player" />
-> <attr name="rupees" type="int">0</attr>
</object>
<object name="Goblin_1">
-> <inherit name="editor_object" />
-> <alias>goblin</alias>
-> <attr name="dead" type="boolean">false</attr>
-> <attr name="rupees" type="int">50</attr>
</object>
"fight~attack" Scripting (ie a Verb of "Goblin_1" Object):
if (Goblin.dead=true) {
-> if (Goblin.rupees > 0) {
->-> player.rupees = player.rupees + Goblin.rupees
->-> Goblin.rupees = 0
->-> msg ("You loot the Goblin's corpse.")
-> } else if (Goblin.rupees <= 0) {
->-> msg ("You've already looted the Goblin's corpse.")
-> }
} else if (Goblin.dead=false) {
-> // the rest (the actual "fighting~attacking~damaging~dodging~blocking~etc" scripts) of your fight~attack scripting
}
~OR~
"fight~attack" Scripting (ie a Verb of "Goblin_1" Object):
if (Goblin.dead=true) {
-> firsttime {
->-> player.rupees = player.rupees + Goblin.rupees
-> } otherwise {
->-> msg ("You've already looted the Goblin's corpse.")
-> }
} else if (Goblin.dead=false) {
-> // the rest (the actual "fighting~attacking~damaging~dodging~blocking~etc" scripts) of your fight~attack scripting
}
result: the player now has a "50" (0+50) Value for their "rupees" Integer Attribute
----------------
however, with equipment (unlike currency), you really need to use an Object... so what to do about it to reduce clutter and quantity?
Sora's Stackable Library and~or also a "Storage System" (I made a very simple and messy one, though it only involves spells).
look, do you really want to see this in your player's inventory:
red rupee Object (Zelda value: 20 green rupees)
blue rupee Object (Zelda value: 5 green rupees)
green rupee Object (Zelda value: 1)
red rupee Object
red rupee Object
green rupee Object
red potion Object
blue potion Object
arrow Object
silver arrow Object
silver arrow Object
red potion Object
.
.
.
.
or would you rather have this:
red rupee (5)
blue rupee (30)
green rupee (99)
red potion (48)
blue potion (76)
arrows (20)
silver arrows (40)
this is what sora's stackable library does
or even further Sora's and a "storage system":
player's inventory:
storage Object
Storage Object:
potion storage
arrow storage
rupee storage
Potion storage:
red potion (10)
blue potion (5)
etc...
so it'd be structured like this:
player inventory
-> storage object
->-> potion storage object
->->-> red potion (5) object
->->-> blue potion (10) object
->-> rupee storage object
->->-> green rupee (99) object
->->-> red rupee (79) object
->->-> blue rupee (39) object
->-> arrow storage object
->->-> wooden arrow (99) object
->->-> silver arrow (50) object
->-> weapon storage object
->->-> wooden sword object
->->-> wooden boomerang object
->->-> magic sword object
->->-> magical boomerang object
->->-> wooden bow object
->->-> silver bow object
->-> armor storage object
->->-> small shield object
->->-> big shield object
->->-> mirror shield object
->->-> green clothes object
->->-> blue clothes object
->->-> red clothes object
you'd only see the "storage object" in your inventory, and open clicking on it (like opening a book), you then see (potion storage, weapon storage, arrow storage, rupee storage), and then clicking on one of those (ie potion storage), you see (ie green potion, red potion, blue potion)
you've got a single "storage book" cluttering up your player's inventory only. But, when you click on it, it opens up to show the "potion storage book", "rupee storage book", and etc. then upon clicking on one of those... do you get the idea now?
-------------
though, again, you shouldn't be using objects for your currency (reduces clutter and quantity of objects), just use attributes instead. but for equipment, you really have to use objects (and their clones ~ cloning objects), but you can limit them via using sora's stackable library.
-------------
also, if you don't want to make an individual scripting for every monster... we'll need to help you to code this in, as it's a bit more advanced.
and, if you want to keep using currency ("rupees") as objects, not as an attribute, then you'll need this more advanced coding, anyways too.
there's many structures or methods, the below is just a few examples, of concepts, structures, or methods of doing only a few (of many more) various things.
---------------
you don't want to be moving around 255 "rupee" Objects...
rather you should use attribute alteration (transactions):
(no "rupee" Object at all is used; no "rupee" object ever made~exists)
if (Goblin.dead=true) {
-> firsttime {
->-> player.rupees = player.rupees + Goblin.rupees
-> }
}
~OR~
if (Goblin.dead=true) {
-> player.rupees = player.rupees + Goblin.rupees
-> Goblin.rupees = 0
}
so for example:
<object name="player">
-> <inherit name="editor_object" />
-> <inherit name="editor_player" />
-> <attr name="rupees" type="int">0</attr>
</object>
<object name="Goblin_1">
-> <inherit name="editor_object" />
-> <alias>goblin</alias>
-> <attr name="dead" type="boolean">false</attr>
-> <attr name="rupees" type="int">50</attr>
</object>
"fight~attack" Scripting (ie a Verb of "Goblin_1" Object):
if (Goblin.dead=true) {
-> if (Goblin.rupees > 0) {
->-> player.rupees = player.rupees + Goblin.rupees
->-> Goblin.rupees = 0
->-> msg ("You loot the Goblin's corpse.")
-> } else if (Goblin.rupees <= 0) {
->-> msg ("You've already looted the Goblin's corpse.")
-> }
} else if (Goblin.dead=false) {
-> // the rest (the actual "fighting~attacking~damaging~dodging~blocking~etc" scripts) of your fight~attack scripting
}
~OR~
"fight~attack" Scripting (ie a Verb of "Goblin_1" Object):
if (Goblin.dead=true) {
-> firsttime {
->-> player.rupees = player.rupees + Goblin.rupees
-> } otherwise {
->-> msg ("You've already looted the Goblin's corpse.")
-> }
} else if (Goblin.dead=false) {
-> // the rest (the actual "fighting~attacking~damaging~dodging~blocking~etc" scripts) of your fight~attack scripting
}
result: the player now has a "50" (0+50) Value for their "rupees" Integer Attribute
----------------
however, with equipment (unlike currency), you really need to use an Object... so what to do about it to reduce clutter and quantity?
Sora's Stackable Library and~or also a "Storage System" (I made a very simple and messy one, though it only involves spells).
look, do you really want to see this in your player's inventory:
red rupee Object (Zelda value: 20 green rupees)
blue rupee Object (Zelda value: 5 green rupees)
green rupee Object (Zelda value: 1)
red rupee Object
red rupee Object
green rupee Object
red potion Object
blue potion Object
arrow Object
silver arrow Object
silver arrow Object
red potion Object
.
.
.
.
or would you rather have this:
red rupee (5)
blue rupee (30)
green rupee (99)
red potion (48)
blue potion (76)
arrows (20)
silver arrows (40)
this is what sora's stackable library does
or even further Sora's and a "storage system":
player's inventory:
storage Object
Storage Object:
potion storage
arrow storage
rupee storage
Potion storage:
red potion (10)
blue potion (5)
etc...
so it'd be structured like this:
player inventory
-> storage object
->-> potion storage object
->->-> red potion (5) object
->->-> blue potion (10) object
->-> rupee storage object
->->-> green rupee (99) object
->->-> red rupee (79) object
->->-> blue rupee (39) object
->-> arrow storage object
->->-> wooden arrow (99) object
->->-> silver arrow (50) object
->-> weapon storage object
->->-> wooden sword object
->->-> wooden boomerang object
->->-> magic sword object
->->-> magical boomerang object
->->-> wooden bow object
->->-> silver bow object
->-> armor storage object
->->-> small shield object
->->-> big shield object
->->-> mirror shield object
->->-> green clothes object
->->-> blue clothes object
->->-> red clothes object
you'd only see the "storage object" in your inventory, and open clicking on it (like opening a book), you then see (potion storage, weapon storage, arrow storage, rupee storage), and then clicking on one of those (ie potion storage), you see (ie green potion, red potion, blue potion)
you've got a single "storage book" cluttering up your player's inventory only. But, when you click on it, it opens up to show the "potion storage book", "rupee storage book", and etc. then upon clicking on one of those... do you get the idea now?
-------------
though, again, you shouldn't be using objects for your currency (reduces clutter and quantity of objects), just use attributes instead. but for equipment, you really have to use objects (and their clones ~ cloning objects), but you can limit them via using sora's stackable library.
-------------
also, if you don't want to make an individual scripting for every monster... we'll need to help you to code this in, as it's a bit more advanced.
and, if you want to keep using currency ("rupees") as objects, not as an attribute, then you'll need this more advanced coding, anyways too.

Pertex
24 Jan 2014, 10:49Perhaps it is better to create new objects, something like this:
msg ("The monster dies in a puff of smoke.")
monster.dead = true
reward=GetUniqueElementName("rupees")
create(reward)
obj=GetObject(reward)
obj.alias="Rupee"
MoveObject (obj, west pass3)

Omega
02 Jul 2014, 18:05wow that's really simple but useful. thanks man.