Game Development Community

Melee script compile errors

by Ken Johnston · in Torque 3D Professional · 08/25/2009 (1:15 am) · 12 replies

hopefully someone will have an answer to this for me... i have this code for server side melee in the weapon.cs script file. everytime i try to run i get a parse error at the pound signs shown anyone have a clue on the error?



function weaponimage::onFireHandToHand (%this, %obj, %slot)
{
   if (%obj.hthStun)
      return;
      $action = "Normal";
      switch$($action);
 ##{
      case "Normal":
         %index = mFloor(getRandom()*(%this.hthnumAttacks-0.0001));
         if (%index > (%this.hthnumAttacks-1))
            %index = (%this.hthNumAttacks-1);
         %attack = %this.hthAttack[%index];
   }
   %obj.hthDamageAttack = %attack;
   %obj.hthDamageSeqPlaying = 1;
   %obj.hthDamageStartMS = $Sim::Time;
   %obj.hthDamageLastId = -1;
   
   if (!%obj.setArmPlayOnce(%attack.seqName))
      echo("Error in setArmPlayonce()");
   return;
}


#1
08/25/2009 (1:32 am)
switch$($action);
Should be:
switch$($action)
#2
08/25/2009 (10:45 pm)
Sweet, thanks Michael that worked!
#3
02/21/2010 (5:26 pm)
Hello. I take it from the code sample above you are working with Josh Moore's TGE resource for Server Side Melee. I have been attempting to implement it, but am baffled at this point after three attempts--specifically, the changes between TGE 1.3 and T3D, I believe, are hanging me up due to my lack of understanding...

I'd really appreciate learning how you solved this issue, with the line in ShapeImage.cpp, where the function ShapeBase::UpdateImageRaycastDamage is added according to the instructions. My compiler hangs up continually on the last line:

Con::executef(image.dataBlock,5,"onImageIntersect",scriptThis(),buff1,buff2,buff3);

and nothing I can think of can alter that line into acceptability. This is the compiler error I receive, which is fairly straightforward except I cannot find an equivalent to the function to use.

15>scopeAlwaysShape.cpp
15>c:\torque\torque 3d 2009 pro 1.1 beta 1\engine\source\t3d\shapeimage.cpp(2130) : error C2665: 'Con::executef' : none of the 21 overloads could convert all the argument types
15> c:\torque\torque 3d 2009 pro 1.1 beta 1\engine\source\console\console.h(574): could be 'const char *Con::executef(const char *,const char *,const char *,const char *,const char *,const char *,const char *)'
15> c:\torque\torque 3d 2009 pro 1.1 beta 1\engine\source\console\console.h(602): or 'const char *Con::executef(SimObject *,const char *,const char *,const char *,const char *,const char *,const char *)'
15> while trying to match the argument list '(ShapeBaseImageData *, int, const char [17], const char *, char [32], char [100], char [100])'
15>rigidShape.cpp

Thank you if anyone has a clue how to get around this in this resource. I have other questions, but this one is the showstopper--can't compile to test the scripts, etc.
#4
02/22/2010 (12:35 am)
take a look at this thread http://www.torquepowered.com/community/forums/viewthread/100427
a detailed solution for porting the solution to beta five is posted there shouldnt be to difficult to get it working in whatever version of t3d you are using.
#5
02/22/2010 (2:54 pm)
Thanks for the quick response, Ken!

I'm going to download a fresh copy of 1.0.1 and try placing that directly in, as just diffing those files against the current Beta isn't working for me--a lot of differences in the diff, and some new variables and variable name changes were introduced in the beta, particularly in ShapeImage. If it works, I'll diff it forward against the a clean copy of the current beta again.

The problem will then turn out to be a borked script file, I can almost count on it :)
#6
02/22/2010 (2:57 pm)
good luck with it net, if you run into problems i can try and help further, it wasn't too difficult to port it up to 1.1 beta so you shouldn't have too much issue going to 1.0.1, just make sure you check your scripts very carefully as at least for me that is were i get into the most trouble half the time, though i have significantly modified this resource now for my own ends.
#7
02/22/2010 (5:11 pm)
OK, I was able to set that up very quickly on a fresh build of 1.0.1, and it worked beautifully, thank you.

Now comes the head scratching part, though. I guess it's time to reinstall 1.1 Beta and put this in, and then try backporting all the code I'd already added in to the clean install assuming I can get the sword working in the first place.

Thanks for providing that code--at least I know how it is supposed to look and behave when working, beyond the brief glimpse seen in the video for the AI kit, which is what set me down this whole path on Thursday in the first place.
#8
02/23/2010 (4:15 am)
Well, after ten more careful hours, and making the changes one file at a time, I believe I have the C++ changes into the engine--they compile and operate properly until the scripts are changed. Everything runs fine with the stock .cs files, and allows the RocketLauncher to function normally.

I even did the merge with WordPad manually, line by line, a file at a time, then searched through them again to make sure I got all the changes in. Then I checked again with WinMerge. Just to be thorough.

I've picked through the .cs files, and the changes in all of them seem very minor. However, after copying the changed lines from the 1.0.1 versions into the 1.1 files, bringing up the mission and left-clicking with the sword displayed instantly causes a fatal crash. Using the "1" key to cycle weapons to the RocketLauncher first, and the game will continue to run even if you fire until you run out of ammo.

I'll have to do a fresh build and try the script changes one by one by one instead of in a batch and see what happens--tomorrow. That's enough for today.
#9
02/24/2010 (7:30 pm)
Nailed it.

Just succeeded in backporting my own code into the build, which took me a couple tries in addition, but all the familiar bits seem back in place.

Thanks for your pointer to that thread, Ken. Very much appreciated. Hope your own project is going well!
#10
03/11/2010 (9:05 am)
@ Netwyrm,

Quote:However, after copying the changed lines from the 1.0.1 versions into the 1.1 files, bringing up the mission and left-clicking with the sword displayed instantly causes a fatal crash.

How did you fix that? Also crashing for me but on 1.1a.
#11
03/11/2010 (10:10 am)
I'm at work at the moment, and far from my files, but if I recall correctly the problem I was having had to do with the sword datablock--watching the console after sticking in print statements had a call being made with an empty or nonexistent datablock, and so when the engine went looking for weapons information, bad things happened.

Check your sword scripts in both the art/datablocks and scripts directories, and also be sure to delete scripts/client/config.cs if you make any changes to scripts/client/default.binds.cs defeating the rocket launcher so they are picked up.
#12
03/11/2010 (1:51 pm)
*facepalm*

I forgot to exec the sword functions (i think), do'h.