Help with a simple script
MorganZ
Member Posts: 17
Hello, i'm totally new to scripting and i'm basically starting by reading someone else scripts and trying to change em and merge them to see what happens (usually bad things!)
//
// CONSTANTS
//
const string HC_RES_SKINNING_MEAT = "it_mmidmisc006";
const string HC_RES_SKINNING_MEAT2 = "it_mmidmisc007";
//
// FUNCTIONS
//
void HC_ActionButcherAnimal()
{
object oPC = OBJECT_SELF;
FloatingTextStringOnCreature("*" + GetName(oPC) + SKINNING, oPC);
CreateObject(OBJECT_TYPE_ITEM, HC_RES_SKINNING_MEAT, GetLocation(oPC));
}
This is a script which fires when a PC use an item (skinning knife) on an animal corpse. HC_RES_SKINNING_MEAT = "it_mmidmisc006" is the item he obtain from that action. I would like the PC to obtain additional items based on the creature name (or tag, or resref). Something like IF the creature is X then drop also Y. The bold part hes been added by me..
hope you can help me!
//
// CONSTANTS
//
const string HC_RES_SKINNING_MEAT = "it_mmidmisc006";
const string HC_RES_SKINNING_MEAT2 = "it_mmidmisc007";
//
// FUNCTIONS
//
void HC_ActionButcherAnimal()
{
object oPC = OBJECT_SELF;
FloatingTextStringOnCreature("*" + GetName(oPC) + SKINNING, oPC);
CreateObject(OBJECT_TYPE_ITEM, HC_RES_SKINNING_MEAT, GetLocation(oPC));
}
This is a script which fires when a PC use an item (skinning knife) on an animal corpse. HC_RES_SKINNING_MEAT = "it_mmidmisc006" is the item he obtain from that action. I would like the PC to obtain additional items based on the creature name (or tag, or resref). Something like IF the creature is X then drop also Y. The bold part hes been added by me..
hope you can help me!
0
Comments
This should give you a start. Feel free to plaster me with questions.
void HC_ActionButcherAnimal()
{
object oPC = OBJECT_SELF;
FloatingTextStringOnCreature("*" + GetName(oPC) + SKINNING, oPC);
CreateObject(OBJECT_TYPE_ITEM, HC_RES_SKINNING_MEAT, GetLocation(oPC));
if(GetTag(oTarget) == "TagNameHere")
{
CreateObject(OBJECT_TYPE_ITEM, HC_RES_SKINNING_MEAT2, GetLocation(oPC));
}
Would this little adjustment make it work as i imagine it should?
Another way to go about it would be use variables. This would be pretty easy if you're using all custom versions of animals that can be skinned.
In the Advanced tab on the creatures properties, there is a button near the bottom where you can define them. Then in your script you can check for them using GetLocalInt() and the like.
If not, then yes. You would have to make an exception for each animal that should drop something else too.
Edit: I did a simple test and leaves lootable corpse does have the same tag as the creature.
In your original post, 'SKINNING' is undefined. Would that be part of it?
skinning is part of "hc_text_activate" and is just a text string that will float, inside hc_text_activate the author placed every text spoken by his script to help others with translation or if someone wants to change the phrase, smart i'd say! It contains lot of strings like this one: string SKINNING= " Skins Animal*";
I think (from reading "hc_inc_npccorpse") that this script is not using the standard nwn cropses but is creating his own corspes thru "hc_inc_npccorpse". I've tryed to run the script with animal creatues with "leave lootable corpse" unchecked and those still generate a corpse!
Totally doable though. In this scrips I can see At this point, both those objects have been created and stored. All you have to do is find where SetLocalObject(<oPC>, HC_VAR_NPCCORPSE_BODY, <someObject>); is called. You can SetLocalInt on the line before it... it's still weird. Why is the object being stored on oPC at all? I think I would need a look at hc_inc_npccorpse to understand that.
On my favorite server (Lala Land [Gone now]), they had a similar skinning system. Animals would leave lootable corpses. If you had a skinning knife equipped, it would play an animation and give you a pelt or whatever depending on what animal it was. After so many times, your skinning knife would get destroyed from being used up. This system you've got here seems like it's maybe trying to be like that, but I'm not seeing any advantages so far.
I've bolded the part where it sets corpse obody and another one about skinning (i guess that second one is just about decaying time of the corpse but i'm not that sure). I think this sistem works pretty similar to the one you described! I'm not sure what should i do when i set local int before SetLocalObject(<oPC>, HC_VAR_NPCCORPSE_BODY. I mean after that how do I change or modify the item dropped by the action "skinning"?
So really I think the change is in the first script you shared, but seeing that big one helped me decide what's going on. (I still wonder where it calls SetLocalObject(oPc, "Other", corpse))
Anyway, here's the script modified to take a string. You can use that as a start.