UGX-Mods

Call of Duty 5: World at War => Downloadable Items for Mappers => Custom Maps, Mods & Tools => Scripts => Topic started by: DuaLVII on January 11, 2014, 04:33:00 pm

Title: [User Tutorial] Adding Buildables/Crafting to your map [Update: 1.0.1]
Post by: DuaLVII on January 11, 2014, 04:33:00 pm
Change Log;
Code Snippet
Plaintext
v1.0.1:
*Bug fix - Correct weapons now given after adding an item to bench with knuckle crack feature (Thanks too drugynugy for finding this bug)

Hey Guys,

Just wanted to share this with you all, This is my second ever script for World at War and I hope it will be useful to at least some of you.

Just know that once players have crafted an item in game, there is no function beyond that point and you will have to add your own script to make things happen after an item has been crafted.
I placed an example script which works with the main buildable script for you's so you know where to add your own scripts.

Download is located as an attachment at the end of this post.

Tutorial - Part 1 - Installing
World at War - Adding Crafting to your map - Tutorial Part 1 (http://www.youtube.com/watch?v=vvDQpR0JUBc#ws)

Tutorial - Part 2 - Using the prefabs and editing their value's
World at War - Adding Crafting to your map - Tutorial Part 2 (http://www.youtube.com/watch?v=Xd87k_rGYXM#ws)

Edit; Something I forgot to add, Make sure that the scripts are ticked on the mod iwd list.

For configuring the buildable script I added a config area near the top of the `dvii_buildables.gsc` script
(Be sure to read all comments within the script)

Code Snippet
Plaintext
dviiBuildableConfig()
{
/*--------------------
Hint strings used on the bench trigger
----------------------*/
level.Bench_Add_Item_Hint_String = "Press & Hold &&1 too add item"; //&&1 = players interact/use key bind :: This message is shown on players screen when they have an item to add

level.Bench_Take_Item_Hint_String = "Press & Hold &&1 too take item"; //&&1 = players interact/use key bind :: This message is shown on players screen when they have finished crafting the item and can take it


/*--------------------
Pickup model and brushmodel config
----------------------*/
level.Delete_Model_After_Pickup = true; //change to false if you don't want the model deleted after pickup

level.Hide_Model_After_Pickup = false; //change to true to hide the model after pickup (Only applies if Delete_Model_After_Pickup = false; (Used in-case you want to reuse the model after)

/*--------------------
Flags that are set either when item is built or when a player takes the built item
----------------------*/

level.Send_Flag_On_Build = false; //change to true to set the flag when the item is built

level.Send_Flag_On_Take = true; //change to false if you don't want the flag to set when the player takes the finished built item

level.Flag_Message_To_Send_On_Build = "item_built"; //Once a player has finished crafting an item, this message will be sent (Refer to example script to see how it is received)

level.Flag_Message_To_Send_On_Take = "item_taken"; //Once a player has taken the crafted item, this message will be sent (Refer to example script to see how it is received)

/*--------------------
Bench models and brushmodels config
----------------------*/

level.Delete_Bench_Item_After_Pickup = true; //change to false if you don't want the crafted item to be deleted

/*--------------------
Other bench configs
----------------------*/

level.Wait_Time_On_Item_Add = 3; //seconds to wait till the bench can be used again to add another item (0 = Instant)

level.Show_Knuckles_On_Item_Add = true; //change to false if you don't want knuckle cracking to show when player adds an item to the bench

level.Allow_Take_On_Build_Finish = true; //change to false if you don't want the player to be able to take the item when finished

/*--------------------
Any scripts to work with dvii_buildables can be added here
----------------------*/
thread maps\dvii_item_built_example::dvii_Initialize(); //Refer to the dvii_item_built_example.gsc script too add function to your built item
}



Adding a function to an item once built, Refer to the `dvii_item_built_example.gsc`

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

dvii_Initialize()
{
thread dviiBuildFinished(); //If level.Send_Flag_On_Build = true on dvii_buildables.gsc script, we will want too use this
thread dviiBuildTaken(); //If level.Send_Flag_On_Take = true on dvii_buildables.gsc script, we will want too use this
}

dviiBuildFinished()
{
while(1)
{
flag_wait("item_built");
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}

dviiBuildTaken()
{
while(1)
{
flag_wait("item_taken");
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}

Thanks,
DuaLVII
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: RamboBadass on January 12, 2014, 09:33:44 pm
can it be used for building a buyable ending .... like build something then once its build add a trigger-use to it ?
 
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: johndoe on January 12, 2014, 10:05:14 pm
can it be used for building a buyable ending .... like build something then once its build add a trigger-use to it ?
yes it can.
Code Snippet
Plaintext
trigger = GetEnt('endgame','targetname');
trigger on
of course, you'll need to disable the trigger using
Code Snippet
Plaintext
trigger off();
just don't forget to use the correct kvps and it'll work just fine.
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: RamboBadass on January 12, 2014, 10:12:50 pm
ok i kind of understand but how does it get turned on when built  sry im still learning
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: DuaLVII on January 13, 2014, 06:08:33 am
ok i kind of understand but how does it get turned on when built  sry im still learning

If you refer to the example script that comes with the download.

Code Snippet
Plaintext
#include maps\_utility; 
#include common_scripts\utility;
#include maps\_zombiemode_utility;

dvii_Initialize()
{
thread dviiBuildFinished(); //If level.Send_Flag_On_Build = true on dvii_buildables.gsc script, we will want too use this
thread dviiBuildTaken(); //If level.Send_Flag_On_Take = true on dvii_buildables.gsc script, we will want too use this
}

dviiBuildFinished()
{
while(1)
{
flag_wait("item_built");
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}

dviiBuildTaken()
{
while(1)
{
flag_wait("item_taken");
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}

I've placed 2 functions within the example, one for when an item is built, another when item is taken.

In the configuration of the main script `dvii_buildables` you can disable allowing players to take the finished item such that it runs only for a buyable ending.

I'll post more help if needed, But just made this post quickly because I'm about to head of too work.

(Quick edit; on your buyable ending script, if your triggername for the buyable ending is `end_game` then use
Code Snippet
Plaintext
ending_trig = GetEnt("end_game", "targetname");
ending_trig disable_trigger();

On example script under dviiBuildFinished() after the flag_wait add;

Code Snippet
Plaintext
ending_trig = GetEnt("end_game", "targetname");
ending_trig enable_trigger();

But like I said, I just rushed this, hope it works, if not, I'll be sure to check in when I get back)

I'll check back later.
Thanks,
DuaLVII
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: drugynugy on January 15, 2014, 11:48:04 pm
i have got this working, but now i need to get it to open a door.  once ive got all the iteams  dvii_buildables sends a flag to dvii_item_built_example so what will  i have to put in to it to activate a door plus the kvps for the door in radiant. will i need any code so the door will not work until its ready.
sorry for being a noob but gotta start somewhere.
thanks and respect will be given for all help
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: DuaLVII on January 16, 2014, 05:48:54 am
i have got this working, but now i need to get it to open a door.  once ive got all the iteams  dvii_buildables sends a flag to dvii_item_built_example so what will  i have to put in to it to activate a door plus the kvps for the door in radiant. will i need any code so the door will not work until its ready.
sorry for being a noob but gotta start somewhere.
thanks and respect will be given for all help

AHA! Drugynugy, My star, your the first to say `This works` and most importantly didn't say `I got an error`
I'll write up something in a bit, I didn't sleep so well last night so I'll be back in a few hours.

Post Merge: January 16, 2014, 11:22:28 am
Ok, Try this (Note I haven't tested this, but I hope it works for you)

This is what I've got so far which doesn't disconnect paths and enable a new zone (Depends on where this door will lead too though)

Make a door with script_brushmodel;
kvp's;
Code Snippet
Plaintext
targetname  =  myDoor
script_vector = 100 0 0
(May want to modify the script_vector depending on door direction for opening)

Once build is finished
Code Snippet
Plaintext
dviiBuildFinished()
{
while(1)
{
myDoor = GetEnt("myDoor", "targetname");
flag_wait("item_built");
                time = 1;
myDoor MoveTo( myDoor.origin + myDoor.script_vector, time, time * 0.25, time * 0.25 );
wait(1);
myDoor delete();
//iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}



When item is taken

Code Snippet
Plaintext
dviiBuildTaken()
{
while(1)
{
myDoor = GetEnt("myDoor", "targetname");
flag_wait("item_taken");
                time = 1;
myDoor MoveTo( myDoor.origin + myDoor.script_vector, time, time * 0.25, time * 0.25 );
wait(1);
myDoor delete();
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: drugynugy on January 16, 2014, 05:05:57 pm
one respect coming your way.
works perfect.
your a supper star
thanks drugynugy
Title: Re: [Tutorial] Adding Buildables/Crafting to your map
Post by: DuaLVII on January 16, 2014, 05:50:49 pm
one respect coming your way.
works perfect.
your a supper star
thanks drugynugy

(https://www.ugx-mods.com/forum/proxy.php?request=http%3A%2F%2F24.media.tumblr.com%2F7887a4c294151c85a75d76fef8b0ea06%2Ftumblr_mt0zmuKuMo1riqgn6o1_500.gif&hash=c4e783b379220aa3093b3dd9eb5ae6905e25f59d)
Title: Re: [User Tutorial] Adding Buildables/Crafting to your map [Update: 1.0.1]
Post by: BishyFTW on April 24, 2014, 04:25:44 pm


Post Merge: April 24, 2014, 11:22:51 pm
AHA! Drugynugy, My star, your the first to say `This works` and most importantly didn't say `I got an error`
I'll write up something in a bit, I didn't sleep so well last night so I'll be back in a few hours.

Post Merge: January 16, 2014, 11:22:28 am
Ok, Try this (Note I haven't tested this, but I hope it works for you)

This is what I've got so far which doesn't disconnect paths and enable a new zone (Depends on where this door will lead too though)

Make a door with script_brushmodel;
kvp's;
Code Snippet
Plaintext
targetname  =  myDoor
script_vector = 100 0 0
(May want to modify the script_vector depending on door direction for opening)

Once build is finished
Code Snippet
Plaintext
dviiBuildFinished()
{
while(1)
{
myDoor = GetEnt("myDoor", "targetname");
flag_wait("item_built");
                time = 1;
myDoor MoveTo( myDoor.origin + myDoor.script_vector, time, time * 0.25, time * 0.25 );
wait(1);
myDoor delete();
//iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}



When item is taken

Code Snippet
Plaintext
dviiBuildTaken()
{
while(1)
{
myDoor = GetEnt("myDoor", "targetname");
flag_wait("item_taken");
                time = 1;
myDoor MoveTo( myDoor.origin + myDoor.script_vector, time, time * 0.25, time * 0.25 );
wait(1);
myDoor delete();
iPrintLn("Continue function from here");

//From here add your work to give your item a function once built

break;
}
}
what do u mean
//iPrintLn("Continue function from here");
//From here add your work to give your item a function once built

im getting a bad syntax error it says }, would this be whats wrong?
Title: Re: [User Tutorial] Adding Buildables/Crafting to your map [Update: 1.0.1]
Post by: DuaLVII on April 25, 2014, 06:39:45 am
PM Me your example script.
Title: Re: [User Tutorial] Adding Buildables/Crafting to your map [Update: 1.0.1]
Post by: BishyFTW on April 26, 2014, 06:54:20 pm
My doors not working?