More,More,More! :D

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

More,More,More! :D

Post by metal_head » Sun Sep 07, 2008 4:12 pm

In my game I want a lot of weapons,but the game has only 9 slots :( Is there a way of putting more weapon slots in the game and can the weapon system be made for example,when I press 1,a pistol to show up,thn if I pres 1 again,the pistol changes to another weapon.I want to double the slots,so in every slot I want two weapons,which can be changed by pressing the slot key.Unreal Tournament has that (UT again :D man I got to stop thinking about this game ).

elnawe
Posts: 5
Joined: Sat Sep 06, 2008 10:12 pm

Re: More,More,More! :D

Post by elnawe » Sun Sep 07, 2008 6:59 pm

Max Paine has that weapon system too
If you press 2 you has a Beretta, but if you press 2 again you has 2 Berettas (Dual Berettas).

Dante
Posts: 21
Joined: Thu Jun 26, 2008 7:20 pm

Re: More,More,More! :D

Post by Dante » Sun Sep 07, 2008 8:41 pm

you could make an Ultra-realistic weapon system using the default one... which means that the player can only have 2 or 3 weapons in the same time. It would be, for example: a slot for rifles, another one for heavy weapons and explosives, and another one for guns... dont be affraid of putting various weapons in the same slot... the player will just have to throw the weapon before taking another!
There never was a good war or a bad peace.
-Benjamin Franklin

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: More,More,More! :D

Post by metal_head » Sun Sep 07, 2008 8:49 pm

yeah,I was thinking about that,but I want the player to have all the weapons available

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: More,More,More! :D

Post by metal_head » Fri Sep 12, 2008 11:48 pm

ssssssooooooo....does anyone have an idea of how this can be done?

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: More,More,More! :D

Post by Juutis » Fri Sep 12, 2008 11:54 pm

Yes. Come to the IRC channel and I'll tell you more. (See General Discussions)


Nah just joking. I'll try to think of a way to do it. It is possible, the question is how complex and flexible you want it to be. But coming to the IRC channel might speed the process up a bit. Yah, I'm a mean person blackmailing you guys but I want this IRC thing to work, no matter the consequences. :D
Pain is only psychological.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: More,More,More! :D

Post by metal_head » Sat Sep 13, 2008 12:29 am

I only use skype,man sorry (I don't know much about IRC though).
I don't want something complex,just I want to double the weapon slots,so I'll have more weapons in the game...but if that's a lot of work,than the 3 looting weapons system is good enough for me

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: More,More,More! :D

Post by Juutis » Sat Sep 13, 2008 2:55 pm

Ahh, finally a job that was worth doing. Call me crazy but I really enjoyed writing this.

Here ya go:

Code: Select all

{

GROUPS
{
	{
		KEY		[1]
		keypressed	[false]

		WEAPONS
		{
			{
				ATTRIBUTE	[c8]
				INDEX		[0]
			}
			{
				ATTRIBUTE	[scattergun]
				INDEX		[1]
			}
		}
	}

	{
		KEY	[2]
		keypressed	[false]

		WEAPONS
		{
			{
				ATTRIBUTE	[disklauncher]
				INDEX		[2]
			}
			{
				ATTRIBUTE	[sniper]
				INDEX		[3]
			}
			{
				ATTRIBUTE	[minigun]
				INDEX		[4]
			}
		}
	}
}


currentweapon	[0]
currentgroup	[0]



Spawn[ ()
{
	Console(false);

	LowLevel("setup");
} ]

setup[ ()
{
	PawnRender(false);

	think = "run";
} ]

run[ ()
{
	ThinkTime = 0;

	for i = 0 to GROUPS.numChildren
	{
		if(IsKeyDown(GROUPS[i].KEY))
		{
			if(GROUPS[i].keypressed = false)
			{
				GROUPS[i].keypressed = true;

				if(i != currentgroup)
				{
					currentgroup = i;
					currentweapon = 0;
				}
				else
				{
					currentweapon = currentweapon + 1;

					if(currentweapon > (GROUPS[i].WEAPONS.numChildren - 1))
					{
						currentweapon = 0;
					}
				}

				for j = 0 to GROUPS[i].WEAPONS.numChildren
				{
					if(GetAttribute(GROUPS[i].WEAPONS[currentweapon].ATTRIBUTE,"Player") > 0)
					{
						j = GROUPS[i].WEAPONS.numChildren - 1;
					}
					else
					{
						currentweapon = currentweapon + 1;

						if(currentweapon > (GROUPS[i].WEAPONS.numChildren - 1))
						{
							currentweapon = 0;
						}
					}
				}

				SetPlayerWeapon(GROUPS[currentgroup].WEAPONS[currentweapon].INDEX);
			}
		}
		else
		{
			GROUPS[i].keypressed = false;
		}
	}
} ]

}
Ya, it's pretty complex. So complex I don't even try to explain. The thing you need to know is how to use it. Basically, you only need to modify the GROUPS array. Each item in it is a group of weapons. These groups are the "categories" of weapons, and pressing a single key will cycle through these weapons. The KEY variable defines which key "activates" the group, and keypressed is nothing you have to worry about.

Each group has a WEAPONS array that holds the info about the weapons in that very group. Each item in that array is a weapon. Each weapon needs to have two variables: ATTRIBUTE and INDEX. ATTRIBUTE is the name of the weapon in weapon.ini and INDEX is the slot you give it in weapon.ini.

That may be a little hard to understand so I'll give an example:

Code: Select all

	{
		KEY		[1]
		keypressed	[false]

		WEAPONS
		{
			{
				ATTRIBUTE	[c8]
				INDEX		[0]
			}
			{
				ATTRIBUTE	[scattergun]
				INDEX		[1]
			}
		}
	}
That's a weapon category that is activated by pressing '1' on the keyboard. There are two weapons in it, the c8 and the scattergun. c8 would normally be armed with the key '1' (its in the slot 0 -> INDEX = 0) and scattergun with the key '2' (slot 1 -> INDEX = 1). But now if you press '1' it first arms the c8 and if you press it again it arms the scattergun. Hope you get it.

You can add as many weapons to a category as you want, and as many categories as you want. You can even have categories in the keyboard letters. The KEY doesn't have to be 0-9, it can be the keycode of any keyboard key or mouse key.


***EDIT***
Oh ya, and disable the controls for the original weapon arming system in control.ini.
Pain is only psychological.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: More,More,More! :D

Post by metal_head » Sat Sep 13, 2008 6:15 pm

I really don't know how to thank you for this! I alsmost understood everything (great explanation)
sooo...if I got it right,here in the script:

Code: Select all

KEY   [2]
      keypressed   [false]

      WEAPONS
      {
         {
            ATTRIBUTE   [disklauncher]
            INDEX      [2]
         }
         {
            ATTRIBUTE   [sniper]
            INDEX      [3]
         }
         {
            ATTRIBUTE   [minigun]
            INDEX      [4]
         }
      }
   }
}
by pressing the key 2,I can change between theese 3 weapons : sniper,minigun and disklauncher,right? And I can make as much weapons as I want to be changed by pressing the key 2 or 3 or 5 ..you get it :D
and that means,I can put as much weapons as I want,because in one slot,there can be 3 or 4 or 5 weapons,right? (well,I'll only put two max :) )

User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Re: More,More,More! :D

Post by Juutis » Sat Sep 13, 2008 6:24 pm

metal_head wrote:by pressing the key 2,I can change between theese 3 weapons : sniper,minigun and disklauncher,right? And I can make as much weapons as I want to be changed by pressing the key 2 or 3 or 5 ..you get it :D
and that means,I can put as much weapons as I want,because in one slot,there can be 3 or 4 or 5 weapons,right? (well,I'll only put two max :) )
Yes, exactly. :)
Pain is only psychological.

User avatar
metal_head
Posts: 1244
Joined: Sat Jan 05, 2008 8:31 pm
Location: Bulgaria,Sofia
Contact:

Re: More,More,More! :D

Post by metal_head » Sat Sep 13, 2008 6:40 pm

That's fantastic! I'll try it this evening! Just have to finnish merging a trooper model for my game first (merging,not modeling :D )

Post Reply