Aller au contenu

Photo

Is it possible to change a weapon's base type through scripting?


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

#1
ColorsFade

ColorsFade
  • Members
  • 1 271 messages
I haven't been able to find a way to do this or a resource to show me how. Figured I'd just ask in case anyone has done it. 

#2
kamal_

kamal_
  • Members
  • 5 260 messages
I suppose you could swap a weapon with another weapon with the same properties but a different base item type. Not sure you can directly change a weapon, but maybe someone will prove me wrong.

#3
ColorsFade

ColorsFade
  • Members
  • 1 271 messages
Yeah, I already have different weapon blueprints created - that's been the easiest way to deal with it so far. But it means copying blueprints and changing the base weapon type and icon. I figured if there was a way to script it, then I'd only need *one* blueprint and that would make life easy.

If I have to keep copying blueprints, so be it.

#4
I_Raps

I_Raps
  • Members
  • 1 262 messages
Someone correct me if I'm wrong ...

You could give oPC an item of the new base type - oNewWeapon...
Loop through the properties of oOldWeapon and add them to oNewWeapon...
Destroy oOldWeapon...

#5
kevL

kevL
  • Members
  • 4 075 messages
sounds good.. still need ~20 blueprints tho.


but yeah, they'd already exist!



ps. nailing down itemprops is a curmudgeon tho....

Modifié par kevL, 11 avril 2013 - 08:26 .


#6
ColorsFade

ColorsFade
  • Members
  • 1 271 messages

I_Raps wrote...

Someone correct me if I'm wrong ...

You could give oPC an item of the new base type - oNewWeapon...
Loop through the properties of oOldWeapon and add them to oNewWeapon...
Destroy oOldWeapon...



Haha! That worked! 

Oh, and it was so simple... I didn't quite do it the way you specified, because of something I read, but you got me on the right track. 

I needed to do two additional things to the object besides copy properties, and that was to change the icon and change the display text. Somewhere I read that if you change the icon on an item in the character's inventory, it won't actually change until they zone to a new area **or** swap it to another player. 

So, I fixed this by first creating the item on the NPC (since he's supposed to be crafting this "artifact" anyway). 

I take my one blueprinted item and create it on the NPC (longsword). Then I create a basic item of a different type on the NPC (short sword, requested by the player in this instance via conversation). 

I then loop through the longsword properties and apply them to the short sword. This was actually really easy to do. 

Then I get the description from the longsword and apply it to the short sword. 

The final step is to change the short sword's icon (since it's flaming, in this case) and for that I have to code the various types into the script by number, which means looking them up in the 2da file (since I couldn't find a function that splits a string - someone correct me if such a function exists). 

The last step is to give the new weapon to the PC. Very easy. 

It works. It means for a given unique item that I want the player to be able to receive as a reward and for the PC to be able to specify what *kind* of weapon they want, I can now do it easily with a reusable script instead of making all those blueprints... 

Awesome! This is going to save me so much time... 

#7
kevL

kevL
  • Members
  • 4 075 messages
IPCopyItemProperties() ?

i guess if it copies the props & subs over well-formed, Great!


( it should, no temporary props ofc )

#8
ColorsFade

ColorsFade
  • Members
  • 1 271 messages
Hey thanks kevL! I forgot to check the superinclude. Yep, that function does exactly what mine was doing. So I don't need to reinvent the wheel there.

The only glitch in the whole thing is that GetDescription is a broken function. So I have to remember to add the description as a local variable on the master item. Kind of a bummer, but easily remedied.

#9
Dann-J

Dann-J
  • Members
  • 3 161 messages
Prior to the ability to change the icon via script (patch 1.23 I think), I was using one of the other standard blueprints that already had the icon I wanted, and stripping the item of all its properties prior to adding my own and changing the name/description. That was the basis for the random item generator I used in Isle of Shrines.

#10
ColorsFade

ColorsFade
  • Members
  • 1 271 messages

DannJ wrote...

Prior to the ability to change the icon via script (patch 1.23 I think), I was using one of the other standard blueprints that already had the icon I wanted, and stripping the item of all its properties prior to adding my own and changing the name/description. That was the basis for the random item generator I used in Isle of Shrines.


I can see how that would work too. 

#11
kevL

kevL
  • Members
  • 4 075 messages
Colors,
did you see 34's notes on Set/GetDescription in Broken Functions? it seems t'me that a fella could Set a blank desc. on creation, then later in the same script Set it to a string, and finally do jiggery-pokery with the item there until it 'all' appears correctly. Anyway, don't get too distracted if you have a 'work' already ...


ps. x2_inc_itemprop is one of my favorite includes, if only for IPSafeAddItemProperty()