Josan12 said:
I need to ask for some general scripting help for the cigs.
1) I've created the new cigarette item using Cubik's F2Wedit. The pro number is 532. No problem.
I also put the new PID number and name in the item.h file (not sure if i need to do that but i did it anyway)
When i try to reference the new PID (PID_CIGS or 532) in this part of my script:
Code:
if (temp < 20) then begin
rm_obj_from_inven(self_obj, 532);
destroy_object(532);
end
the game crashes when it tries to call the new item PID.
Am i missing something? Is there some way you need to register a new PID i've missed?
2) Does anyone know what code to add to stop the idle animation interrupting the animation being played by the script?
script_overrides and reg_anim_clear don't seem to do the job
3) Can anyone think of a good way to give an item 10 uses? Unfortuanately, drugs are always single use so thats out.
I don't know if you still have the problem, but here's the answer:
the function rm_obj_from_inven needs to be put in another variable. So you need to write:
Code:
variable trash;
trash:=rm_obj_from_inven(dude_obj,532);
destroy_object(trash);
If not, there's a handy command:
Code:
remove_pid_qty(dude_obj,PID_CIGS,1)
Remember
NOT to put a ";" sign at the end.
If you want to put the appropriate code in the obj_dude script, here is my proposal:
Code:
procedure use_obj_on_p_proc begin
variable item;
item:=obj_being_used_with;
if (obj_pid(item) == PID_CIGS) then begin
script_overrides;
if (obj_is_carrying_obj_pid(self_obj,PID_LIGHTER) > 0) then begin
if (local_var(LVAR_Cigarettes_remaining) == 0) then begin
set_local_var(LVAR_Cigarettes_remaining,10);
display_msg("You open a new pack of Commies.");
end
dec_local_var(LVAR_Cigarettes_remaining);
if (local_var(LVAR_Cigarettes_remaining) == 0) then begin
remove_pid_qty(self_obj,PID_CIGS,1)
end
inc_local_var(LVAR_Total_Cigarettes_Smoked);
reg_anim_clear(self_obj);
reg_anim_begin();
reg_anim_animate(self_obj,ANIM_jump_begin,-1);
reg_anim_end();
play_sfx("smoke");
display_msg("You smoke another Commie.");
if ((local_var(LVAR_Total_Cigarettes_Smoked) == 50) and (global_var(GVAR_REPUTATION_SMOKER) == 0)) then begin
set_global_var(GVAR_REPUTATION_SMOKER,1);
display_msg("You get a funny feeling you couldn't just quit smoking now. 'Commies' have become your obsession...");
end
end
else begin
display_msg("You don't have the lighter.");
float_msg(self_obj,"Damn!",FLOAT_MSG_RED);
end
end
end
What it does:
* If dude carries the lighter, it plays the animation and the sound, checks the number of cigarettes remaining and whether dude got the Smoker rep or not.
* If dude smoked the last cigarette from the pack, it removes the item.
* If dude doesn't have a lighter, it displays an appropriate message.
What it needs/assumes:
* You need to declare two local variables in the obj_dude script:
LVAR_Cigarettes_remaining and
LVAR_Total_Cigarettes_Smoked.
* You need to create a global variable for the smoker reputation.
* The Cigarettes item needs to be a misc item.
* I assumed the PID is PID_CIGS (I think I saw it somewhere in this thread), and the name of the sound: 'smoke'.
* I also assumed the smoking animation is the jump_begin animation. (You mentioned something about that, IIRC)
***
I haven't tested it, so there may be some bugs. I'm not entirely sure if the animation would be played, if not, let me know, I'll correct it.