FAQFAQ    Board RulesBoard Rules    SearchSearch    LotteryLottery    RouletteRoulette    UsergroupsUsergroups
     RegisterRegister  ProfileProfile    Log in to check your private messagesLog in to check your private messages    Shop    Log inLog in 
View posts since last visit View your posts View unanswered posts

MAFIA 2 - a way to import modded objects into the scene
Goto page Previous  1, 2, 3, 4  Next
 
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Mafia Mods
View previous topic :: View next topic  
Author Message
osaru

New Member
New Member


Joined: 09 Jul 2016
Posts: 16

32 Bank Notes
Items

PostPosted: Fri Mar 16, 2018 12:35 am    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

I created a script that makes it possible for the player to enter the car from a distance. First you have to press the function that is aligned with the .lua file(F1 - F12) that this script is within. Then, you would have to press the "Y" key when you are inside a car. You can later press the "T" key which will teleport the player inside the car, regardless of the distance.


To enter any car from a distance

player = game.game:GetActivePlayer()

Joe = player:GetOwner()

DelayBuffer:Insert(function(_ARG_0_)
bindKey ("Y", "Vito = game.game Vitocar = Vito:GetActivePlayer():GetOwner()")
end,{_ARG_0_},500,1,false)





ply = game.game:GetActivePlayer()


DelayBuffer:Insert(function(_ARG_0_)
bindKey ("T", "DelayBuffer:Insert(function(l_1_0)CommandBuffer:Insert(l_6_0,{function(l_1_0)return ply:SetControlStyle(enums.ControlStyle.LOCKED)end,function(l_2_0)return ply:GetInOutCar(Vitocar, 1, false, false)end,function(l_3_0)return ply:SetControlStyle(enums.ControlStyle.FREE)end})end,{l_1_0},500,1,false)")
end,{_ARG_0_},500,1,false)
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Sat Mar 17, 2018 4:13 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

osaru thank you for helping me. Unfortunately this script doesn't seem to work for me. :/
Back to top
View user's profile Send private message
osaru

New Member
New Member


Joined: 09 Jul 2016
Posts: 16

32 Bank Notes
Items

PostPosted: Sat Mar 17, 2018 6:36 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

I think I might know why it does not work for you. It is probably because of Y.u.s.i.k's trainer. The trainer may not be able to activate bindKey functions.

To ensure that it activates bindKey functions, test this script in the trainer.

Vitocar = Vito:GetOwner()

bindKey ("X", "Vitocar:SetSpeed(300)")

Obviously, you would need to press the "X" key activate the script. That is after you press the function key that corresponds with the .lua file that the script is within. Unless you are not using an injector. I just realized that it was unnecessary for me to give you such information. Since you are not using an injector, a function key is not needed. You would only need to press a button on the trainer to activate scripts - since you are using a trainer to activate scripts.

Last edited by osaru on Sun Mar 18, 2018 12:23 am; edited 1 time in total
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Sat Mar 17, 2018 6:40 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

UPDATE


I worked a bit on it and I have new scripts that you can use.

The main script to spawn the entity has changed a bit, now the object should be more stable right from the start.

DelayBuffer:Insert(function(l_1_0) CommandBuffer:Insert(l_1_0,{
function(l_2_0)return game.sds:ActivateStreamMapLine( "game_main_load")end,
function(l_3_0) player, V = game.game:GetActivePlayer(), game.entitywrapper
auticko = V:GetEntityByName("Car_Entity_01")
auticko:Activate()
auticko:RepairAndClear()
carPos = Math:newVector()
carPos:set(413.179,-317.481,-20.297)
auticko:SetPos(carPos)
carDir = Math:newVector()
carDir:set(1.000, 0.008,0.000)
auticko:SetDir(carDir)
auticko:Lock()
auticko:SetPos(carPos)
auticko:SetDir(carDir)
auticko:Lock()
end})end,{l_1_0},100,1,false)

And also now you can spawn more than just one entity at a time.

An example (this script spawns firstly Car_Entity_01 and then afterwards Car_Entity_02):

DelayBuffer:Insert(function(l_1_0) CommandBuffer:Insert(l_1_0,{
function(l_2_0)return game.sds:ActivateStreamMapLine( "game_main_load")end,
function(l_3_0) player, V = game.game:GetActivePlayer(), game.entitywrapper
auticko = V:GetEntityByName("Car_Entity_01")
auticko:Activate()
auticko:RepairAndClear()
carPos = Math:newVector()
carPos:set(-1567.367,-269.247,-20.333)
auticko:SetPos(carPos)
carDir = Math:newVector()
carDir:set(0.023,1.000,0.000)
auticko:SetDir(carDir)
auticko:Lock()
auticko:SetPos(carPos)
auticko:SetDir(carDir)
auticko:Lock()
end,

function(l_4_0) player, V = game.game:GetActivePlayer(), game.entitywrapper
trava = V:GetEntityByName("Car_Entity_02")
trava:Activate()
trava:RepairAndClear()
travaPos = Math:newVector()
travaPos:set(-1617.704,-2320.606,-17.394)
trava:SetPos(travaPos)
travaDir = Math:newVector()
travaDir:set(0.023,1.000,0.000)
trava:SetDir(travaDir)
trava:Lock()
trava:SetPos(travaPos)
trava:SetDir(travaDir)
trava:Lock()
end})end,{l_1_0},100,1,false)

And while doing that I decided to write a simply script that teleports the player to certain coordinates, you can make use of it too.

v = game.game:GetActivePlayer():GetPos()
lol = Math:newVector()
lol:set(-1567.367,-269.247,-20.333)
game.game:GetActivePlayer():SetPos(lol)

And the last thing I'd like to share with you is a script that tells you at which coordinates an entity is.

function loginf(log_text)log_text=".) "..log_text.."\n"
f=assert(io.open("coords.txt", "a+"))
f:write(i,log_text)
io.close(f)
end

autickoPos = V:GetEntityByName("Car_Entity_01"):GetPos()
autickoDir = V:GetEntityByName("Car_Entity_01"):GetDir()

if i==nil then i=0 end
i=i+1
loginf(autickoPos.x..", "..autickoPos.y..", "..autickoPos.z)
loginf(autickoDir.x..", "..autickoDir.y..", "..autickoDir.z)

The information will be saved in Mafia 2/pc/coords.txt

*you need to play the game as administrator in order to make the script work.
Back to top
View user's profile Send private message
osaru

New Member
New Member


Joined: 09 Jul 2016
Posts: 16

32 Bank Notes
Items

PostPosted: Sun Mar 18, 2018 12:34 am    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

The script below should be of no use for those who use Y.u.s.i.k's trainer:


function loginf(log_text)log_text=".) "..log_text.."\n"
f=assert(io.open("coords.txt", "a+"))
f:write(i,log_text)
io.close(f)
end

autickoPos = V:GetEntityByName("Car_Entity_01"):GetPos()
autickoDir = V:GetEntityByName("Car_Entity_01"):GetDir()

if i==nil then i=0 end
i=i+1
loginf(autickoPos.x..", "..autickoPos.y..", "..autickoPos.z)
loginf(autickoDir.x..", "..autickoDir.y..", "..autickoDir.z)

The trainer has the player's current position and direction listed on a window that is labeled as "Main". I tested the coordinates and they correspond to that in Lua coding.
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Sun Mar 18, 2018 11:14 am    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

Osaru:

That is true but we also need current coordinates of spawned entities for our purposes. Once an entity has been spawned it can be moved (using the F1-F6 scripts that I posted) and when it has been moved its coordinates change.

The trainer doesn't show coordinates of entities, only the player's ones.
Back to top
View user's profile Send private message
osaru

New Member
New Member


Joined: 09 Jul 2016
Posts: 16

32 Bank Notes
Items

PostPosted: Sun Mar 18, 2018 1:03 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

Oh, okay.

Anyway, be sure to test the trainer's abilities. Can it activate scripts that are under a bindKey function? Test this script:

Vito = game.game:GetActivePlayer()

Vitocar = Vito:GetOwner()

bindKey ("X", "Vitocar:SetSpeed(300)")
Back to top
View user's profile Send private message
agens

New Member
New Member


Joined: 29 Apr 2016
Posts: 13

29 Bank Notes
Items

PostPosted: Mon Mar 19, 2018 7:44 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

[video width=1280 height=720]https://www.youtube.com/watch?v=wLZ205sW6og&t=122s[/video]
Back to top
View user's profile Send private message
agens

New Member
New Member


Joined: 29 Apr 2016
Posts: 13

29 Bank Notes
Items

PostPosted: Mon Mar 19, 2018 7:48 pm    Post subject: Re: MAFIA 2 - a way to import modded objects into the scene Reply with quote

Back to top
View user's profile Send private message
Jaqub

Junior Member
Junior Member


Joined: 12 Dec 2017
Posts: 53
Location: idk
2 Bank Notes
Items

PostPosted: Mon Mar 19, 2018 8:49 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

I have no words to this anymore Confused Very happy Shocked
This is the greatest breakout in m2 modding...

I obviously should have removed these grey barriers leftovers in 3ds max but I thought you would notice them and remove them urself xD
_________________

Back to top
View user's profile Send private message Visit poster's website
AMadeMan

Member
Member


Joined: 23 May 2017
Posts: 239
Location: United States
339 Bank Notes
Items

PostPosted: Mon Mar 19, 2018 9:03 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

I..

I just..

I don't know what to say. Shocked

All i can say is, YOU sir, Just made Mafia history. You did it.

Your work will lead to a new era of Mafia 2 modding. I'm both honored and proud to see this day come.

Please accept my most heartfelt congratulations brother. Salute Applause

A bridge from empire bay to Lost Heaven. wow..
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Tue Mar 20, 2018 12:29 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

Thank you both for your praising, whoever you were praising anyway, , it is unfortunately still impossible to convert the map fully with collisions at this point.

The biggest problem with collisions is the fact that you can use only one collision per a model.

I had an idea of a workaround that I shared with agens, but converting a map following this procedure may be pain in the ass, especially if the map is big, but with patience it may possible to convert the racing track, which is not that big:


"Ungroupe all the parts of the object and make a collision for only one part (do not move this part so that its coordinators remain the same) and delete the remaining parts and export. Make one add-on of this.

Then do the same thing with the rest of the parts - choose one, make a collision for it and remove the rest. Make another add-on.

Then do the same thing again and again until you have done all the parts.

Then send me all the add-ons and I'll write a script in which each add-on will be spawned in the same coordinates. This way it is possible to load a map with collisions."


Though it is not tested and may not work. But the best I have come up with so far.

Jaqub: I'd like to express my graditude towards Jaqub, who helped this project move by sharing his models of Lost Heaven. *Those converted directly from the game didn't work.

osaru: The script unfortunately didn't work and the trainer says that the line with the bindKey... is invalid - a nil value.

If you want to help, don't hesitate. It is important that all Mafia 2 fan modders come together to make a follow-through to this.

Somebody who can write a script for exporting maps for Mafia 2 for 3d max would come in handy. Also somebody who can encrypt the file called PREFAB_0.bin is needed.
Back to top
View user's profile Send private message
osaru

New Member
New Member


Joined: 09 Jul 2016
Posts: 16

32 Bank Notes
Items

PostPosted: Tue Mar 20, 2018 4:32 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

Yes I know the does not work, what I gave you was incomplete; a mistake I made.

This is the full script

Vito = game.game:GetActivePlayer()

Vitocar = Vito:GetOwner()

bindKey ("X", "Vitocar:SetSpeed(300)")

This script should work. Activate it when you are inside a car.
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Wed Mar 21, 2018 3:23 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

No, it doesn't seem to work.
Back to top
View user's profile Send private message
T3mas1

Member
Member


Joined: 11 Jul 2015
Posts: 138
Location: Czech Republic
318 Bank Notes
Items

PostPosted: Sun Mar 25, 2018 12:34 pm    Post subject: MAFIA 2 - a way to import modded objects into the scene Reply with quote

THE END OF THE ROAD?






agens has released another video in which he shows the countryside from Mafia 1 in Mafia 2 with shaders this time. He tried to put also collisions into the scene, but the collisions for some reason never worked as add-ons, which surprised me. Collisions were buggy and had holes in them.

To make you understand you can use only one given ORIGINAL collision per a model. Every model of a car in the game on which you build the map has three default collisions two of which don't work at all if changed. That leaves you just with one collision to use meaning you have to cut the countryside into small pieces, make a collision for each of them and then export them one by one and then you spawn them in the game one by one in order to have the map with collisions, but that didn't work for some reason.

Also bear in mind that the collision that you can use cannot be lenghtened or bended as far as possible - there are limitations that you need to take into consideration.

What we need is to be able to insert a new collision into a model. Possibly the file that is responsible for that action is PREFAB_0.bin located in pc/sds/cars/xxx.sds. Unfortunately there's no program for editing this file. If you can make a program for it, please do it.

However, the best way to go is to find somebody who can make Mafia 2 maps import/export in 3d max possible.

I've written to many people about this problem and asked them if they could do something about it - no response till this day and I am afraid it is going to stay this way. Sad

Things that have been proven:
- The map can be expanded as far as possible: there are no boundaries like in GTA V, as it seems.
- The game doesn't lag when big added objects are loaded.
- a model of a car can be as big as possible.

-Collisions are the only thing stopping us.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Mafiascene.com Forum Index -> Mafia Mods All times are GMT
Goto page Previous  1, 2, 3, 4  Next
Page 2 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

Generation Time: 0.041 | Queries: 18