Forums
Games
Cyberpunk 2077 Thronebreaker: The Witcher Tales GWENT®: The Witcher Card Game The Witcher 3: Wild Hunt The Witcher 2: Assassins of Kings The Witcher The Witcher Adventure Game
Jobs Store Support Log in Register
Forums - CD PROJEKT RED
Menu
Forums - CD PROJEKT RED
  • Hot Topics
  • NEWS
  • GENERAL
    THE WITCHER ADVENTURE GAME
  • STORY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 THE WITCHER TALES
  • GAMEPLAY
    THE WITCHER THE WITCHER 2 THE WITCHER 3 MODS (THE WITCHER) MODS (THE WITCHER 2) MODS (THE WITCHER 3)
  • TECHNICAL
    THE WITCHER THE WITCHER 2 (PC) THE WITCHER 2 (XBOX) THE WITCHER 3 (PC) THE WITCHER 3 (PLAYSTATION) THE WITCHER 3 (XBOX) THE WITCHER 3 (SWITCH)
  • COMMUNITY
    FAN ART (THE WITCHER UNIVERSE) FAN ART (CYBERPUNK UNIVERSE) OTHER GAMES
  • RED Tracker
    The Witcher Series Cyberpunk GWENT
THE WITCHER
THE WITCHER 2
THE WITCHER 3
MODS (THE WITCHER)
MODS (THE WITCHER 2)
MODS (THE WITCHER 3)
Menu

Register

Giving and taking items

+
N

nayava

Senior user
#1
Aug 15, 2008
Giving and taking items

I want to take an item from the player and give him an other. Fortunately is this part of a quest so I thought I could use the on phase finished actions transfer item to player and npc. But it does not work. So I tried this script. But it does not work too although there is no error message. Could someone tell me what I did wrong?
Code:
void main(){	object oPC = GetFirstPC();	object oItemA = GetObjectByTag("i46");	object oItemB = GetObjectByTag("i43");		ActionTakeItem(oItemA, oPC);	ActionGiveItem(oItemB, oPC);}
 
A

ailinon

Senior user
#2
Aug 15, 2008
Giving and taking are actions performed by an NPC, to be used like this -
Code:
object oNPC = GetObjectByTag("npc_somebody");object oPC = GetFirstPC();object oItem = GetObjectByTag("some_item");AssignCommand(oNPC,ActionGiveItem(oItem,oPC));
To simply add an item to the player's inventory,
Code:
object oPC = GetFirstPC();CreateItemOnObject("item_template",oPC);
Or, if you already have the object,
Code:
object oPC = GetFirstPC();object oItem = GetObjectByTag("some_item");object oNewItem = CopyItem(oItem,oPC);DestroyObject(oItem);
All of this is 'dry' code, though - please test it thoroughly.
 
N

nayava

Senior user
#3
Aug 15, 2008
Thanks, it works now. But why I get with CreateItemOnObject("item_template",oPC); the same item twice?
 
A

ailinon

Senior user
#4
Aug 15, 2008
Well, it creates an item basing on a template - multiple creations result in multiple items. Or, do you get the item twice even if you have only one CreateItemOnObject action..? o_O
 
N

nayava

Senior user
#5
Aug 15, 2008
Oh, I put the action script inadvertent in the standard greeting line which is said before and after the quest conversation lines. Thanks.
 
Share:
Facebook Twitter Reddit Pinterest Tumblr WhatsApp Email Link
  • English
    English Polski (Polish) Deutsch (German) Русский (Russian) Français (French) Português brasileiro (Brazilian Portuguese) Italiano (Italian) 日本語 (Japanese) Español (Spanish)

STAY CONNECTED

Facebook Twitter YouTube
CDProjekt RED Mature 17+
  • Contact administration
  • User agreement
  • Privacy policy
  • Cookie policy
  • Press Center
© 2018 CD PROJEKT S.A. ALL RIGHTS RESERVED

The Witcher® is a trademark of CD PROJEKT S. A. The Witcher game © CD PROJEKT S. A. All rights reserved. The Witcher game is based on the prose of Andrzej Sapkowski. All other copyrights and trademarks are the property of their respective owners.

Forum software by XenForo® © 2010-2020 XenForo Ltd.