Defining weapon ammo qty on scripts.

Discuss the creation and scripting of new fan-made games and mods for the Fallout series of games.
Post Reply
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Defining weapon ammo qty on scripts.

Post by Corpse »

I posted this on NMA earlier; I need help with two things:
1- give_obj_weapon command: I have tried to use this command to give my character a specific item with -1 ammunition qty everytime it is used; the idea is for an item that uses charges, that item is defined as the restock obj, the syntax I tried was
op_give_obj_weapon(op_dude_obj(), restock_obj, 38, -1, wield_me);
Unfortunately Noid's compiler is refusing to compile that line in the script, resulting in the following error message:
op_give_obj_weapon used before definition.
2- Defining ammunition qty on a wielded weapon:, is there a way to do this?, or a Metarule that defines it, etc.
I found proto_data command but when I looked for the data_member definitions, couldn't find one for ammo.

Any help would be appreciated.
Thanks in advance.
Jargo
Respected
Respected
Posts: 85
Joined: Fri Dec 27, 2002 6:17 pm
Location: FMC (Poland)
Contact:

Post by Jargo »

1) I don't think there is give_obj_weapon function.
Where have you find this ?
Error message say that compiler don't know what 'give_obj_weapon' is.

2)Well i have trayed to do that but witch no result :(
Even if you set (using Dims mapper, oryginal don't show this value) amunition quantity it doesn't work.
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

peoples reluctance to use the official mapper and script compiler still astounds me..

it is very easy to define new weapons in the official mapper.. just edit an item prototype and away you go..

you can set the ammo, the rounds ( per shot ) and so on..
Jargo
Respected
Respected
Posts: 85
Joined: Fri Dec 27, 2002 6:17 pm
Location: FMC (Poland)
Contact:

Post by Jargo »

He want to set ammo in weapon in script (in game) not the rounds etc in prototype.
Can you set that pistol will have only half of its ammo max qty using oryginal mapper :)
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

i read it as

1. he wants to make an item / weapon that takes 1 off the ammo every time he uses it..

2. wants to define how much ammo a weapon holds.. ( 10 shots per clip, 30 etc.. )

If i misunderstood what he wants to do then I apologise..

as for giving items and such from scripts, the original scripts that come with the editor are quite easy to follow to see how to do it..
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Post by Corpse »

ColJack wrote:i read it as

1. he wants to make an item / weapon that takes 1 off the ammo every time he uses it..
The item is already made and has a script assigned, and the ammunition is defined in the proto; what I can't get it to do is to use 1 charge of its ammo every time you use the item. That is why I need to work this into the item script.
2. wants to define how much ammo a weapon holds.. ( 10 shots per clip, 30 etc.. )
What I actually need is for the script to recognise how much ammunition the item is holding, there has to be a function for this; one example is if you look at an armed NPC, you will get the ammo count for the weapon that NPC is wielding, unless this is harcoded into the game engine then there has to be a way to recognise the ammo charges.

A simpler way I thought of doing it is to define the charges in a variable and script it to decrease 1 from the variable until it gets to the 0 at which point if the restock script has been succesfully decreasing 1 charge, the item should be out of ammo. Then you could make the script recognise this and replace the item for another duplicate of it which is a dud.

Then there is the issue of being able to create an item with ammo pid and quantity defined on the script. give_obj_command doesn't seem to work at all.

To Jargo
1) I don't think there is give_obj_weapon function.
Where have you find this ?
Error message say that compiler don't know what 'give_obj_weapon' is.
I found it on command.h.
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

i still don't get it.. :/

you want an existing item to reduce it's ammo by 1 every time you use it?? :?

that's what the weapons do anyway.. :|

please tell us EXACTLY what you want it for..

is this the molotov idea you had??
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Post by Corpse »

The item is not a weapon but a miscellaneous item that uses charges, (like the stealthboy) its for a set of Nightvision goggles; I got all the rest of the script working all I need is to get it to use up its charges.
User avatar
Red
Hero of the Glowing Lands
Hero of the Glowing Lands
Posts: 2085
Joined: Wed May 15, 2002 11:58 am
Location: Nowhere (important anyway)
Contact:

Post by Red »

Check out how the stealthboy and scanner work instead... Use the Midc item type with the charge and whatnot. I never tried this but I'm sure it'll be easyer to work it out that way.
...
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Post by Corpse »

Well, that is one of my problems, I can't find the scripts for the motion sensor, stealth boy or any misc item that uses charges; I think they are handled by the game engine.
Jargo
Respected
Respected
Posts: 85
Joined: Fri Dec 27, 2002 6:17 pm
Location: FMC (Poland)
Contact:

Post by Jargo »

give_obj_weapon is not a function it is a macro. You can't use macros in noids compiler(only in oryginal compiler)
This macro however does not add ammo to weapon, it only add weapon and ammo for it to critter inventory.


Well, that is one of my problems, I can't find the scripts for the motion sensor, stealth boy or any misc item that uses charges; I think they are handled by the game engine.
uhm
I think its hardcoded :( .
User avatar
ColJack
Vault Scion
Vault Scion
Posts: 175
Joined: Sat Apr 19, 2003 8:01 pm
Contact:

Post by ColJack »

it's in the objects prototype..

energy pid. ( picture of "ammo" )
energy type ( c cells, d cells etc )
count. ( charge )
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Post by Corpse »

give_obj_weapon is not a function it is a macro. You can't use macros in noids compiler(only in oryginal compiler)
This macro however does not add ammo to weapon, it only add weapon and ammo for it to critter inventory.
Thanks for that bit of info, but actually that is my intention; not to give ammo to the weapon but create the weapon with -1 ammo every time it is used. (eg. starts with 100 charges, use once this item is removed and replaced by same item with 99 charges... and so on)

If anyone could compile a simple script for me using Watcom and use that macro, then I could probably decompile it with Noid's or find another way around it if that doesn't work.
it's in the objects prototype..

energy pid. ( picture of "ammo" )
energy type ( c cells, d cells etc )
count. ( charge )
Yes I know that and the prototype registers this, but adding this parameter to Misc item prototypes does not make it use up its charges. I copied the stealth boy prototypes to make sure I didn't miss anything then hexed all the other data like PID, FRM, etc.
Jargo
Respected
Respected
Posts: 85
Joined: Fri Dec 27, 2002 6:17 pm
Location: FMC (Poland)
Contact:

Post by Jargo »

Well
If you want to add items to inventory you can simply use this:

Code: Select all


add_mult_objs_to_inven(WHO,ITEM_PID,NUMBER_OF_ITEMS);

usage:

add_mult_objs_to_inven(self_obj,8,1);        //this will add 10 mm pistol to self

add_mult_objs_to_inven(self_obj,29,100);    //this will add 100 ammo for it (10 mm JHP) to self

if you use Noid compiler then don't forget to add "op_" before function name.
op_add_mult_objs_to_inven
User avatar
Corpse
Vault Scion
Vault Scion
Posts: 188
Joined: Thu Mar 20, 2003 2:48 pm
Location: Sydney, Australia

Post by Corpse »

Jargo wrote:Well
If you want to add items to inventory you can simply use this:

Code: Select all


add_mult_objs_to_inven(WHO,ITEM_PID,NUMBER_OF_ITEMS);

usage:

add_mult_objs_to_inven(self_obj,8,1);        //this will add 10 mm pistol to self

add_mult_objs_to_inven(self_obj,29,100);    //this will add 100 ammo for it (10 mm JHP) to self

if you use Noid compiler then don't forget to add "op_" before function name.
op_add_mult_objs_to_inven
That wouldn't work because it would create the item loaded to its maximum capacity, then would create the ammunition separate. I want the item loaded with a specific ammo quantity and as far as I know you can't specify this using any of the add_obj or add_mult_obj commands; maybe adding an extra parameter to it:
eg op_add_obj_to_inven(op_target_obj()), item_pid, X)
X being intended to be the ammo parameter, but I haven't tested this and chances are it will result in a syntax error if this command can only use one parameter.
Jargo
Respected
Respected
Posts: 85
Joined: Fri Dec 27, 2002 6:17 pm
Location: FMC (Poland)
Contact:

Post by Jargo »

it would create the item loaded to its maximum capacity, then would create the ammunition separate
Yes, I think weapons when created always have max ammo. :(
Post Reply