News: Welcome back to Bullworth! If you haven't already, you will need to reset your password..


Author Topic: Custom missions.  (Read 6221 times)

0 Members and 1 Guest are viewing this topic.

Elitecake

  • Guest
Custom missions.
« on: June 09, 2015, 05:02:09 PM »
Hello. Does anyone know any tutorials on to make custom missions, or have a basic program?
If not,  I would appreciate if you could make one ^^

Offline AfterLife

  • The Reaper
  • Sr. Member
  • ***
  • Posts: 830
  • Gender: Male
  • I'm from the AfterLife...
    • View Profile
Re: Custom missions.
« Reply #1 on: June 09, 2015, 08:49:21 PM »
Use LUA.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom missions.
« Reply #2 on: June 09, 2015, 11:29:01 PM »
I've released 2 open source missions before. I've been told my scripts aren't always easy to read, but you can try if you want.
The Cure 1 and 2.

First I suggest you learn LUA and get a basic understanding of it, make sure you can at least make some simple mods like spawning and recruiting bodyguards for example. SWEGTA has some tutorials to get you started a little bit. He has a topic here but his tutorials don't cover much, but I personally think it's an okay first step as you can get your first mod working, then learn what all the code you wrote meant and how it works. C00ld0c has a simple text tutorial of some LUA here, or if you're patient enough to read through all of mine I think I made a pretty solid one that covers a lot more than the others here, but it may be a bit confusing too.

Bully uses LUA 5.0.2 (well, a modified version of it, so we have to use this compiler made by Fred Tetra to compile code). You can find a full manual of LUA 5.0 here, but note that it may not all be supported by Bully's version.

You won't need to master LUA to make some custom missions, but make sure you at least can make some basic mods and understand entirely how the scripts you make work before moving on.


After you get the basic understanding of LUA, you may be able to better understand the missions I linked above and learn from them too.
Basically what a mission is... is it's just a script with objectives. It's just like any other script really. We just need something to pause the script from getting to the next part of the mission until a certain objective is completed, which is a very simple concept really.

Code: [Select]
function main()
  TextPrintString("Kill Gary",1,1)
  local enemy = PedCreateXYZ(130,270,-110,6)
  PedAttackPlayer(enemy,3)
  repeat
    Wait(0)
  until PedIsDead(enemy)
  TextPrintString("Go to the waypoint",1,1)
  BlipAddXYZ(280,-110,6,0)
  repeat
    Wait(0)
  until PedIsInAreaXYZ(gPlayer,280,-110,6,3)
end

There's a super simple example. Spawn a ped, show on screen what the player should do, then repeatedly wait (this prevents the script from getting to the next part of the script) until Gary is dead. The repeat loop won't end until Gary is dead, and only then will the script get to the next part of the code, which is the 2nd objective, which is to go to some place.

Really that's all you have to do. Just make a bunch of objectives and well that's a mission!

For your mission though you'll probably need a lot of coordinates. Enemy spawns, waypoints, camera coordinates for cut-scenes, etc.
I haven't been able to write to files to save coordinates, but you can use steam or something similar to take screenshots of a mod that shows coordinates on-screen, then put those screenshots next to notepad++ and write them in. Use my coordinate grabber to get player, ped, or camera coordinates. Read the readme.txt for important info.

You can also add me on steam if you have any questions.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Custom missions.
« Reply #3 on: June 10, 2015, 07:36:37 AM »
^ Very informative.

Learning LUA itself is a big step before creating your own mods. You want to memorize a lot of stuff so you can make your own mods without trouble. For some people it takes a long time, others its fast. There are a lot of tutorials here, and in SWEGTA's Tutorial Corner. Obviously the tutorial section too. There are other tutorials for specific things.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #4 on: July 06, 2015, 09:18:58 AM »
Making custom missions eh? I am releasing a script with some basic scripts that should help in mission making. Since I have the most knowledge in this field I will help out.

Well with making a mission it is an objective type of script but their is more to it then just simple objectives their is always certain functions that play in the background to make the peds do certain things like running,climbing,jumping,using a special attack or alla sorts of things.

Like Daboss's script the very first thing is the simple script but a function is this which I always thought functions were the scripts themselves until I noticed the DodgeCondition and FightCondition functions which make Derby in his boss fight dodge and use the super uppercut.

Another function is something like Davis's barrel climb or his run to the Autoshop garage. It's pretty simple just set this to run on a thread which a thread can simply be put anywhere inside the script accept inside the main's repeat function because it is already repeating itself.

Something like
Code: [Select]
CreateThread("main2")
Code: [Select]
main2 = function()
F_StartSimpleRun()
end

F_StartSimpleRun = function()
if PedIsValid(enemy) and l_17_0 == false then
PedSetInvulnerable(enemy,true)
PedMoveToXYZ(enemy,speed,X,Y,Z)
l_17_0 = true
end

Code: [Select]
function main()
  CreateThread("main2")
  l_17_0 = false
  TextPrintString("Kill Gary",1,1)
  local enemy = PedCreateXYZ(130,270,-110,6)
  PedAttackPlayer(enemy,3)
  repeat
    Wait(0)
  until PedIsDead(enemy)
  TextPrintString("Go to the waypoint",1,1)
  BlipAddXYZ(280,-110,6,0)
  repeat
    Wait(0)
  until PedIsInAreaXYZ(gPlayer,280,-110,6,3)
end
« Last Edit: July 06, 2015, 09:35:17 AM by LostInSpace »

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom missions.
« Reply #5 on: July 06, 2015, 06:41:25 PM »
^ LostInSpace: In your code above, there is really no point for that to run in it's own thread since it only runs one time... you don't have any loops in it. The way you have it, it'll only check if he is dead once. Just because it runs on a separate thread does not mean it will run repeatedly. The function "CreateThread" just creates a new thread, and the function specified runs one time on that new thread.

About functions as LostInSpace mentioned.... you should definitely understand functions before trying to make a mission, because functions are a very basic part of LUA's language. Bully defines a large set of functions that you can use, and you're also able to make your own. For an ArcRace1 script, you need to define 2 functions yourself and optionally 3. MissionSetup and main. MissionSetup runs first, then main. MissionCleanup is optional and will run when the script is terminated.

Threads are useful, but don't over use them when it's not needed.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #6 on: July 06, 2015, 07:51:35 PM »
Good tip I didn't fully complete it sorry but basically what I was explaining is not the function like missionsetup but more along the lines of characters doing certain instances. Like I said above maybe making Davis run around the school it is completely easy.

CreateThread("main3")

main3 = fuction()
repeat
F_ChaseAroundSchool()
until Player not Alive
end

F_ChaseAroundSchool = function
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end

main4 = fuction()
repeat
F_ChaseAroundSchoo2()
until Player not Alive
end

F_ChaseAroundSchool = function
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end

Running this will make the ped run wherever you want him to back and fourth. I am currently working on much longer functions like making a ped run the whole map and be fully aware of the player on its own.


Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom missions.
« Reply #7 on: July 06, 2015, 09:08:27 PM »
Actually, that code will crash the game.

Quote
repeat
F_ChaseAroundSchool()
until Player not Alive

You have a loop without any calls to the Wait function which will crash the game. I explained this problem here.

Yes, there are many functions to make peds to certain things, these are the functions Bully provides for us and they are our only way to interact with the game in our scripts so they are quite important.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #8 on: July 06, 2015, 11:39:36 PM »
Actually, that code will crash the game.

Quote
repeat
F_ChaseAroundSchool()
until Player not Alive

You have a loop without any calls to the Wait function which will crash the game. I explained this problem here.

Yes, there are many functions to make peds to certain things, these are the functions Bully provides for us and they are our only way to interact with the game in our scripts so they are quite important.

Lol I am on a phone and can't remember everything.

Offline Unknownsoldier

  • Hero Member
  • ****
  • Posts: 2,773
    • View Profile
Re: Custom missions.
« Reply #9 on: July 07, 2015, 01:44:36 PM »
Good tip I didn't fully complete it sorry but basically what I was explaining is not the function like missionsetup but more along the lines of characters doing certain instances. Like I said above maybe making Davis run around the school it is completely easy.

CreateThread("main3")

main3 = fuction()
repeat
F_ChaseAroundSchool()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end

main4 = fuction()
repeat
F_ChaseAroundSchoo2()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end

Running this will make the ped run wherever you want him to back and fourth. I am currently working on much longer functions like making a ped run the whole map and be fully aware of the player on its own.

main3 = fuction()

Lol I dunno what this code is supposed to do, but here is your script just fixed a lil:
CreateThread("main3")
CreateThread("main4")

main3 = function()
repeat
F_ChaseAroundSchool()
until Player not Alive
end

F_ChaseAroundSchool = function
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end
end

main4 = function()
repeat
F_ChaseAroundSchool2()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end
end


Likely wont work, but it is fixed on some mistakes lol.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom missions.
« Reply #10 on: July 07, 2015, 03:30:38 PM »
^ Still forgot the wait, all threads need to wait or the game won't run as I explained in that topic I linked earlier.

I don't think we're really helping them anyways.... they don't seem like they stayed on the board even. shit. Or they at least aren't replying to this one.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #11 on: July 07, 2015, 03:57:51 PM »
I cant put everything in I am on a phone. I will finish it when I am on my laptop.

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #12 on: July 08, 2015, 04:28:40 PM »
Good tip I didn't fully complete it sorry but basically what I was explaining is not the function like missionsetup but more along the lines of characters doing certain instances. Like I said above maybe making Davis run around the school it is completely easy.

CreateThread("main3")

main3 = fuction()
repeat
F_ChaseAroundSchool()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end

main4 = fuction()
repeat
F_ChaseAroundSchoo2()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end

Running this will make the ped run wherever you want him to back and fourth. I am currently working on much longer functions like making a ped run the whole map and be fully aware of the player on its own.

main3 = fuction()

Lol I dunno what this code is supposed to do, but here is your script just fixed a lil:
CreateThread("main3")
CreateThread("main4")

main3 = function()
repeat
F_ChaseAroundSchool()
until Player not Alive
end

F_ChaseAroundSchool = function
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end
end

main4 = function()
repeat
F_ChaseAroundSchool2()
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end
end


Likely wont work, but it is fixed on some mistakes lol.

CreateThread("main3")
CreateThread("main4")

main3 = function()
repeat
F_ChaseAroundSchool()
Wait(0)
until Player not Alive
end

F_ChaseAroundSchool = function
if PedIsValid(enemy) and l_17_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_17_0 = true
l_18_0 = false
end
end

main4 = function()
repeat
F_ChaseAroundSchool2()
Wait(0)
until Player not Alive
end

F_ChaseAroundSchool = function()
if PedIsValid(enemy) and l_18_0 == false then
PedMoveToXYZ(Ped,Speed,X,Y,Z)
l_18_0 = true
l_17_0 = false
end

Now it should actually work and I am on a pc finally either way I did actually get it to work and it just makes a ped run from the school to the autoshop using coord's from the school to the autoshop. If I am in a certain rectangle and the pedisvalid and the false is false then it usually makes the ped run back and fourth.

Offline DaBOSS54320

  • Hero Member
  • ****
  • Posts: 3,398
  • Gender: Female
    • View Profile
Re: Custom missions.
« Reply #13 on: July 08, 2015, 04:37:51 PM »
Why use such cryptic variable names?

You do not need to name your variables l_#_#, they are only like that in decompiled scripts because the decompiler cannot get the names used for local variables without the source, so it generates a name like l_#_# standing for "local".

Name your variables something related to what they do, it doesn't help to use variable names like l_0_0.

A variable name can be whatever you like as long as it starts with a letter character, and contains only letters, numbers, or underscores after that. (and some other symbols but, you should probably just stick with that).

Also in your code, Player isn't defined. Maybe you meant gPlayer? But even if you did that wouldn't be valid code... maybe you should just omit Player completely and just leave not Alive since Alive is just a variable. I personally prefer to use not PedIsDead(gPlayer) though, has worked better in my experience.
« Last Edit: July 08, 2015, 04:40:08 PM by DaBOSS54320 »

Offline AlphaTech

  • LostInSpace
  • Sr. Member
  • ***
  • Posts: 758
  • Gender: Male
  • The name's AlphaTECH, whatca need help with?! :)
    • View Profile
Re: Custom missions.
« Reply #14 on: July 08, 2015, 06:28:10 PM »
Okay but I still got the code working regardless. Using not Alive is my usual speed way of doing fast scripts and it still works great. For the local variable I usually use those types for spawn coords or fast variable's if I actually have time I define them. Usually doing any type of variable does not make it work better doesn't matter. For spawn coords or false I usually use l_#_# as examples.