Frictional Games Forum (read-only)

Full Version: "Puzzle"
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
For the GiveItem function:

GiveItem(string& asName, string& asType, string& asSubTypeName, string& asImageName, float afAmount);

asName - internal name
asType - item to give
asSubTypeName - item name for .lang file
asImageName - image.tga

I'm a bit confused about the difference between asName and asType. I'm thinking asName is the name of the item to give, but then what's asType? In FG's "Inventory.hps" folder I noticed that for asType under all the GiveItem functions they put "Puzzle."

[Image: scaled.php?server=405&filename=puzzleuo.png&res=landing]

So what does that do?
I'm not sure about your specific question, but if you wish to use that type of function, use GiveItemFromFile:

GiveItemFromFile(string& asName, string& asFileName);


asName = the name you want to give that item
asFileName the entity (.ent) file name
Wiki says that function is used almost exclusively for debugging only.
I would argue the second argument relates to the subtype for items.
Note: This may be inaccurate, as I am relatively new to coding AngelScript and coding in general, but this seems to work fine for what I do.

I usually just use the same for asName and asType. For instance, take a look at a script I'm making for my upcoming story Rising Water. I've bolded the parts that are important.

void OnStart()
{
SetEntityPlayerInteractCallback("stone_hammer_1", "TorchScare", true);
AddUseItemCallback("chemical_container_1", "chemical_container_1", "acid_container_1", "FillJarWithAcid", false);
}

void TorchScare(string &in item)
{
SetLampLit("torch_static01_1", false, true);
GiveSanityDamage(10, true);
PlaySoundAtEntity("react_scare", "react_scare", "Player", 0, false);
PlaySoundAtEntity("enemy_hallucination_disappear", "enemy_hallucination_disappear", "torch_static01_1", 0, false);
}

void FillJarWithAcid(string &in item, string &in entity)
{
GiveSanityBoostSmall();
RemoveItem("chemical_container_1");
GiveItem("chemical_container_full", "chemical_container_full", "AcidPot", "chemical_container_full.tga", 1);
PlaySoundAtEntity("ui_use_oil", "ui_use_oil", "Player", 0, false);
}


void OnEnter()
{
StopMusic(0, 0);
StopMusic(1, 0);
PlayMusic("23_amb02", true, 1, 6, 0, false);
}

void OnLeave()
{

}

For the GiveItem command, I used "chemical_container_1" for both the type and name. When I use the chemical pot on the acid container, it fills with acid with a sound playing, and gives sanity. In fact, I just use the same for type and name for pretty much any command, like the torch scare, where I use the same text input for the PlaySoundAtEntity which plays "enemy_hallucination_disappear" and extinguishes a torch when I pick up a hammer. I also used "react_scare" for the gasp afterward.

Basically speaking, the input I use for type and name are usually identical, and the script functions correctly. I hope this helps you, Chronofox.

EDIT: In case you still don't get it, I'll use a PlaySoundAtEntity example.

PlaySoundAtEntity("react_pant", "react_pant", "Player", 0, false);

I used the same thing for type and name. The first strings of the command are type and name. I used "react_pant" for both the type and name. Type and name are the same thing. They still function correctly.
@Zaffre, i would argue that if the type doesn't match an internal type, it would default to Puzzle.