Tuesday, October 27, 2009

Custom Weapon in UnReal: Part 2


In UnReal Editor, import the textures for the weapon, the weapon mesh (.PSK) and the weapon anims (.PSA).

Create an AnimSet


Your AnimSet Editor will open. Choose the weapon mesh and import the .PSA from here.


Open the Socket Manager and assign MF to the base and MuzzleFlashSocket to the point of fire.


This is how you import .PSA in case anyone is clueless.


In your UTAmmo_SmileyGun.uc, change the highlighted sentence to UTWeap_NameOfYourWeapon.

UPDATE: Here's a more detail breakdown of what to change (be sure to save as ANSI format if using NotePad++)

Open UTAmmo_SmileyGun.uc
Change line 4 to this
class UTAmmo_SmileyGun extends UTAmmoPickupFactory;
line 9 to this:
TargetWeapon=class'UTWeap_SmileyGun'
these redefine the name of the class and retarget the ammo to the correct weapon. If you like you can play with line 8.
AmmoAmount=8

Open UTAttachment_SmileyGun.uc
change line 4 to:
class UTAttachment_SmileyGun extends UTWeaponAttachment;
line 24:
End = Start + vector(Instigator.Controller.Rotation) class'UTWeap_SmileyGun'.default.WeaponRange;
line 117:
SkeletalMesh=SkeletalMesh'WP_Smiley_Gun.Mesh.WP_Smiley_Gun_3P' (or wherever your mesh is located)
line 131:
WeaponClass=class'UTWeap_SmileyGun'

Now open UTWeap_SmileyGun.uc
change line 4:
class UTWeap_SmileyGun extends UTWeapon;
change line 345 and 346:
SkeletalMesh=SkeletalMesh'WP_Smiley_Gun.Mesh.WP_Smiley_Gun_1P' (or wherever the first person gun is located)
AnimSets(0)=AnimSet'WP_Smiley_Gun.Anim.WP_Smiley_Gun_1P_Anim'
line 352:
AttachmentClass=class'UTAttachment_SmileyGun'
line 355:
SkeletalMesh=SkeletalMesh'WP_Smiley_Gun.Mesh.WP_Smiley_Gun_3P'
line 400:
MuzzleFlashSocket=MuzzleFlashSocket

DONE!


In your UTAttachment_SmileyGun.uc, make the changes as per this pic.

The third uc file is the toughest. Basically, examine the file and change what you think links previously to the rocket launcher, to now link to the SmileyGun. I've attached the hacked UTWeap_SmileyGun.uc file for your perusal.


When you run the UnReal editor again (once the uc files are hacked), it will detect changes and act as a compiler. This message will appear.


There should be no errors. Then you're good to go.


Run Unreal and go to Mutators.


Close Unreal and a UTSmileyGun.ini should be created. You can change FriendlyName and Description.


Back in Unreal, go to Mutators -> Weapon Replacement




Forgot to mention that a .u file would also be created. Put that into the Published directory if you are to run Unreal instead of the Editor.




Done!

Note: Do not name your package the same name as your weapon script folder (eg. SmileyGun folder, do NOT have a SmileyGun.upk. Unreal is too stupid to figure this out.

6 comments:

EuWing said...

Where do I get the bone for link gun?

Anonymous said...

I was getting the compiling error: unexpected 'i'

For those of you getting this error you need to save as unicode in your text editor, or else your script will not be compiled

Anonymous said...

You cannot get bones from anywhere. You need to create it from scratch.

Anonymous said...

I dont want to give my bones from my body to you

alex said...

UTWeap_SmileyGun.uc inside needed to change wat?

Anonymous said...

alex, you basically change whatever linkages that are modified specifically to your gun and make sure they refer to your gun ie. You're modifying the script to refer to your gun instead of the standard unreal gun.

Post a Comment