Mafia Scene - Mafia I & II Game Fan Site

Modders Corner => Mafia Editing => Mafia II mods => Topic started by: Kmeto on February 18, 2013, 05:07:27 PM

Title: LUA script (Entity)
Post by: Kmeto on February 18, 2013, 05:07:27 PM
Hello. I've got problem. I want to make LUA script to add NPCs, but it looks like it's not working. Can somebody please help?


 




Here's my script (to add Bomber in front of Vito's Villa):







<pre class="ipsCode">game.sds:ActivateStreamMapLine("fr_bomber_m01_load")



game.entitywrapper:GetEntityByName("enemy1"):Activate()

game.entitywrapper:GetEntityByName("enemy1"):SetPos(Math:newVector( -1315, 1005,-19))

game.entitywrapper:GetEntityByName("enemy1"):SetDir(Math:newVector( 0,-1,0))

game.entitywrapper:GetEntityByName("enemy1"):InventoryAddWeapon(5,92)

game.entitywrapper:GetEntityByName("enemy1"):Attack(game.game:GetActivePlayer())</pre>
Title: LUA script (Entity)
Post by: hahalala on February 18, 2013, 06:31:40 PM
Sorry, i canôt help you. I even tried scripting myself but run into trouble sometimes, but i would like to use this lua script if you get it working  <img src="/wp-content/uploads/invision_emoticons/smile.png" alt="(//smile.gif)" data-emoticon="" srcset="/wp-content/uploads/invision_emoticons/smile@2x.png 2x" width="20" height="20">
Title: LUA script (Entity)
Post by: Kmeto on February 18, 2013, 06:52:40 PM
QuoteSorry' date=' i canôt help you. I even tried scripting myself but run into trouble sometimes, but i would like to use this lua script if you get it working  <img src="/wp-content/uploads/invision_emoticons/smile.png" alt="(//smile.gif)" data-emoticon="" srcset="/wp-content/uploads/invision_emoticons/smile@2x.png 2x" width="20" height="20"> [/quote'] 




Use it If you want to. I think what I wrote is absolutely wrong, but maybe I just did small mistake somewhere.


Title: LUA script (Entity)
Post by: eXistenZ34 on February 26, 2013, 02:32:27 AM
It is normal that it does not work.




in your script, all command is activated directly. one after the other but very quickly.


 




But StreamMapLine activation requires some time to be fully activated before activation NPC.


 




test this : NPC activation is effected three seconds after







Quotegame.sds:ActivateStreamMapLine("fr_bomber_m01_load") 




DelayBuffer:Insert(function(l_1_0)




game.entitywrapper:GetEntityByName("enemy1"):Activate()




game.entitywrapper:GetEntityByName("enemy1"):SetPos(Math:newVector( -1315, 1005,-19))




game.entitywrapper:GetEntityByName("enemy1"):SetDir(Math:newVector( 0,-1,0))




game.entitywrapper:GetEntityByName("enemy1"):InventoryAddWeapon(5,92)




game.entitywrapper:GetEntityByName("enemy1"):Attack(game.game:GetActivePlayer())




end,{l_1_0},3000,1,false)


Title: LUA script (Entity)
Post by: Kmeto on February 26, 2013, 07:42:45 PM
Many many thanks. Now I understand how it works, but there is still a problem with my Lua Script injector (I've got version v6). This script crashes 3 seconds after activation. Maybe the scripts needs more time to load or something.
Title: LUA script (Entity)
Post by: eXistenZ34 on February 27, 2013, 12:58:59 AM
test this


 







QuoteDelayBuffer:Insert(function(l_1_0)

CommandBuffer:Insert(l_1_0,{




function(l_1_0)return game.sds:ActivateStreamMapLine("fr_bomber_m01_load")end,




function(l_2_0)




game.entitywrapper:GetEntityByName("enemy1"):Activate()




game.entitywrapper:GetEntityByName("enemy1"):SetPos(Math:newVector(-1315, 1005,-19))




game.entitywrapper:GetEntityByName("enemy1"):SetDir(Math:newVector( 0,-1,0))




game.entitywrapper:GetEntityByName("enemy1"):InventoryAddWeapon(5,92)




game.entitywrapper:GetEntityByName("enemy1"):Attack(game.game:GetActivePlayer())




end})




end,{l_1_0},100,1,false)



 




one thing, the injector has not been improved since December 2010.
Title: LUA script (Entity)
Post by: Kmeto on March 01, 2013, 04:39:51 PM
It's not working. The problem has to be somewhere else. Is that script working in FR JA v3.0?
Title: LUA script (Entity)
Post by: eXistenZ34 on March 01, 2013, 09:26:00 PM
look at this topic and especially its title.




//viewtopic.php?f=22&t=10363
Title: LUA script (Entity)
Post by: Kmeto on March 02, 2013, 11:57:52 AM
Ok, so this is not working in FR JA?  Is there any other way how to add entities (NPCs) to FR JA 3.0? I think the problem might be in file size limitation.
Title: LUA script (Entity)
Post by: Kmeto on March 02, 2013, 02:08:56 PM
I found something in your post (http]):


 







 (//forums/22/3262?start=15)
Quotezahar999 




it's really, really good.


 




I found the solution
 and it works for FR M2 & FR JA and with all images in the folders "gui" of M2, JV, BJ & JA


 




- levelx_xx





- paintingxx





- pinupxx





- pinupxx
_ps




- posterxx





- wantedxxx
_ps




- xx
_ja




- ja_pinupxx





- xx
_rtr


 




and I also found the solution has




[url=http://www.imagebam.com/image/7f3cd8171328466:3v017m5f](//thumbnails37.imagebam.com/17133/7f3cd8171328466.jpg&key=cc863b6f9440e4037b9710e6be5032993a4ba8b8fc93dc98e7440050a9321564)[/url] [url=http://www.imagebam.com/image/1461e2171328477:3v017m5f](//thumbnails39.imagebam.com/17133/1461e2171328477.jpg&key=8cf3d150c75942b72a7ae4fac4d84aaf9cddefbb51c07edea5fa909e5af8ced6)[/url]




entities are loaded with "StreamMapLine" but not activated.


 




I prepare a new topic for tomorrow, As with Icons.


 




and a surprise : a small script for the Cathouse using the command "ShowQuestDialog", with 93 entity activated, only with injector.
 (just activated)



 




How is it possible to add NPC?
Title: LUA script (Entity)
Post by: eXistenZ34 on March 07, 2013, 01:57:06 PM
you can not add like that NPCs in FR.


 




"StreamMapLine" : These commands are used to enable different chapter and sub-chapter of the game or DLC.




but after you are no longer in the FR. it is not that simple, to use it.