NightprowlerAlpha Posted April 3, 2010 Share Posted April 3, 2010 Hi, I've started messing around with the Toolset today and, following a Tuto, I managed to make and add to the game a full set of equipment.Yet, there's one thing I'd like to add to it... I would like one of the parts of the armor to give a Talent (Feign Death to be accurate) while equipped.I tinkered around a bit, and figured it takes a Script (inside of the .uti file, the line after Plot Item), I've tried looking in the built-in scripts, but couldn't see one doing that, and since I don't know C++ at all, I must admit I'm clueless so far.Could anyone be nice enough give me an example of the Script it would take, or point me out to a place I could read about that please ? I digged a bunch of forums (Nexus, Beyond F, Bioware Social...) without finding anything to that effect. As for the mod I'm planning, I'm making 4 different sets matching my party needs : 1) Ranger/Bard 2) Assassin/Duellist, 3) Champion/Reaver 4) Spirit Healer/Blood Mage.I'm trying to make them strong enough to be worth making, but balanced enough to avoid the "Cheat/God items" section when I'll upload :) The stats and so on should be ready rather quick, yet I ain't quite close to be done, as I still have to learn about skins and as you could see earlier, scripts, but hey... can't have your cake and eat it too, huh ?! :) Thanks in advance for the help **EDIT** Might have a hint here, found a "addtalent.nss" in the Debug, it's supposed to be used to give a talent to a creature, but it might be of some help, I'll dig that out while waiting for someone who knows how to proceed to pop up :) Link to comment Share on other sites More sharing options...
hdhd Posted April 3, 2010 Share Posted April 3, 2010 You could make a script, override event_type_unequip and equip, if equipped item is "..." then AddAbility(oPC,3023); if unequipped then RemoveAbility(oPC,3023); or alternatively you have to edit the itemsets code. I didn't try it but maybe it also will work if you just add the script to the item: void main() { object oPC = GetHero(); if (GetTag(GetItemInEquipSlot(YOUR_SLOT, oPC)) == "YOUR_ITEM_TAG") { AddAbility(oPC,3023); } else { RemoveAbility(oPC,3023); } } Edit:I think the removeability line won't work but test it if it doesn't work you still can do it with event_type_equip Link to comment Share on other sites More sharing options...
NightprowlerAlpha Posted April 3, 2010 Author Share Posted April 3, 2010 Thanks for the quick answer Hdhd.So far, what (I think) is the way to do it is, as I said in the OP to add a script tied to the item itself with "behaviour" infos.Something that would state that "if the helm is equipped by a creature, the said creature gets the Feign Death ability given for as long as the helm is worn" I'm back to work as I speak, so I'm gonna dig the functions that I would see fit and post them here to see what you think about that...This is my first glance at C++ so I can only go by logic, I don't understand much to libraries and the like ^^ Mkay... looks like I was either sleepy (I'd prefer that one) or dumb (meh) when I was looking at built-in scripts and such this morning, I found one that gets me closer to what I'm looking (CreatureEvent) So this is what the base would look like I assume #include "log_h" #include "utility_h" #include "wrappers_h" #include "events_h" void main() { event ev = GetCurrentEvent(); int nEventType = GetEventType(ev); string sDebug; object oPC = GetHero(); object oParty = GetParty(oPC); int nEventHandled = FALSE; switch(nEventType) { //////////////////////////////////////////////////////////////////////// // Sent by: Engine // When: The current creature has equipped an item //////////////////////////////////////////////////////////////////////// case EVENT_TYPE_EQUIP: { object oItem = GetEventCreator(ev); // the item being equipped break; } //////////////////////////////////////////////////////////////////////// // Sent by: Engine // When: The current creature has unequipped an item //////////////////////////////////////////////////////////////////////// case EVENT_TYPE_UNEQUIP: { object oItem = GetEventCreator(ev); // the item being unequipped break; } } if (!nEventHandled) { HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE); } } so the structure should be along the line of "if ANY creature equips item which owns that script give said creature talent Feign Death if said creature unequips item which owns that script remove talent Feign Death from said creature"right ? **EDIT** I found 3 different scripts that might give me the result I'm looking for if correctly merged.The one I posted above, and 2 that are (as said earlier) under the _Debug folder (respectively AddTalent and RemoveTalent). I guess that, if I could manage to set it properly, it would allow the structure I'm looking for.But I'm still puzzled by the C++... can't get sure about what means what out there :( AddTalent script void main() { // get console command commandline string sVar = GetLocalString(GetModule(),"RUNSCRIPT_VAR"); int nFind = FindSubString(sVar," "); object oCreature; int nId; string sSub; if (nFind >0) { // before the first space: tag string sCreatureTag = SubString(sVar,0,nFind); sSub = SubString(sVar,nFind+1, GetStringLength(sVar)); oCreature = GetObjectByTag(sCreatureTag); } else { oCreature = GetMainControlled(); sSub = SubString(sVar,0,GetStringLength(sVar)); } nId = StringToInt(sSub); string sName = Log_GetAbilityNameById(nId); if (IsObjectValid(oCreature)) { if (nId >0 /*&& GetStringLength(sName)>0*/) { if (!HasAbility(oCreature,nId)) { DEBUG_PrintToScreen("Added talent #" + ToString(nId) + " to " + ToString(oCreature)); } AddAbility(oCreature,nId); SetQuickslot(oCreature, 0, nId); } else { DEBUG_PrintToScreen("Adding talent #" + ToString(nId) +" to " + ToString(oCreature)+ " failed, invalid talent"); } } SetLocalString(GetModule(),"RUNSCRIPT_VAR",""); } RemoveTalent scriptvoid main() { // get console command commandline string sVar = GetLocalString(GetModule(),"RUNSCRIPT_VAR"); int nFind = FindSubString(sVar," "); object oCreature; int nId; if (nFind >0) { // before the first space: tag string sCreatureTag = SubString(sVar,0,nFind); // after the first space: new tag nId= StringToInt(SubString(sVar,nFind+1, GetStringLength(sVar))); oCreature = GetObjectByTag(sCreatureTag); } else { oCreature = GetMainControlled(); nId= StringToInt(SubString(sVar,0,GetStringLength(sVar))); } if (IsObjectValid(oCreature)) { if (nId >0) { if (!HasAbility(oCreature,nId)) { DEBUG_PrintToScreen("Added talent #" + ToString(nId) +" to " + ToString(oCreature)); } RemoveAbility(oCreature,nId); } else { DEBUG_PrintToScreen("Adding talent #" + ToString(nId) +" to " + ToString(oCreature)+ " failed"); } } SetLocalString(GetModule(),"RUNSCRIPT_VAR",""); } Any help is really welcome :) Link to comment Share on other sites More sharing options...
hdhd Posted April 3, 2010 Share Posted April 3, 2010 The command to add spells is: AddAbility(oPC,spellid); the remove command: RemoveAbility(oPC,spellid); look at the script I proposed (IDs can be found on dragonagewiki) Maybe try this (I just added the add and remove spell command): #include "log_h" //you need this only for debugging (PrintToLog) so you could remove it #include "utility_h" #include "wrappers_h" #include "events_h" void main() { event ev = GetCurrentEvent(); int nEventType = GetEventType(ev); string sDebug; object oPC = GetHero(); object oParty = GetParty(oPC); int nEventHandled = FALSE; switch(nEventType) { //////////////////////////////////////////////////////////////////////// // Sent by: Engine // When: The current creature has equipped an item //////////////////////////////////////////////////////////////////////// case EVENT_TYPE_EQUIP: { object oItem = GetEventCreator(ev); // the item being equipped AddAbility(oPC,3023); break; } //////////////////////////////////////////////////////////////////////// // Sent by: Engine // When: The current creature has unequipped an item //////////////////////////////////////////////////////////////////////// case EVENT_TYPE_UNEQUIP: { object oItem = GetEventCreator(ev); // the item being unequipped RemoveAbility(oPC,3023); break; } } if (!nEventHandled) { HandleEvent(ev, RESOURCE_SCRIPT_CREATURE_CORE); } } The problem is that this script will always give the spell to the player (oPC) and not to the creature that equipped the item so you have to find out who wears your item (perhaps again with GetEventCreator) or restrict the item that only a specific person can wear it. Link to comment Share on other sites More sharing options...
NightprowlerAlpha Posted April 3, 2010 Author Share Posted April 3, 2010 Thanks alot for the head up mate, I'll look into that and let you know :)Much appreciated. *EDIT**I tested with that script, it doesn't seem to work (even on the main char).No error return when it's compiled tho, so I don't get why.I wish I could be of some use aside of the idea :( Link to comment Share on other sites More sharing options...
hdhd Posted April 4, 2010 Share Posted April 4, 2010 Try to find the error with debugging (http://social.bioware.com/forum/1/topic/71/index/462740/1?forum/1/topic/71/index/462740/1&forum/1/topic/71/index/462740/1&lang_id=5&lang_id=6) for instance maybe the event is not overridden: PrintToLog("Handling event type " + IntToString(nEventType));or test this script: #include "log_h" void main() { PrintToLog("****** Adding spell ******"); object oPC = GetHero(); AddAbility(oPC,3023); } If in the log isn't the message "Adding spell" you did something wrong and the problem is not the script itself but that the mod isn't loaded properly. Link to comment Share on other sites More sharing options...
NightprowlerAlpha Posted April 4, 2010 Author Share Posted April 4, 2010 Hi,I tested all of your scripts and none worked, I know for a fact that the module (items and such) loads properly, as I changed the skin each time I tested a script, and the skin was changed on loading it.And since you said your scripts should work for sure at least to add the talent, I guess I'm doing something wrong regarding the Helm script, just gotta find out what now :)Gonna see what I can find about using a script inside an item file instead of inside a module file to try and figure that out. I know for a fact that it's doable as at some point, I've seen a module adding a talent when the item was worn. Thanks for your great help :) **EDIT**Might have found why I can't get it to work.Looks like the script shouldn't be set in the .uti file of the Helmet as I thought.From : DA Builder Wiki Item Script :The purpose of the item event script (if any) is not clear. Events involving items (acquire, lose, equip, unequip, etc…) are received by the event script for the creature or placeable owning the item, but are not received by the item script. **EDIT 2** List of Item PropertiesItem Properties can be added either directly to an item through the tool builder interface, or assigned via scripting through the AddItemProperty method.which refers to.... void AddItemProperty( object oItem, int nProperty, int nPower ); just gotta find how to use that now ^^ Link to comment Share on other sites More sharing options...
hdhd Posted April 4, 2010 Share Posted April 4, 2010 I don't think that it will work with item properties because they usually just increase your attributes. Maybe if you could add to the existing itemproperty list an attribute that adds a spell it could work. The existing list can be found in C:\Program Files\Dragon Age\tools\Source\2DA\itemprps.xls look at http://social.bioware.com/wiki/datoolset/index.php/2DA for more informations. Maybe the best solution is still to use a script but this time without attaching it to an item but instead using it as a general script. You can use then GetItemInEquipSlot to check if the item is equipped. Link to comment Share on other sites More sharing options...
NightprowlerAlpha Posted April 4, 2010 Author Share Posted April 4, 2010 Yep, you're right for the list, I've been digging around on the Wiki and found out about the list, had a glance at it, and found it's limitated to the exact same properties that are acessible through the Toolset, so that's most certainly a no go.As for the script attached to an item, I tested out (to be 100% sure) using a addResctriction script that is built-in, and it doesn't work, so it's now obvious that it's not the way to go. Now to figure out how to proceed tho hehe... Maybe the best solution is still to use a script but this time without attaching it to an item but instead using it as a general script. You can use then GetItemInEquipSlot to check if the item is equipped.which brings us back to your first suggestion... damn me lol I assume it would go inside the main script then ? (the one that I use to spawn the items in the player inventory)Or would 2 scripts in the same module be both taken in account ? Link to comment Share on other sites More sharing options...
NightprowlerAlpha Posted April 4, 2010 Author Share Posted April 4, 2010 Looks like I found a much better (and easier ^^) way to get to the result I want.Actually, it seems possible to make a "set bonus" to give an ability...Here's what i found so far :It's possible to make use the "item set" property to give various effects, and adding an ability is among those (from effects.xls).I found the property I need for that.Now I need to find how to set the "item set bonus" cause adding it straight to the itemsets.xls doesn't seem to work... gonna have to mess around a bit, but I might eventually get it to work :) Link to comment Share on other sites More sharing options...
Recommended Posts