Weapon - units question?

Weapon - units question?

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Post Reply
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Weapon - units question?

Post by davidovo »

Hey guys, Do I really need to set the weapon models in the same file of the Units models.

Example:

My units will be: M4 Soldier

Basicly the m4 soldier would be armed with a m4.

But if i want this same units to buy a new weapon example AK47, can i replace his based weapon. Or do i need to Create exactly the same character models twice but 1 with the m4 and one with the Ak47???


Ill use some script as example.


Weapon script:

-- M4 (BLO)

local M4 = RifleClass:New{

name = [[M4]],

soundStart = [[BLO_M4]],

damage = {

default = 35,

objectName= M4.S3O

},



AK47 (BLO)

local AK47 = RifleClass:New{

name = [[AK47]],

soundStart = [[BLO_AK47]],

objectName= AK47.S3O


Im not sure if my question is clear well thanks!
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon - units question?

Post by smoth »

You cannot change weapons assigned to individual units. The way we work around this is to have alternate copies of units with each weapon profile.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Weapon - units question?

Post by davidovo »

Okay then I need to set it as an unit upgrade.

But the problem with this way is the fact that I want units to get random models.

So all Us Soldiers won't get the same skin.

Example

[unitinfo] {

2 unitname=USSOLdier;

...

int objectname;

switch (objectname)
{
case 1: {
objectName=USLMG1.S3O;
break;
}
case 2:
{
objectName=USLMG2.S3O;
break;
}
case 3:
{
objectName=USLMG3.S3O;
}
}


I think im really wrong about it but its the main idea of what i wanna do.

And IF i change the unit weapons with an upgrade to load the same model but with another weapon his skin will also change.
Last edited by davidovo on 20 Dec 2012, 16:35, edited 1 time in total.
User avatar
Anarchid
Posts: 1384
Joined: 30 Nov 2008, 04:31

Re: Weapon - units question?

Post by Anarchid »

You cannot change weapons assigned to individual units. The way we work around this is to have alternate copies of units with each weapon profile.
Alternatively, a unit can have all the potential weapons, with only one 'enabled' at a time.

Speaking from art standpoint, it is possible to use pressureline's piece-moving gadget instead of modeling multiple units, but you'll have to find it first.

Or you can include all the guns in the model as well, and just hide the ones you're not using.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Weapon - units question?

Post by davidovo »

Anarchid wrote:
You cannot change weapons assigned to individual units. The way we work around this is to have alternate copies of units with each weapon profile.
Alternatively, a unit can have all the potential weapons, with only one 'enabled' at a time.

Speaking from art standpoint, it is possible to use pressureline's piece-moving gadget instead of modeling multiple units, but you'll have to find it first.

Okay thanks but this way will take a while for me to get worked well, I think ill begin with full models and use the upgrade way to change their weapon.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon - units question?

Post by smoth »

Anarchid wrote:Alternatively, a unit can have all the potential weapons, with only one 'enabled' at a time.
This is not a good solution, because the unit ai always tries to use the primary weapon for range considerations. It produces inconsistent and frequently undesirable behaviors.
davidovo wrote:Okay thanks but this way will take a while for me to get worked well, I think ill begin with full models and use the upgrade way to change their weapon.
Try digging up the morph gadget, it's code is not something to learn from but it'll do the job for now.
User avatar
Jools
XTA Developer
Posts: 2816
Joined: 23 Feb 2009, 16:29

Re: Weapon - units question?

Post by Jools »

Actually, the morph gadget changes the unit from one unitdef to another.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: Weapon - units question?

Post by smoth »

Jools wrote:Actually, the morph gadget changes the unit from one unitdef to another.
which is what I suggested. I just wanted to give him a direct name of what he needs to look for.
davidovo
Posts: 21
Joined: 06 Dec 2012, 21:12

Re: Weapon - units question?

Post by davidovo »

Yeah its cool but in those two case I need to do 2 models anyway, so i prefer to just create 2 units example:

Paulmg.s3o

Paulshotgun.s3o

And use a build menu to switch from one to another.

Also can I link a build menu to a specific unit.

Whe only existing example I have is the merchant shop in warcraft3

Example A unit would buy from a vendor.
So I could set up the upgrade in there.
User avatar
yuritch
Spring 1944 Developer
Posts: 1018
Joined: 11 Oct 2005, 07:18

Re: Weapon - units question?

Post by yuritch »

Take a look at factories in S44. Tank and gun yards have 2 alternate upgrades, which result in different units.

Upgrade commands are not in build menu, they are custom buttons, which is the proper way (you don't usually want to have regular soldiers have build menus).
Google_Frog
Moderator
Posts: 2464
Joined: 12 Oct 2007, 09:24

Re: Weapon - units question?

Post by Google_Frog »

smoth wrote:
Anarchid wrote:Alternatively, a unit can have all the potential weapons, with only one 'enabled' at a time.
This is not a good solution, because the unit ai always tries to use the primary weapon for range considerations. It produces inconsistent and frequently undesirable behaviors.
I can work around this.

In ZK there is an amphibious unit that has a long ranged torpedo and a short ranged shotgun. On land it should get close to enemies but in the sea it should stay far away. My solution was to set the shotgun to be the primary weapon and increase it's range via lua when the unit is in the sea.

With this in mind I think you could achieve weapon swapping by making the primary weapon a dummy weapon which exists to set a unit's closing distance.
User avatar
Pressure Line
Posts: 2283
Joined: 21 May 2007, 02:09

Re: Weapon - units question?

Post by Pressure Line »

Google_Frog wrote:With this in mind I think you could achieve weapon swapping by making the primary weapon a dummy weapon which exists to set a unit's closing distance.
100% possible, and relatively easy (I have something that does exactly this lying around someone)
Post Reply

Return to “Lua Scripts”