megigames Posted August 28, 2011 Share Posted August 28, 2011 how would i go about making a first person shooter script with weapon pickup and interchangeable models for guns oh and if anyone knows how to make a reload that would be great also if you want to share a script so i can learn that'd be nice i also am willing to pay for scripts Quote Link to comment Share on other sites More sharing options...
Andr3wHur5t Posted August 28, 2011 Share Posted August 28, 2011 Are you talking about a lua script or c++ code? Quote Tools: AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro Programing & Scripting Languages: C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby Link to comment Share on other sites More sharing options...
megigames Posted August 28, 2011 Author Share Posted August 28, 2011 either or would be nice Quote Link to comment Share on other sites More sharing options...
Andr3wHur5t Posted August 28, 2011 Share Posted August 28, 2011 Leadweks comes with a lua script that dose some of the things you want; you should start there it is located in the ledwerks folder under scripts then games. reload is resonably simple you could do somthing like this: int iAmmoInClip = 20; int iClip = 2; int iAmmoPerClip = 20; //main loop while( !KeyHit(KEY_ESCAPE) ){ //Checking if we hit the Left mouse button and making sure we have ammo. if(MouseHit(1) && iAmmoInClip > 0){ //Place Shooting code Here iAmmoInClip --; } //if we are out of ammo in our clip auto reload if(iAmmoInClip <= 0 && iClip > 0 ){ iClip --; iAmmoInClip = iAmmoPerClip; } //if we Hit the R key and have a xtra clip reload if(KeyHit(KEY_R) && iClip > 0 ){ iClip --; iAmmoInClip = iAmmoPerClip; } } Quote Tools: AC3D | 3D Canvas(pro) | Texture Maker(pro) | Genetica(basic) | 3D World Studio | Fragmotion |Leadwerks 2 | XNA 4 | Visual Studio 2010 Professional | XCode 5.x |UU3D Pro Programing & Scripting Languages: C |C++ | C# | Obj-C | LUA | Javascript | PHP | Ruby Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted August 28, 2011 Share Posted August 28, 2011 Well.. I haven't done it before in leadwerks myself but the concept is the same for any engine. Sorry if none of this makes sense. I'm tired. Player: 1. Player Controller 2. Attach camera to controller 3. code the mouse movement to for rotating the camera 4. code the wasd to move the controller foreward /back left /right Shooting: 2-ways: -Raycasting <-- personally I don't like this way -Bullet Body 1. On click -> create bullet with a body at the gun nozel 2. Apply velocity to the bullet body in the same direction as the camera is facing (or gun) Reloading: <-- On press 'R' 2. Check that ammo is not full 3. If not check how much ammo you need to fill the magazine (eg. cartridge size of 8 with only 3 bullets left = 8-3 = 5 bullets needed) 4. If the ammo you have in your 'pocket' is greater than 5 (what you need to fill the magazine. : Play Reload animation |||| cartridge ammo = 8, ||| ammo = ammo -5 ||| 5. else if the ammo you have in your pocket is less than 5 but more than 0 (say 3 ) : Play Reload animation |||cartridge ammo = cartridge ammo + ammo ||| ammo =0 (resulting in cartridge ammo being 6 and total ammo 0 6. else if the ammo you have in your pocket is 0 : notify the player that they cannot reload . simple Ammo Pickups:/u] These are really simple you just detect a collision between ammo box and player, get the entity from that and add the ammo to your stash according to what you collided with. Interchangable Weapons IDK how everyone else does it but I figured out a way in the last engine I was using. The idea should still work here. first I made a bunch of arrays that held all the stats for all of the weapons. It looked something like this. (This is just psuedo btw) std::string WeaponName["Colt 45", "Socom", "FAMAS", "12 Guage"]; std::string WeaponModel["Colt.gmf", "Socom.gmf", "FAMAS.gmf", "12 Guage.gmf"]; int WeaponRange[ 45, 50, 200, 25 ]; std::string WeaponDamage etc etc etc etc etc etc Then I made an integer variable called 'currentWeapon' which started at 0. When you press the button to switch weapon the currentWeapon variable changes and and loads the stats of the corresponding gun in the array. EG. currentWeapon = 2 would be the FAMAS & currentWeapon = 0 would be the Colt 45. Anyway this was just some stupid method I came up with dunno if its technically the correct way to do it but it works. Everything here can be found in the existing tutorials on the wiki. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
cassius Posted August 28, 2011 Share Posted August 28, 2011 How do you tell the bullet to go in the direction the camera is facing? Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
megigames Posted August 28, 2011 Author Share Posted August 28, 2011 hmm interesting i'll try this out Quote Link to comment Share on other sites More sharing options...
Road Kill Kenny Posted August 29, 2011 Share Posted August 29, 2011 How do you tell the bullet to go in the direction the camera is facing? Anyway you want. Line pick raycast comes to mind. Then just get the position of the collision and move the bullet from the guns to the position that the raycast hit. Yeh the way I said the camera facing direction wasn't technically correct but I wrote that In a rush so yeh rather get the position of to propell towards using a raycast. Quote STS - Scarlet Thread Studios AKA: Engineer Ken Fact: Game Development is hard... very bloody hard.. If you are not prepared to accept that.. Please give up now! Link to comment Share on other sites More sharing options...
YouGroove Posted August 30, 2011 Share Posted August 30, 2011 Thre is the "LESoldierEntityAndGame" script that you can find in the asset store, that contains lot of usefull stuff. I just found it today, and it really contains all Lua stuff for begin some gameplay and entities management ! For FPS and all stuff i don't have any idea unfortunately ! Quote Stop toying and make games Link to comment Share on other sites More sharing options...
megigames Posted September 4, 2011 Author Share Posted September 4, 2011 lesoldierentityandgame does not work with latest leadwerks i really need to hire a lua programmer :/ all i know how to do is print (i suck at lua) Quote Link to comment Share on other sites More sharing options...
YouGroove Posted September 5, 2011 Share Posted September 5, 2011 Really Lua is so easy and fast to use , you should try it a little perhaps. Just follow tutorials for Lua. Quote Stop toying and make games Link to comment Share on other sites More sharing options...
dennis Posted October 4, 2011 Share Posted October 4, 2011 I modified the character controller which is provided by LE Engine. it's LUA coded. and I made it an function. so it could be loaded very easy in my scene loader. if you like to I can give you the full code it's quite working and great to use Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.