Operation Flashpoint Dragon Rising OFDR Forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

I have some questions to ask...

+2
TheGeneral
Morieza
6 posters

Page 1 of 3 1, 2, 3  Next

Go down

I have some questions to ask... Empty I have some questions to ask...

Post by runerback Mon 07 Jul 2014, 13:52

How did checkpoint or scriptcheckpoint works? I put mission variables and some functions which are expatiatory into secondary scripts, and when I restart game from lastest checkpoint, there will be a lot of mistakes.
MDDYM told me this issue can be resolved by save game to external files, like log.
So I want to know when the game get to checkpoint, what is happening? which contents are saved? and what is the current state of the game. 
This is what I want to know most.
If I write a function to save game to external files, what will be saved? And when read checkpoint from the external files, what should be read? Question 
Thanks.

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Mon 07 Jul 2014, 15:05

What happens is the game reallocates memory on a checkpoint load and you loose the memory reference of the pointers to functions on your secondary scripts. If you are pointing to a secondary script function, you have to place your pointer in onCreate() or if you are using the EDX you can use onEDXInitialized. I hope this helps. You asked me a question in your other thread that requires a lengthy explanation so I haven't taken the time to draft a reply yet. If you still need help with this, just let me know.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Mon 07 Jul 2014, 15:48

I'll show you some of my mission code, if there is something wrong, I hope you can give me some advise, thanks. Smile 
I put all events into level.lua, all function in fun.lua, some data to data.lua, and the last one is talk.lua which includes some feedback like enemydownfeedback. Maybe this form is redundant...

level.lua:
Code:
onCreate=function()
  F=scripts.mission.fun;
  D=scripts.mission.data;
  T=scripts.mission.talk;
end

onDeath=function(victim, killer, method)
  if OFP:getDistance(killer,victim)<=100 then
    T:enemyDownFeedback(victim, killer);
  else
    T:killFeedback(killer);
  end
  if victim=="player" then
    OFP:missionFailedKIA();
  end
end

onMissionStart=function()
  F:startAdd();
end

fun.lua:
Code:
onCreate=function()
  D=scripts.mission.data;
end

startAdd=function(self)
  math.randomseed(os.time());
  enableSpeech(nil);
  OFP:addTimer(D.timer["gametimer"][1],5000);--gamestart
  triggerInit(nil);
end

In data.lua, I put all table there.

talk.lua:
Code of others, I just borrow them...
Code:
function killFeedback(self,killer)
  if not allowSpeak or math.random(1,3) ==1 then
    return;
  elseif OFP:getDistance(killer,"player")<=50  then
    OFP:playNPCSpeech(killer,{kill_table[math.random(1,#kill_table)]});
    allowSpeak = false;
  end
end

Wherever I set checkpoint, the game will go to the wrong direction.

I also want to know what is right format, my mission code is always messy.

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Mon 07 Jul 2014, 21:34

This is simply not enough code to be able to diagnose the issue. Please post an mssn file so I can examine all of your code. Thanks  Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Tue 08 Jul 2014, 02:14

Oh I hate time difference...

download here:http://fbe.am/tvf

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Tue 08 Jul 2014, 05:36

OK... I had a chance to look over your code. There is a bit more code than I expected, but none the less, I went through it. After a quick analysis I wasn't able to detect any malformed functions or expressions. I did notice in the entirety of your code you used a single EDX function, so I'm assuming you are aware that you need to have installed the EDX for this function to work. If that is the case, you need to move everything from your level script into a new secondary script of whatever name you choose. In the EDX thread there is a module called the quickstart module that loads everything you need in the level script, but do not use it for your own code. The EDX "rewires" several of the event handlers to from the level script to the waypoints script so that they can be distributed across all secondary scripts.

I was unfortunately not able to run the mission due to differences between our entity databases. Thus, I was unable to actually see what is going wrong or run any kind of diagnostic functions. If you save your script as a table to an external file you will be able to see every variable and function that is in play on the script. Do this before you load a checkpoint and after and compare the 2 tables. If anything is getting lost in the checkpoint, you will be able to see it.

I would strongly suggest you attempt to organize your code into scripts by their functionality instead of by the type of object or function. For example, all of your speech tables and functions all on one script. All of your functions for your actual mission events on another. It is very difficult to debug the scripts in their current format because you can't even run a trace on a variable as you could if they were contained in the same scripts.

Please confirm that you are using the Editor Expansion. If I knew that for certain I could help you straighten out your code to a more readable format and show you some examples of how you can benefit from using it.

Let me know and I'll help as much as I can.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Tue 08 Jul 2014, 07:32

How to save script as a table? 
And, do you mean to put code into different secondary script by event? Such as "onTimer" or "onEnter".
Oh, I almost forgot... I download the EDX kit and covered corresponding files. But, I don't really know how to use it.
You just need to tell me how to straighten out my code, and I will do it. I have taken so much of your time.

Thank you! Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Tue 08 Jul 2014, 22:21

To save a table, assuming you have the EDX installed, use the following piece of code...

Code:

EDX:saveTable(scripts.mission.yourScriptName, nil, "yourFileName.lua");

You can trigger that from a hotkey event or insert it anywhere in your code. It will take a snapshot of all of the data on whatever script you name in the first variable. If you also have scripts pointing at other scripts, which you do, they will all be saved in the file as well. I am writing a few new modules and working on a large mission at the present time, but my plan is to drastically expand on the EDX section of the forum with much more in depth tutorials and instructions.  Hopefully more people will come around to check it out, but if it just helps one person I'll be satisfied with that.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 02:05

It's useful but... 
I inserted it in two places:
Code:
startAdd=function(self)
  math.randomseed(os.time());
  T:enableMDASpeech();
  triggerInit(nil);
  eventInit(nil);
  speech(nil);
  EDX:saveTable(scripts.mission.fun,nil,"heli_rescue0.lua");
end

spawnedSet=function(self,setName,tableOfEntities)
  if setName=="decept" then
    OFP:follow("deceptteam","player",50,"ADDTOFRONT");
    OFP:engage("deceptteam","player","ADDTOEND");
    OFP:scriptedCheckpoint();
    EDX:saveTable(scripts.mission.fun,nil,"heli_rescue1.lua");
  end
end
Then I checked them... they are the same... 
I really want to figure out the checkpoint, I'm stuck.
Maybe I should put all code into level.lua.

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Wed 09 Jul 2014, 02:33

Do you mean they were totally identical? What you need to do is make a table save prior to a checkpoint. Create a checkpoint in the game and load the mission from the checkpoint. Then create another table save. Look carefully at every single line. There has to be something there that is different if the mission is not functioning after the checkpoint.

Since you are using the EDX you need to get everything out of the level script. Look through the EDX kit you downloaded from the EDX thread and find the quickstart marker collection. To load that file go to file>marker collections>load. Navigate to the file and open it. That will place the proper level script into your project along with a mission script containing some basic mission settings. Copy everything from your existing level script into the mission script and adjust the code accordingly (ie- put your onMissionStart code into the onMissionStart function.  Copy everything from the level script that was put in by the quickstart into your existing level script and delete the additional one.. At that point you should have the following scripts in your project:
level
mission
fun
data
talk

You do not want to move all of your code to the level script... this will cause problems. Your level script should be almost blank except for a couple of variables to set EDX parameters. Nothing else.

When you use timers with the edx there is no need to use onTimer. It only fires because you had it on your level script, but the EDX only calls the named function from the timer without the onTimer. This could be causing an issue in your project.

Try those adjustments and let me know how it goes.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 03:59

Wow, it works!
I "copy everything from my existing level script into the mission script and adjust the code accordingly", and everything runs well.

Maybe I made a mistake here:
Code:
triggerInit=function()
  for i=1,#D.trigger do
    D.trigger[D.trigger[i]]=1;
  end
end
then
Code:
onMissionStart=function()
  triggerInit();
end

In onEnter event:
Code:
triggerSet=function(self,zoneName,unitName)
  if D.trigger[zoneName]==1 then
    D.trigger[zoneName]=0;
    OFP:displaySystemMessage("trigger is enabled.");
    --------------------------------------------------
    if zoneName==D.zone["trigger"][1] and OFP:isInGroup(unitName,"playerteam") then
      deceptSet(nil,zoneName,unitName);
    end
    if OFP:isInGroup(unitName,"playerteam") and sightHeliJudge(nil,zoneName,unitName) then
      sightHeliSet(nil);
    elseif zoneName==D.zone["trigger"][2] and OFP:isInGroup(unitName,"playerteam") then
      camoutSet(nil);
    elseif zoneName==D.zone["trigger"][3] and OFP:isInGroup(unitName,"transhelo") then
      esSet(nil);
    end
  else
    OFP:displaySystemMessage("trigger is disabled.");
    --------------------------------------------------
  end
end

When I delete them and use normal format, checkpoint works!

Thanks! Very Happy

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Wed 09 Jul 2014, 04:08

That's excellent!!  cheers When you get it tested and ready to go, post it back up in your mission release thread so we can give it a go. I'll post up some of my new modules when I get them exactly how I want them. I'm very happy to hear you got your mission running right. The EDX may take a little bit of getting used to, but it makes using the editor much easier and gives you much more flexibility and control over your scripts, not to mention the ability to create plug and play modules with it.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 04:26

onEnter triggerzones, most of them should be OFP:disableEvent() after be triggered. 
But when I put all of them together such as :
Code:
onEnter=function(zoneName,unitName)
  if zoneName=="zoneName" then
    do something.
  elseif zoneName=="zoneNamei1" then
    do something.
  end
end
Then I find it's difficult to disable them after be triggered because different zoneName or unitName. Is there some method to do this?  Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Wed 09 Jul 2014, 04:33

Just set variables for them and check the variable status like this.
Code:
onEnter=function(zoneName,unitName)
  if zoneName=="zoneName" and not z0 then --checks variable z0 and if it's not there then
    z0 = true; --sets variable z0 to prevent this chunk from executing again
    do something.
  elseif zoneName=="zoneNamei1" and not z1 then
    z1 = true;
    do something.
  end
end
This way you check the variable and if it's absent the first time the trigger is entered the variable is set and will prevent that chunk from executing again. To make the trigger available again just set the variable to nil or false somewhere and it will function until it is entered again.

Smile
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 04:52

OK... It's so easy...
I have many questions, and the rest of them maybe complex, such as what happened when a command was added to the target's command queue, but I don't really want to know them as soon as possible. You can tell me about them when you have plenty of time.

Thanks. Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Wed 09 Jul 2014, 05:01

This might be even easier
Code:
onMissionStart=function()
   disabled={};
end

onEnter=function(zoneName,unitName)
   if not disabled[zoneName] then
      disabled[zoneName]=true;
      if zoneName=="whatever" then
         do something.
      elseif zoneName=="somethingelse" then
         do something.
      end
   end
end
Wink
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 05:04

I wonder what time it is now in your timezone? Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Wed 09 Jul 2014, 05:08

It's getting late here... in fact I have to get to bed.I have to write scripts for a living tomorrow Wink Dont be afraid to keep asking questions though. When I have the time to answer them and if I have the answer, I will Smile

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Wed 09 Jul 2014, 15:32

When a command attach to the target, such as "move" "assault" etc, then how to get this command name by scripts at that moment?

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Thu 10 Jul 2014, 13:34

If you are trying to capture the commandID you need to set a variable like this:
Code:
myCommand=OFP:move("ech","target","OVERRIDE")
This will return the commandID to myCommand.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Thu 10 Jul 2014, 17:07

Thanks... But, maybe I didn't express it clearly.
When player give a command to other members, such as by pressing Q in the game, then how to get the name of this command.
There is a function which can get command name,
Code:
onCmdCompleted(commandID,commandName, unitorechelonName, isSuccessful)
But the command has been finished.
I found this function in RootScript.lua, and some struct of command.
Then I guess there is some way to get command name at that moment when the command is added to actor's command queue table. I'm unable to do this...
I was just curious, in fact. Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by tvig0r0us Thu 10 Jul 2014, 18:58

I'm not 100% about this and I've never used any of these functions, but try looking into the onPlayEnter event handler. You may be able to swipe the commandID from that function when the command is given by the player. Check out the help file in the editor for more details on those event handlers. There are several commands that have to do with the AI play book, but I don't know how they tie into the player issuing individual commands.

Cheers Very Happy
tvig0r0us
tvig0r0us
Admin

Location : Nky
Points : 266
Reputation : 29
Join date : 2013-10-16

http://www.moddb.com/members/tvig0r0us

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Sun 13 Jul 2014, 08:16

I can't finish my first complete mission I guess, there are lots of bugs and it's difficult to clean them because they are one by one... But I don't want to give up this one, this mission is interesting because of lightning effect and playOneShotSound, so I uploaded it and I hope you can help me, you have more experience.
    RUNERBACK'S MSSN
I'm using DB from EDX kit.All function are in mission.lua and I don't use func.lua.
Thanks! Smile

By the way, I use I have some questions to ask... Sce10 from TemplarGFX to make darker night.

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Sun 13 Jul 2014, 09:56

And this is FMOD of thunder:
  Thunder

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by runerback Mon 21 Jul 2014, 02:25

Hi, how to use luacom, I want to make key-press in the game.
I put luacom.dll in game folder, then
Code:
onCreate=function()
  require "luacom";
  ws = luacom.CreateObject("WScript.Shell");
end
Code:
ws:SendKeys("Esc");

It's no use. So I want to know how to make this happen. Smile

runerback

Location : China
Points : 153
Reputation : 5
Join date : 2014-06-18

Back to top Go down

I have some questions to ask... Empty Re: I have some questions to ask...

Post by Sponsored content


Sponsored content


Back to top Go down

Page 1 of 3 1, 2, 3  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum