Aller au contenu

Photo

[Help/Question] How to create a lootable placeable (not container)


  • Veuillez vous connecter pour répondre
13 réponses à ce sujet

#1
NewYears1978

NewYears1978
  • Members
  • 894 messages
Such as the elfroot and such in the game.  Or a pile of gold that gives you gold when you click it then vanishes.

I've search but I have no clue where to begin.

#2
Guest_etfeet_*

Guest_etfeet_*
  • Guests
genip_herb_07 is the peaceable that is used in the campaign

#3
Sarcen

Sarcen
  • Members
  • 38 messages
Replacing the placeables script with a script like this here will move all of the placeables inventory to the player and then destroy itself.



(Note: i didnt test this, but i would assume it works.)



void main()

{

event ev = GetCurrentEvent();

int nEventType = GetEventType(ev);



switch (nEventType)

{

case EVENT_TYPE_USE:

{

MoveAllItems(OBJECT_SELF, GetHero());

Safe_Destroy_Object(OBJECT_SELF);

}

}

}

#4
NewYears1978

NewYears1978
  • Members
  • 894 messages
perfect Sarcenn, I will try that! I had manage to make an item give things to the player..but not destroy itself.
Trying now, appreciate it :)

Worked perfect, thanks :)

#include "wrappers_h"
void main()
{
event ev = GetCurrentEvent();
int nEventType = GetEventType(ev);
    switch (nEventType)
    {
        case EVENT_TYPE_USE:
        {
        //MoveAllItems(OBJECT_SELF, GetHero());
        AddCreatureMoney (1000000, GetHero(), TRUE);
        Safe_Destroy_Object(OBJECT_SELF);
        }
    }
}


Modifié par NewYears1978, 21 novembre 2009 - 04:08 .


#5
Quildra

Quildra
  • Members
  • 45 messages
I'd suggest you use SetObjectInteractive instead of destroy.

#6
NewYears1978

NewYears1978
  • Members
  • 894 messages

Quildra wrote...

I'd suggest you use SetObjectInteractive instead of destroy.


This only changes whether the item is usable though..I want the item to disappear..just like loot piles that are money or elfroots/deathroots...

Why did you suggest this?  So I can learn the reasoning and your thoughts. Thanks!

#7
Quildra

Quildra
  • Members
  • 45 messages
Elfroots etc don't disappear on my install. I assumed you wanted to replicate the same effect as in game so I suggested that function as that is what happens when I loot an item. there is also SetObjectActive, which despawns the item and returns it to its relevant pool if one was created.




#8
NewYears1978

NewYears1978
  • Members
  • 894 messages
Oh well I was thinking they did disappear...which is the effect I wanted (I guess loot left from enemies that is gold would have been a better example..)



Is there a reason not to use the destroy feature? As it seems to work fine and do what I intended? Just like to learn the proper methods :)

#9
Axe_Murderer

Axe_Murderer
  • Members
  • 279 messages
Well it depends what you want. Destroy gets rid of it so if you want it back later you have to recreate it. SetObjectActive, I believe, only hides it so if you want to reuse it later you don't have to recreate, you just reactivate it and it appears again (naturally you'd also have to restock it again). In your case it probably makes more sense to destroy a loot bag dropped by an enemy since those are probably created on death and never reused.


#10
NewYears1978

NewYears1978
  • Members
  • 894 messages
Yep, that is the case, I won't need to reuse it. Works perfectly thanks again.

#11
Craig Graff

Craig Graff
  • Members
  • 608 messages
If you wanted to use standard ressources you could achieve the same thing (though not destroying the placeable) simply by adding "_autoloot" to the end of the placeable's tag.

Modifié par Craig Graff, 22 novembre 2009 - 04:18 .


#12
hwlreckles

hwlreckles
  • Members
  • 44 messages

Craig Graff wrote...

If you wanted to use standard ressources you could achieve the same thing (though not destroying the placeable) simply by adding "_autoloot" to the end of the placeable's tag.



Pro tip!  Will remember that one.

#13
AND04

AND04
  • Members
  • 154 messages

Craig Graff wrote...

If you wanted to use standard ressources you could achieve the same thing (though not destroying the placeable) simply by adding "_autoloot" to the end of the placeable's tag.


idd, simplified and complicated some stuff for my Auto Loot Mod - changing the tag and then reverting it etc... + some scripts check the tag and so on... + that "trick" only works on containers that aren't BodyBags, etc...

#14
NewYears1978

NewYears1978
  • Members
  • 894 messages

Craig Graff wrote...

If you wanted to use standard ressources you could achieve the same thing (though not destroying the placeable) simply by adding "_autoloot" to the end of the placeable's tag.


Great tip, thanks!