MODSon[line.com] Wiki - Beta 1.0

World at War: SP Nazi Zombies Automatic Transaction Machine

From MODSonline Wiki

Jump to: navigation, search

Contents

[edit] Automatic Transaction Machine

The ATM allows players to share points by depositing them in a "Bank" and transacting. It also provides bonus points every round like an 'interest' feature.

The setup and script was developed by Playername from www.modsonline.com for Map Pack 1 of the Zombie Experience mod.

[edit] Scripting and Implementation

Create a _zombiemode_atm.gsc in codwaw/raw/maps

Inside place this:

#include maps\_zombiemode_utility;
#include common_scripts\utility;

/* ATM
   Tyler H. | Playername
   playername@codhelp.info

------------ What it does ------------
The ATM is just like a bank ATM. You can transact and deposit money into and out of the "bank".
The banks money is shown in the bottom left above the round number.
If you do not have enough money to deposit, or the bank doesn't have enough to transact, nothing happens.

------------ How to use ------------
1. Make a new "trigger_use".
2. Hit "N" to bring up the entity window.
3. Give the trigger a targetname of "atm_trigger"
4. Make a new "script_origin"
5. Move it to the place where the player will stand. Also, set the angles so the arrows is facing the
   direction the player should be facing.
5. Link the trigger to the script_origin by selecting the trigger, then the origin and hitting "W".
6. Add as many of these you want.
7. Change the "level.bank" (below) to the start number of money in the bank.
*/

Init()
{
	level.bank = 500;
	precacheMenu("atm_menu");
	precacheString("Bank Ballace:");

	atms = getEntArray("atm_trigger", "targetname");

	if(!isDefined(atms) || atms.size <= 0)
	{
		// Uhh, no triggers were found
		// Print error and quit
		return;
	}

	for(i=0;i<atms.size;i++)
		atms[i] thread atmStart();

	thread bankHud("create");
	thread bankRoundWatch();
}

atmStart()
{
	self.beingUsed = false;
	self setCursorHint("HINT_NOICON");

	if(!isDefined(self.target))
	{
		// Uhh, no origin was found for this trigger
		// Print error and return;
		// TURN OFF TRIGGER
		self trigger_off();
		return;
	}

	seat = getEnt(self.target, "targetname");

	for(;;)
	{
		self waittill("trigger", player);

		if(self.beingUsed == true)
			continue;

		self.beingUsed = true;
		self.cash = 0;
		self trigger_off();

		player atmHud("create");

		player setOrigin(seat.origin);
		player setPlayerAngles(seat.angles);
		//player playerLinkTo(seat);
		player freezecontrols(true);
		player DisableWeapons();

		player openMenu("atm_menu");

		while(self.beingUsed)
		{
			player waittill("menuresponse", menu, response);

			if(menu != "atm_menu")
				continue;

			switch(response)
			{
			case "close":
				self thread closeAtm(player);
				break;

			case "deposit":
				// Take player's money and add it to the bank's
				bank = round_up_to_ten(int(self.cash));

				// See if they have enough money... if I have 200 and want to add 500, 200 < 500, so i am adding 200
				if(player.score >= bank && player.score != 0)
				{
					player maps\_zombiemode_score::minus_to_player_score(bank);
					level.bank += bank;
					player playsound( "cha_ching" );
					self.cash = 0;
					player atmHud("update", self.cash);
					bankHud("update");
				}
				else
				{
					self.cash = 0;
					player atmHud("update", self.cash);
					player playsound("no_cha_ching");
				}

				self thread closeAtm(player);
				break;

			case "transact":
				// Take bank's money and add it to the player's
				bank = round_up_to_ten(int(self.cash));

				if(level.bank >= bank && level.bank != 0)
				{
					player maps\_zombiemode_score::add_to_player_score(bank);
					level.bank -= bank;
					player playsound( "cha_ching" );
					self.cash = 0;
					player atmHud("update", self.cash);
					bankHud("update");
				}
				else
				{
					self.cash = 0;
					player atmHud("update", self.cash);
					player playsound("no_cha_ching");
				}

				self thread closeAtm(player);
				break;

			case "50":
				self.cash += 50;
				player atmHud("update", self.cash);
				break;

			case "100":
				self.cash += 100;
				player atmHud("update", self.cash);
				break;

			case "500":
				self.cash += 500;
				player atmHud("update", self.cash);
				break;

			case "1000":
				self.cash += 1000;
				player atmHud("update", self.cash);
				break;

			case "clear":
				self.cash = 0;
				player atmHud("update", self.cash);
				break;
			}
		}

		// Just in case ;)
		self thread closeAtm(player);

		wait 5;
	}
}

closeAtm(player)
{
	player atmHud("delete");
	//player unlink();
	player freezecontrols(false);
	player enableWeapons();
	self.beingUsed = false;
	self trigger_on();
}

atmHud(status, cash)
{
	switch(status)
	{
	case "create":
		if(isDefined(self.atmHud))
			return;

		self.atmHud = newClientHudElem(self);
		self.atmHud.x = 310;
		self.atmHud.y = 156;
		self.atmHud.alignX = "center";
		self.atmHud.alignY = "top";
		self.atmHud setValue(0);

		break;

	case "update":
		cash = int(cash);
		if(!isDefined(self.atmHud))
			return;

		self.atmHud setValue(cash);
		break;

	case "delete":
		if(!isDefined(self.atmHud))
			return;

		self.atmHud destroy();

		break;

	default:
		return;
	}
}

bankRoundWatch()
{
	level waittill("round_start"); // Skip first round

	while(1)
	{
		level waittill("round_start");
		level.bank += 100;
		bankHud("update");
	}
}

bankHud(status)
{
	switch(status)
	{
	case "create":
		if(!isDefined(level.bankHudNo))
		{
			level.bankHudNo = newHudElem();
			level.bankHudNo.alignX = "left";
			level.bankHudNo.alignY = "top";
			level.bankHudNo.horzAlign = "left"; 
			level.bankHudNo.vertAlign = "top";
			level.bankHudNo.x = 70;
			level.bankHudNo.y = 0;
			level.bankHudNo setValue(level.bank);
		}

		if(!isDefined(level.bankHudText))
		{
			level.bankHudText = newHudElem();
			level.bankHudText.alignX = "left";
			level.bankHudText.alignY = "top";
			level.bankHudText.horzAlign = "left"; 
			level.bankHudText.vertAlign = "top";
			level.bankHudText.x = 1;
			level.bankHudText.y = 0;
			level.bankHudText setText("Bank Balance:");
		}
		// We want to also update the hud when we create it

	case "update":
		cash = int(level.bank);
		if(!isDefined(level.bankHudNo))
			return;

		level.bankHudNo setValue(cash);
		break;

	case "delete":
		if(isDefined(level.bankHudNo))
			level.bankHudNo destroy();

		if(isDefined(level.bankHudText))
			level.bankHudText destroy();

		break;

	default:
		return;
	}
}

You can follow the setup guide within the script to help modify it.

[edit] Radiant

[edit] HUD Elements

C:\Program Files\Activision\Call of Duty - World at War\raw\ui\scriptmenus\atm_menu.menu

#include "ui/menudef.h"
#include "ui_mp/common_macro.inc"

#define CHOICE_GROUP			"invert_axis"

// required for inside-popup styles
#include "ui_mp/menustyle.inc"
#include "ui/choices_setup_common.menu"

// setting longer buttons which in turn sets the width of the popup
#undef CHOICE_SIZE_X
#define CHOICE_SIZE_X			320

#undef CHOICE_HORIZONTAL_ALIGN
#define CHOICE_HORIZONTAL_ALIGN	HORIZONTAL_ALIGN_CENTER
#undef CHOICE_VERTICAL_ALIGN
#define CHOICE_VERTICAL_ALIGN	VERTICAL_ALIGN_CENTER
	
// required for popup style
#include "ui_mp/popupstyle.inc"
#include "ui/choices_setup_popmenu.menu"

{
	menuDef 
	{
		name atm_menu
	    	visible 1
   		fullscreen 0
		focusColor COLOR_FOCUSED
		rect	0 0 640 480
   		style 1
		onESC 
		{ 
			scriptMenuResponse "close";
			// close "atm_menu";
		}

	  	itemDef
	  	{
	  		name			Deposit
	  		text			"Deposit"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			175 150
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "deposit";
				close "atm_menu";
			}
		}

	  	itemDef
	  	{
	  		name			Transact
	  		text			"Transact"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			325 150
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "transact";
				close "atm_menu";
			}
		}

	  	itemDef
	  	{
	  		name			50
	  		text			"50"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			125 200
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "50";
			}
		}

	  	itemDef
	  	{
	  		name			100
	  		text			"100"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			225 200
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "100";
			}
		}

	  	itemDef
	  	{
	  		name			500
	  		text			"500"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			325 200
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "500";
			}
		}

	  	itemDef
	  	{
	  		name			1000
	  		text			"1000"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			425 200
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "1000";
			}
		}

	  	itemDef
	  	{
	  		name			close
	  		text			"close"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			425 250
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "close";
				close "atm_menu";
			}
		}

	  	itemDef
	  	{
	  		name			clear
	  		text			"clear"
	  		type			ITEM_TYPE_BUTTON
	  		textscale		TEXTSIZE_DEFAULT
	  		style			WINDOW_STYLE_FILLED
	  		textfont		UI_FONT_NORMAL
	  		rect			0 0 128 24
			origin			125 250
	  		textalign		ITEM_ALIGN_MIDDLE_CENTER
	  		forecolor		COLOR_UNFOCUSED
	  		visible			1
	  		onFocus
	  		{
	  			play "mouse_over";
	  		}
	  		action
			{
				scriptMenuResponse "clear";
			}
		}
	}
}

[edit] Zone Source

In nazi_zombie_yourmapname_patch.csv located in CODWAW/Zone_source

// menu,
menufile,ui/hud.txt
menufile,ui/scriptmenus/atm_menu.menu

[edit] Compiling