Assigning scripts to drugs

Josan12

Vault Senior Citizen
Does anyone know if it's possible to make drugs follow a script? I've experimented a little, and you can assign the script to the drug, but all drug items seem to be pre-set to be flagged as 'use on' only. This seems to screw up any use_item procs in the script and prevent them from working.....

Any ideas or suggestions?

(I ask because i'm experimenting with the possiblity of making drinking animations that are assigned to the booze, nuka-cola etc to make the animation/SFX play when the player uses the item. Crazy i know but hey)
 
Is it possible to fake it by turning them into regular items and have your script provide the normal drug effects?
 
Kanhef said:
Is it possible to fake it by turning them into regular items and have your script provide the normal drug effects?

I suppose it could (though as a noob scripter i can't say for sure)
I don't know how to script addictions and stat-effects but i suspect it can be done (?)

But one problem i can forsee for sure - i would have to set the 'new' items with the 'use' flag instead of the 'use on' flag. This would prevent booze (for example) being used on anyone other than the player. I could set them to have both flags, but i've noticed the 'use on' flag seems to ovveride the 'use' flag.

So the key question is: does anyone know if there's any way to make the 'use on' flag work with a script? (i guess it's quite possible there is but i'm just being dumb)
 
Does anyone know if the 'use_obj_on_obj' proc is relevant to solving my problem here?? I mean - according to the Editor guide it should be but i don't fully understand how it works.

Can anyone help?
 
Josan12 said:
Does anyone know if the 'use_obj_on_obj' proc is relevant to solving my problem here??

I don't think that is the code you want. I'm pretty sure that procedure is used not where the item itself with the code is used on something, but when another item is used on it.


Josan12 said:
Kanhef said:
Is it possible to fake it by turning them into regular items and have your script provide the normal drug effects?

I suppose it could (though as a noob scripter i can't say for sure)
I don't know how to script addictions and stat-effects but i suspect it can be done (?)

You can add temporary, drug-like effects. Consider the script from Ms. Kitty in New Reno. I don't know how to script new addictions, or if it's even possible. I would suggest handling it the same way as the smoking thing (i.e. karmic title, and make it temporary).
 
Using a new global variable and activate it when using a item and deactivating it after a while? The only problem I see with this is that the timer needs to be restarted after loading a game, etc. But this could maybe solved by setting more global var-stats. As example, 0, 1, 2, 3, 0, ...If you need this "addiction"-image, it would be possible to use Helios' script buttons because you can also just add new windows/ images withour button-function. I also would say that it is possible to activate/ deactivate the addiction with Sfall itself (read and write int or so, I am not 100% sure).
 
I also would say that it is possible to activate/ deactivate the addiction with Sfall itself.

Yes thats right ;)

timeslip add 3 new commands for it:
show_iface_tag, hide_iface_tag and is_iface_tag active relate to the LEVEL and ADDICT tags that appear above the interface. Use 3 for LEVEL and 4 for ADDICT. There are no other valid values that I'm aware of.

When you need other "Addict windows" I can make it with my Script Button Method.
 
Josan12

Code:
procedure use_obj_on_p_proc begin
   variable skill_doctor;
   variable heal;
   skill_doctor := has_skill(dude_obj, SKILL_DOCTOR);
   
/*
   PID_STIMPAK
   PID_FIRST_AID_KIT
   PID_RADAWAY
   PID_ANTIDOTE
   PID_MENTATS
   PID_MUTATED_FRUIT
   PID_BUFFOUT
   PID_DOCTORS_BAG
   PID_RAD_X
   PID_PSYCHO
   PID_SUPER_STIMPAK
   PID_JET
   PID_JET_ANTIDOTE
   PID_BROC_FLOWER
   PID_XANDER_ROOT
   PID_HEALING_POWDER
   PID_MEAT_JERKY
   PID_HYPODERMIC_NEEDLE
   PID_MUTAGENIC_SYRUM
   PID_HEART_PILLS
   PID_HYPO_POISON
   PID_FIELD_MEDIC_KIT
   PID_PARAMEDICS_BAG
   PID_MONUMENT_CHUNCK
   PID_MEDICAL_SUPPLIES
*/
   if (obj_being_used_with == PID_STIMPAK) then begin
   set_global_var(GVAR_NUM_USED_STIMPAKS, global_var(GVAR_NUM_USED_STIMPAKS) + 1);
   // Надо бы сделать таймер
   //set_local_var(LVAR_Time_Stimpak, (1 * ONE_GAME_DAY) + game_time);
   
   destroy_object(obj_being_used_with);
   add_obj_to_inven(dude_obj, create_object_sid(PID_HYPODERMIC_NEEDLE, -1, -1, -1));
   
   //if (skill_doctor >= 50) then heal := 5;
   
   if (global_var(GVAR_NUM_USED_STIMPAKS) <3> 3) then heal := -5; // Передоз

   critter_heal(dude_obj, heal);
   script_overrides;
   end
end



Code:
procedure use_obj_on_p_proc begin
//defines

#define GVAR_LEVEL_DRUG (346)

   if (obj_being_used_with == PID_JET) then begin
   set_global_var(GVAR_LEVEL_DRUG, global_var(GVAR_LEVEL_DRUG) + 1);


   if (global_var(GVAR_LEVEL_DRUG) > 5) then begin
   set_pc_base_stat(STAT_st, 2);
   critter_heal(dude_obj, -15);
   end

   script_overrides;
   end
end
 
It's the prophecy Josan...

YES YOU CAN !!!

:mrgreen:
you can understand the very strange langage if this phocking script :)
with a lot a aspirin and four roses bottles, you will touch the other reality !!
Or not :)
Ok , stop my trip, but it's true that it seems coming from another wolrd :)
Good luck ;)
How do you learn this langage?
HA...well a last thing ;)
I'm french, with strange humour :)
Hopping you 're not hurt ;)
++

Brother soifran
 
From what i gather, the first one allow you to create an empty hypodermic needle after using a stimpack, the second remove you 15 hp the 5th time you take jet.

So I suppose the script you are looking to create should look somewhat like this

if (obj_being_used_with == PID_BOOZE) then begin
set_global_var(GVAR_NUM_USED_BOOZE, global_var(GVAR_NUM_USED_BOOZE) + 1);
// Надо бы сделать таймер
//set_local_var(LVAR_Time_BOOZE, (1 * ONE_GAME_DAY) + game_time);

destroy_object(obj_being_used_with);
add_obj_to_inven(dude_obj, create_object_sid(PID_EMPTY_BOTTLE, -1, -1, -1));



if (global_var(GVAR_NUM_USED_BOOZE) <3> 3) then heal := -5; // Передоз

critter_heal(dude_obj, heal);
script_overrides;
end

And somewhere between If and end, you should add the play animation line of the frm you want to play (don't know how to do that, but it shouldn't be that different from the "go to sleep" script that you made).
But logicaly it would still play the drug anim before the drinking one....
Oh, and you loose 5hp each time you drink more than 3 booze,

But i am not sure was that what you asked ?
 
Grayswandir said:
From what i gather, the first one allow you to create an empty hypodermic needle after using a stimpack, the second remove you 15 hp the 5th time you take jet.

Ah ha .... i see. Well that's pretty cool (and i would use this) but
what i want most of all is to have the 'use on' flag run a script - but it seems this is not possible.

So, the second best option is to recreate all the effects (stat penalties, addictions, etc) of the different drinks (booze, beer, rotgut, nuka-cola etc) via script and assign them to a new item with the 'use' flag only.

The 2 problems are

a) that i don't really know how to script these addictions and effects
b) an item with the 'use' flag only can't be used on anyone other than the player ... so no more feeding booze to brahmin .... :(
 
what i want most of all is to have the 'use on' flag run a script - but it seems this is not possible.

You want a script that work for all npc? What did you tried exactly?
And where is the script that concern the drugs?
I am not familiar with command yet, but maybe i could give it a try...
 
Grayswandir said:
You want a script that work for all npc? What did you tried exactly?
And where is the script that concern the drugs?
I am not familiar with command yet, but maybe i could give it a try...

I'm not concerned whether the script will run on an NPC, but i would still want the item to be useable on NPC's.

Try assigning a script to a drug - as far as i can tell it won't run the script.
 
Josan you can use the original drug items. It's not a big problem.

Try assigning a script to a drug - as far as i can tell it won't run the script

Thats's not right. I use scripts that assigning to drugs. But with animations it will not work good. Only when you use the drugs at inventory the script play animations after close the inventory.

But I think the animations should be played , if dude used the items from the hand or inventory. Here is a modified glbooze Script. But it only work if perception is not 1.

Code:
#include "..\headers\animcomd.h"

procedure start;

variable perception;
variable booze;

procedure start begin
	variable new_perc;
	variable new_booze;
	if (game_loaded) then begin
		perception:=get_pc_extra_stat(1);
		booze:=obj_is_carrying_obj_pid(dude_obj, 125);
		set_global_script_repeat(25);
	end else begin
		new_perc:=get_pc_extra_stat(1);
		new_booze:=obj_is_carrying_obj_pid(dude_obj, 125);
		if (perception != new_perc) or (booze != new_booze) then begin
			if (perception > new_perc) and (booze > new_booze) then begin
            reg_anim_begin();
               reg_anim_animate(dude_obj, 13, -1);
            reg_anim_end();
			end
			perception:=new_perc;
			booze:=new_booze;
		end
	end
end

I hope this will help you :)
 
Back
Top