project-navigation
Personal tools

Author Topic: New weapons - SOLVED  (Read 5686 times)

Offline Latino210

  • Squad Leader
  • ****
  • Posts: 161
  • UFORadiant mapper
    • View Profile
New weapons - SOLVED
« on: November 23, 2012, 05:28:56 pm »
Hello!

I am trying my hand at modding weapons. I've just built a model for a new rifle (I need it for my mod), but I cannot make it work. I've built the .md2 and extracted a .jpg, but I do not know how to apply a little light spot, how to tell the engine from where the bullet will come off and, more important, how to put it ingame. Any help will be appreciated.

« Last Edit: November 24, 2012, 12:28:05 am by Latino210 »

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: New weapons
« Reply #1 on: November 23, 2012, 05:38:18 pm »
You're going to need tags, which are small triangles put onto models to tell it where to attach various other items. For weapons, you only need a tag_muzzle. The character models have tags which tell it how to equip your weapon.

Offline Latino210

  • Squad Leader
  • ****
  • Posts: 161
  • UFORadiant mapper
    • View Profile
Re: New weapons
« Reply #2 on: November 23, 2012, 06:22:37 pm »
You're going to need tags, which are small triangles put onto models to tell it where to attach various other items. For weapons, you only need a tag_muzzle. The character models have tags which tell it how to equip your weapon.

OK, got it thanks, I have created a new tag, named it tag_muzzle and exported the .tag file with the script. Now, if you could explain me how to implement the new rifle? I can copy the assault rifle entry in the weapons_human.ufo file, changing the path for the model and the name of the weapons, but I do not know how to add this as an usable weapon. Should I add a dummy tech in the research.ufo and a ufopaedia entry?

EDIT: I managed to put the files in the SMG dir, it's enough to test the graphics. As you can see for yourself, I still have some problems with the skinning. I unwrapped the UVmap, packed it and rendered the UV template (all in 3ds max, of course) but the result is not what I wanted. Can anyone help with the UVmapping?

My idea is a rifle cobbled together by a bunch of engineers with access to a CNC lathe and a lot of desperation. It's the kind of weapon I could build if my factory was attacked by aliens.
« Last Edit: November 23, 2012, 07:37:55 pm by Latino210 »

Offline DarkRain

  • Project Coder
  • Captain
  • ***
  • Posts: 746
    • View Profile
Re: New weapons
« Reply #3 on: November 23, 2012, 07:35:53 pm »
Every item (including ammo) needs a tech, so, yes, you need to add a new tech entry (but you can create new ufo files for your new tech/items/wathever if you want), you might want to look at the assault rifle techs as an example, maybe you also want to take a look at researched_list.ufo

An ufopaedia entry isn't strictly needed, (but would be cool, wouldn't it?) you can write a short description if you like.

Offline Latino210

  • Squad Leader
  • ****
  • Posts: 161
  • UFORadiant mapper
    • View Profile
Re: New weapons
« Reply #4 on: November 23, 2012, 11:26:53 pm »
Sorry, I am having some problems. I've created a new dir called "scraprifle" in the models/weapons dir, with the md2 and jpg for the new rifle. I 've added this code to the weapons_human.ufo file:

Code: [Select]
// SCRAPRIFLE

item scraprifle
{
name "_Scraprifle"
model "weapons/scraprifle/scraprifle"
weapon true
type "rifle"
animationindex 1
holdtwohanded false
firetwohanded true
shape "0 0 2 2"
center "2 0 1"
scale 1.35
ammo 12
reload 6
reloadsound "weapons/reload-pistol"
price 900
size 7
is_secondary false
}

item scraprifle_ammo
{
name "_Scraprifle Ammo"
model "weapons/scraprifle/scraprifle_clip"
type "ammo"
animationindex 0
shape "0 0 1 1"
center "0 0 -0.2"
scale 1.5
price 20
size 1
is_secondary false
dmgtype "normal"

weapon_mod
{
weapon scraprifle
firedef
{
name "_Snap Shot"
skill "close"
projtl bullet-smg
impact bulletImpact
hitbody null
firesnd "weapons/bullet-pistol"
impsnd "impact/bullet-impact"
bodysnd "impact/bullet-bodyimpact"
speed 3000
spread "2 2"
crouch 1
range 40
shots 1
ammo 1
time 4
damage "30 5"
dmgweight "normal_light"
reaction true
}
firedef
{
name "_Aimed Shot"
skill "close"
projtl bullet-smg
impact bulletImpact
hitbody null
firesnd "weapons/bullet-pistol"
impsnd "impact/bullet-impact"
bodysnd "impact/bullet-bodyimpact"
speed 3000
spread "1.5 1.5"
crouch 1
range 40
shots 1
ammo 1
delaybetweenshots 10
time 8
damage "30 5"
dmgweight "normal_light"
}
}
}
(copied from the pistol code)

Then I've added this code to the researched_list.ufo

Code: [Select]
rs_weapon_scraprifle
rs_weapon_scraprifle_ammo

and this code to the research.ufo

Code: [Select]
tech rs_weapon_scraprifle
{
type "weapon"
up_chapter equipment
description {
default "*msgid:pistol_txt"
}
// pre_description "*msgid:pistol_pre_txt"

provides scraprifle
time 0
producetime 40
}

tech rs_weapon_scraprifle_ammo
{
type "weapon"
up_chapter equipment
description {
default "*msgid:pistol_mag_txt"
}
// pre_description "*msgid:pistol_mag_pre_txt"

provides scraprifle_ammo
time 0
producetime 12
}

copied from pistol, again.


But when I start a new campaign the scraprifle is nowhere to be seen. What am I doing wrong?
« Last Edit: November 24, 2012, 12:10:56 am by Latino210 »

Offline geever

  • Project Coder
  • PHALANX Commander
  • ***
  • Posts: 2561
    • View Profile
Re: New weapons
« Reply #5 on: November 23, 2012, 11:33:10 pm »
Sorry, I am having some problems. I've created a new dir called "scraprifle" in the models/weapons dir, with the md2 and jpg for the new rifle. I 've added this code to the weapons_human.ufo file:

But when I start a new campaign the scraprifle is nowhere to be seen. What am I doing wrong?

Do you see any warnings about it in ufoconsole.log?

-geever

Offline H-Hour

  • Administrator
  • PHALANX Commander
  • *****
  • Posts: 1923
    • View Profile
Re: New weapons
« Reply #6 on: November 23, 2012, 11:38:47 pm »
Item "scraprifle_ammo" doesn't exist because you forgot to rename the item definition. It's still listed as pistol_ammo.

Always check the ufoconsole.log. It's very good at flagging errors with the UFO scripts. In this case it probably would have thrown an error saying that pistol_ammo was already defined (ie - there were two item definitions with the same id).

Offline Latino210

  • Squad Leader
  • ****
  • Posts: 161
  • UFORadiant mapper
    • View Profile
Re: New weapons
« Reply #7 on: November 24, 2012, 12:08:47 am »
ok, thanks, I've already solved the "scraprifle_ammo" problem and added the UFOPAEDIA entries for both the weapon and the ammo, they both work. I've already tried to add the following lines to the "campaign_initial_market" and the "campaign_player" entries in the Equipment.ufo file:

Code: [Select]
item (scraprifle 1)
item (scraprifle_ammo 12)

but the scraprifle is not appearing in the buy/sell nor in the production menus... I've checked the console, no error messages!
« Last Edit: November 24, 2012, 12:18:17 am by Latino210 »

Offline Latino210

  • Squad Leader
  • ****
  • Posts: 161
  • UFORadiant mapper
    • View Profile
Re: New weapons - SOLVED!
« Reply #8 on: November 24, 2012, 12:27:47 am »
Thanks for the help, I managed to find the problem!


The error was the "Is secondary      false" line. It should have been a "Is primary           true" line. Now it works perfectly. Thanks again. Now, if someone could help me with the UV skinning I would appreciate it.