Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 123 Pages +
  • « First
  • 7
  • 8
  • 9
  • 10
  • 11
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   XThX2 

#241

				whilevarn spritenum2 16384
				{
					addvar spritenum2 1

					ifvarvarn spritenum2 THISACTOR
					{
						getactor[spritenum2].picnum picnum
						getactor[spritenum2].statnum statnum
						getactor[spritenum2].sectnum mysector
						ifvarn statnum 1024 ifvarn mysector -1
						{
							switch picnum
							case ENLISTEE case LIZTROOP case PIGCOP case LIZMAN case ZOMBIEPLS
							case OCTABRAIN case COMMANDER case DEVIL case SHADE case CHAINGUNNER
							case EXTERMINATOR case TANK case BLOODSEEKER case NEWBEAST case NNEWWBEAST
							case CDEMON case PAINE case LSOUL case APLAYER
								canseespr THISACTOR spritenum2 returnvar7
						
								ifvare returnvar7 1
								{
									setactorvar[spritenum2].para 1
									setactorvar[spritenum2].para_counter 0
									randvar randomvar 24
									mulvar randomvar 48
									setactor[spritenum2].htextra randomvar
								}
							break
							endswitch
						}
			   		}
		 		}


I've played around with the code and I'm still having the same error, with these this time ;

Quote

Line 6793, getactor: tried to get picnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2
Line 6794, getactor: tried to get statnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2
Line 6795, getactor: tried to get sectnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2


It gets stuck on APLAYER sprite for some reason. I don't know why. (1405 = Aplayer) What am I doing wrong here ? (Spritenum2 is -1 2)

This post has been edited by XThX2: 26 August 2009 - 04:11 AM

0

User is online   Danukem 

  • Duke Plus Developer

#242

Line 6793, getactor: tried to get picnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2


^What that means is that sprite 0, which is a player sprite, is trying to get information from an invalid sprite (number 16384).

Put the addvar spritenum2 1 at the END of the while loop instead of the beginning.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#243

Also, check the statnum before anything, you may not use getactor unless you are checking the statnum.
0

User is offline   XThX2 

#244

Well checking the statnum involves getactor... Unless there's a way to do it otherwise.

Also, it is working perfectly now, thanks. :blink:

This post has been edited by XThX2: 26 August 2009 - 07:55 AM

0

User is offline   Chip 

#245

View PostMblackwell, on Aug 25 2009, 05:11 PM, said:

Care to post the relevant code?


I bring you pictures and everything!

Observe picture 1:
Everthing works fine, of course I'm facing the actor through the whole situation.
(If you click the image to gointo Imageshack, then once its loaded, click the image again to get it to a single window - then click once more to full size the image but this last part may vary depending on your web browser)
Posted Image


In this next test, I turn away when the climbing animation starts and then when I return its in a horrible mess!
Posted Image




Clearly its gone wrong all because the player turned away. I'm certain this has to be down to the whole models (well sprites and what ever they have set to them) dissapearing when out of sight and thus screwing with the animations either by pausing them or resetting them, either way my movement code carries on and forces my actor into the possitions its meant to be at but of course the animation lost sync with it and it looks silly.

Here's the climbing code:

state pokeclimbstate

ifmove MPOKEHANG1 nullop else move MPOKEHANG1 geth getv
ifvare APPLYONCE 0 { getsector[TEMP5].floorz z2 subvar z2 90 setvar APPLYONCE 1 }

getactor[THISACTOR].z z
ifvarvarl z z2 { ifcount 120 setactor[THISACTOR].xvel 32 }
else { subvar z 140 setactor[THISACTOR].z z }

ifactioncount 45 { state resetvarsstate setvar TIMEOUT 3 setvar TEMP 2 action APOKEWALK }
ends



Here's the defined animation:
   anim { frame0 "FRAME396" frame1 "FRAME480" fps 19 flags 1 }
   frame { name "FRAME396" tile 5747 } // Climb up  and over!



The actor is a "useractor notenemy", it does not have any share gamevars - all the ones it uses are per actor. There isn't a single player related command in any of its states.

This post has been edited by Chip: 26 August 2009 - 08:46 AM

0

User is offline   Mblackwell 

  • Evil Overlord

#246

Where are you setting the initial actions? And what's resetvarstate? I only see one action call in that state. I also see an ifcount 120, which I must ask if you're ever resetting to 0. And where is TEMP5 getting set?

Oh and I reformatted your code so it's easier to read.
state pokeclimbstate

	ifmove MPOKEHANG1
		nullop
	else
		move MPOKEHANG1 geth getv

	ifvare APPLYONCE 0
	{
		getsector[TEMP5].floorz z2
		subvar z2 90
		setvar APPLYONCE 1
	}

	getactor[THISACTOR].z z
	ifvarvarl z z2
	{
		ifcount 120
			setactor[THISACTOR].xvel 32
	}
	else
	{
		subvar z 140
		setactor[THISACTOR].z z
	}

	ifactioncount 45
	{
		state resetvarsstate
		setvar TIMEOUT 3
		setvar TEMP 2
		action APOKEWALK
	}
ends

0

User is online   Danukem 

  • Duke Plus Developer

#247

This is pretty clearly a problem with some internal animation counter on the model not behaving correctly because it is not being rendered (as Chip suggested). Unless he has something really silly in his code (like ifp pfacing nullop else action...) looking away from the model and then back again isn't going to make any difference to its animation. It reminds me of an HRP issue (which I know was at least partially fixed) where dead monsters would display their death animation again if you hadn't looked at them in a while.
0

User is offline   Chip 

#248

Quote

Where are you setting the initial actions? And what's resetvarstate? I only see one action call in that state. I also see an ifcount 120, which I must ask if you're ever resetting to 0. And where is TEMP5 getting set?



All actions and vars are being set from another state followed by an instant "break" (in this case it was set in its hang state which it does before climbing) TEMP5 holds the sector's ID where it plans on climbing to which was set in its jump state. Its only reset in its standard paving stuff. Resetvarsstate is a state used to set my important gamevars to 0 (In this case my jumpable vars since the otheres were untouced)
That ifcount however isn't being reset - I forgot about that so I may throw into the resetvarsstate but it shouldn't cause any problems since it will get automaticaly reset in its seekstate upon the first invalid spotted sector. (It has an ifcount 2 { resetcount ......stuff... } when it doesn't like the look of the upcoming sector) My actor doesn't do anything else with that count so its harmless at the moment.


Quote

Oh and I reformatted your code so it's easier to read.


That's how I used to always write out my code but I actually started finding it easier to read in the other way, Its especially quicker to skim past.





Quote

It reminds me of an HRP issue (which I know was at least partially fixed) where dead monsters would display their death animation again if you hadn't looked at them in a while.

I guess that's a little more evidence that models and animations needs a little looking into. For me this bug of re-animating dead monsters always occurs when I reload a saved gamed.

This post has been edited by Chip: 26 August 2009 - 12:07 PM

0

User is online   Danukem 

  • Duke Plus Developer

#249

The only thing I can think of that might help is setting mdflags to 16 on the actors. It can't hurt to try.

http://wiki.eduke32.com/wiki/Mdflags
0

User is offline   Chip 

#250

View PostDeeperThought, on Aug 26 2009, 10:02 PM, said:

The only thing I can think of that might help is setting mdflags to 16 on the actors. It can't hurt to try.

http://wiki.eduke32.com/wiki/Mdflags



Yeah I tried that but it unfortunately didn't work, assuming I used it right. (which I may have not now that I think about it). I will however also try changing my actor from notenemy to enemy to see if that makes any change since enemies do alot more stuff then notenemies (I've only recently found out the enemy tagged actors have a built in paving code to help it avoid walls - not a good one but there is indeed one in there. I guess that's why it jerks in movement.)

This post has been edited by Chip: 27 August 2009 - 04:27 AM

0

User is offline   XThX2 

#251

Is canseespr only working if both actors are in the same sector ? Or at close/same heights ? Because, in my case with the code I've posted before (with the fixes you guys suggested) it never works when I go to a different sector than the actor that I'm supposed to be seeing, or when I go to a higher place like ramps, or cliffs.
0

User is offline   Chip 

#252

I'm certain I've seen it working over sectors since I distinctly remember seeing one of my Marines (from my old badly coded Doom mod) shooting over a table to hit an Imp. But I can't test it now so I can't proove anything.

If you're still having problems then you could aways try cansee which indeed can cross sectors (else it would be pointless for the command to need sector IDs imputted for botth points) but with that you'll need to obtain more details before using the command.

Side note, cansee is fantastic for paving code!

This post has been edited by Chip: 27 August 2009 - 04:57 AM

0

User is offline   XThX2 

#253

Strange, cansee works just perfectly, whereas canseespr fails to work over height/sector changes. Cansee also seems more useful because of the information it uses.
0

User is online   Danukem 

  • Duke Plus Developer

#254

View PostXThX2, on Aug 27 2009, 07:49 AM, said:

Strange, cansee works just perfectly, whereas canseespr fails to work over height/sector changes. Cansee also seems more useful because of the information it uses.


I'm guessing that when you used cansee, you set the z coordinates appropriately. canseespr works fine too, but keep in mind that sprites see from the bottoms of their feet, so it's a good idea to lift them up before using it.
0

User is offline   m210® 

#255

It is possible to operate SE12 by means of a code?
0

User is offline   Chip 

#256

View PostM210, on Aug 29 2009, 03:52 AM, said:

It is possible to operate SE12 by means of a code?


What's sector effector 12? (I don't know the numbers by heart)






Quote

Yeah I tried that but it unfortunately didn't work, assuming I used it right. (which I may have not now that I think about it)

Tried that again but still nothing.
I guess this may only be something that TerminX can solve but I don't want to hassle people (especially if they may allready know about due to it being apart of a bug that's existed for a while) so I wont speak more of this till some time passes by.




New issues: Slopes!!!!
It appears sloped sectors are evil, my actors see them not as a slope but of the unmodifed block that the slope starts at. A slope that starts from the ground and slopes up counts as being flat on the ground and one that starts at the top then slopes down counts as being flat at the top.
As such my actors avoid them thinking those are too high or too low and so wont either step foot on them or if they do (starts at the ground and slopes up) then they wont walk off the top onto the higher sector. Also I guess the actor's z possition isn't really where the sprite is but still on the floor / at the top regardless of possition. I believe that since my actor checks his new possition's floor with subvar 8000 (so its not flat on the floor) against his own z possition (again with subvar 8000 so he's seeing higher up) His cansee shouldn't be blocked due to that so its failing because of my hack stopping him from walking into wall that's 5000 higher then his own Z possition. (and by higher I mean lower)

I'm not too bothered about getting the exact slope details, at this point I just want my actor to have an accurate z possition when on the slope.
For this I need to know the angle of the sloped sector. This I don't know how to obtain since the only getsector slope detail I saw was the amount the slope had gone up / down by.
With that I can hopefully do the rest by checking all the points to each other and conpair the angle between those points to the sloped sector to see which 2 points closely match the slope's angle and as such can assume that these 2 points I have are 1 from the top of the slope and 1 from the bottom allowing me to work out the height of both ends of the slope by obtaining the adjacent floor's Z .....then do some kind of XY thing with the actor to work out where he is on the slope and add or sub a value from his z checking.
*edit*
What if my sector slopes to a cliff edge? I guess I'll have to throw in the floorslope amount in there as well.


In short, my question is: how do I find out a sector's slope angle?
Oh and is there a much better way to work out my z possition on a sector slope then what I posted above? (Which I'm certain there are 500 more)
Also what does EXTRA hold from Walls? The wiki says sectors and walls have an EXTRA but it doesn't say what it holds.








*edit once more*
///////////////////////////////////////////////////////////////////////////////// ///////////



Never mind, about the Z possition on sloped sectors, I saw this: http://wiki.eduke32....Getflorzofslope !

Another fantastic command hidden within the wiki!

This post has been edited by Chip: 29 August 2009 - 11:01 AM

0

User is offline   m210® 

#257

View PostChip, on Aug 29 2009, 10:46 PM, said:

What's sector effector 12? (I don't know the numbers by heart)

It's a light switch SE, which switch-on light on the sector when push at button, and swicth-off if shot at lighter or push to off the button
0

#258

Right, I want to ask something, though I'm not sure whether this is the right thread for it - but I don't want to start a whole new thread. Ok here goes.
Some time ago on 3D Realms forums, I came up with an idea for a mod/tc that was basically Duke Nukem 2 style in Duke Nukem 3D, I did a bit of work and then kind of forgot about it, but I keep thinking of starting it up again, there's only one thing that stops me - CON Code, i can't really seem to get back into that, I've been slowly moving away from programming for a couple of years now, and CON code just doesn't seem to be something that will go back into my head (And I think it's a bit different if i want to take advantages of the EDuke32 features anyway) so, If I did decide to start the mod again, would someone perhaps give me a hand with that? I would literally be doing everything else for it except the CON Coding, well, might decide i needed a few models, but more likely I would use Sprites, as it would be like a 3D SideScroller (DNMP Style).

This isn't something I am definitely going to do mind, but I am really thinking about it for when I have my Music Packs finished as I would have no more foreseeable projects lined up.
0

User is online   Danukem 

  • Duke Plus Developer

#259

Speaking for myself, I would never sign on to code a TC unless the person I was working with had a proven record of finishing and releasing stuff. Pretty much every modder in the community who has been around long enough has been burned at one time or another by putting a lot of effort into something only to have it wasted because the other member(s) of the team didn't do their part.
0

#260

And I don't blame people for thinking like that - I would do the same, that sort of thing used to happen to me all the time with other kinds of projects (usually at college, I still blame the rest of my group for me failing that IT course :blink: ).

Which gives me an idea, what I think I will do, if I decide to do this TC/Mod, I will do everything I can with it (Maps, Graphics etc...), would probably even have a crack at the CON code myself as well as I could probably get some of it working, and then when I have everything but the code I would need, then come back and make a thread saying that I basically have everything done, I just needed some code before adding the finishing touches (the finishing touches being stuff in the maps that relied on the code) - yeah, I am now thinking that is a better idea.

This post has been edited by High Treason: 01 September 2009 - 12:56 AM

0

User is offline   XThX2 

#261

How can I get the distance of an actor to the midpoint of a wall it is hitscanning ? I've tried numerous attempts and this one was the closest I could get, yet it doesn't work quite well.

			getwall[hitwall].x x
			getwall[hitwall].y y
			getwall[hitwall].point2 point2
			getwall[point2].x wx
			getwall[point2].y wy
			getplayer[THISACTOR].posx posx
			getplayer[THISACTOR].posy posy
			
			addvarvar x wx addvarvar y wy divvar x 2 divvar y 2
			mulvarvar x x mulvarvar y y addvarvar x y sqrt x x
		   
			mulvarvar posx posx mulvarvar posy posy
			addvarvar posx posy sqrt posx posx
			subvarvar x posx

0

#262

Lucky for you I've done this for NR with using ATMs/Cola Machines/etc. Since all walls are straight lines, the method below should always work. However you'll have to change the varnames to your own since these are taken straight from NR's code.

 getwall[hitwall].x hitwallx
 getwall[hitwall].y hitwally
 getwall[hitwall].point2 hitwallpoint2
 getwall[hitwallpoint2].x hitwallpoint2x
 getwall[hitwallpoint2].y hitwallpoint2y
 setvarvar hitwallcenterx hitwallx
 addvarvar hitwallcenterx hitwallpoint2x
 divvar hitwallcenterx 2
 setvarvar hitwallcentery hitwally
 addvarvar hitwallcentery hitwallpoint2y
 divvar hitwallcentery 2

 getplayer[THISACTOR].posx posx
 getplayer[THISACTOR].posy posy

 setvarvar wallxdist hitwallcenterx
 subvarvar wallxdist posx
 setvarvar wallydist hitwallcentery
 subvarvar wallydist posy


And if you want to check your distance from the wall with this method, like for the way I mentioned above, you can use this form of example to help you. This example is for if you're within "item grabbing range" of the wall.
 ifvarg wallxdist -845 ifvarl wallxdist 845
{
  ifvarg wallydist -845 ifvarl wallydist 845
  {
   // do something
  }
}


Let me know if that helps. >.>

This post has been edited by Lord Misfit: 02 September 2009 - 02:27 AM

0

User is offline   XThX2 

#263

			getwall[hitwall].x x
			getwall[hitwall].y y
			getwall[hitwall].point2 point2
			getwall[point2].x wx
			getwall[point2].y wy
			getplayer[THISACTOR].posx posx
			getplayer[THISACTOR].posy posy
			
			addvarvar x wx
			addvarvar y wy
			divvar x 2
			divvar y 2
			
			subvarvar x posx
			subvarvar y posy
			addlogvar x addlogvar y

This is what I've done, I removed those "setvvarvar" stuff because I thought they were unnecessary (I tried it the way you have given, "exactly" the way you've given after this one failed) however they both don't work. The values they return are with 5 digits...

Quote

CONLOGVAR: L=8054 x (Global) =87965
CONLOGVAR: L=8054 y (Global) =92763


This is when I'm at point blank range to the wall. Also, I needed the code to work with diagonal walls too, then I thought I could use phythagoras, but my tries proved my code doesn't do so well.
0

User is online   Danukem 

  • Duke Plus Developer

#264

Averaging wall point coordinates to find center: WIN!

Subtracting center coords from player coords to find distance to player: FAIL!

Yes, it is simpler computationally to use subtraction, but the result is not very accurate, so just use the Pythagorean theorem and do it correctly.
0

User is offline   Chip 

#265

View PostDeeperThought, on Sep 2 2009, 03:45 PM, said:

so just use the Pythagorean theorem and do it correctly.


Which I have no idea how to do........not that I need it. I once required sometihng like this for making my actor's climb walls correctly but I just had my actor check his angle to both wall points to see if he was within the wall and not just clipping it. It was also used to allow my actor to align correctly since he needed to know whether to add or subtract 512 of the walls angle (so he would end up flat against the wall)
My method is probably (most certainly) lame so I wont bother posting exactly what I did.

This post has been edited by Chip: 02 September 2009 - 07:03 AM

0

#266

Right, I am not asking for help as such, because that would be plain cheek - and it could end up wasting peoples time as well, and that probably wouldn't go down very well - I just want to know whether certain things can actually be done.

As I am now working on this mod of mine, i must ask whether it is actually possible to change the camera angle for third-person view using CON code?

I just want to know before I pour weeks/months into this project. Failing that, I guess it could work if it were instead possible to change the angle the gun fired at, but I also am not sure that is possible.

This post has been edited by High Treason: 02 September 2009 - 08:04 AM

0

User is online   Danukem 

  • Duke Plus Developer

#267

Yes, it's possible, and it's not even the most difficult thing you'll need to code.
0

User is offline   Jimmy 

  • Let's go Brandon!

#268

The Pythagorean theorem is 10th Grade Geometry. I nearly failed Geometry and I could tell you it:
A^2 + B^2 = C^2
0

User is offline   XThX2 

#269

My problem was not with the theory, in fact, I believe I've applied it perfectly, yet it refuses to work. The one I'm using is, for distance between two points, which is similar.

Quote

sqrt[(x_1 - x_2)^2 + (y_1 - y_2)^2] = Distance

0

User is online   Danukem 

  • Duke Plus Developer

#270

View PostXThX2, on Sep 2 2009, 01:51 PM, said:

My problem was not with the theory, in fact, I believe I've applied it perfectly, yet it refuses to work.



If you believe that you are applying it perfectly and it's not working, then you must think there is something wrong with EDuke32 that is preventing it from working. But if you really believed that, then surely you would have posted your perfect code to make your point.
0

Share this topic:


  • 123 Pages +
  • « First
  • 7
  • 8
  • 9
  • 10
  • 11
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options