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

Jump to content

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

EDuke32 Scripting  "CON coding help"

User is offline   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

 DeeperThought, 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 offline   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 offline   Danukem 

  • Duke Plus Developer

#270

 XThX2, 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

User is offline   XThX2 

#271

			addvarvar x wx
			addvarvar y wy
			divvar x 2
			divvar y 2
			
			subvarvar x posx mulvarvar x x 
			subvarvar y posy mulvarvar y y
			addvarvar x y sqrt x x
			addlogvar x


Well, the values don't match at different places, which I'm sure it's because of the usage of "coordinates" I can't think of a better way to make it.
0

User is offline   Danukem 

  • Duke Plus Developer

#272

View PostXThX2, on Sep 2 2009, 02:42 PM, said:

			addvarvar x wx
			addvarvar y wy
			divvar x 2
			divvar y 2
			
			subvarvar x posx mulvarvar x x 
			subvarvar y posy mulvarvar y y
			addvarvar x y sqrt x x
			addlogvar x


Well, the values don't match at different places, which I'm sure it's because of the usage of "coordinates" I can't think of a better way to make it.



That looks right! I have used code that does exactly the same thing and it has worked fine for me. It makes me wonder if an assumption has gone wrong farther back, like maybe you aren't using the right wall points.
0

User is offline   XThX2 

#273

Damn you're right ! I was hitscanning the wall "hitwall2" but I was using "hitwall" all the time !!! I hate when this happens, and this is not once or twice that I kept bothering you and others because of it ;( It works perfectly fine now :/

This post has been edited by XThX2: 02 September 2009 - 04:10 PM

0

User is offline   Chip 

#274

Isn't there a command that plays the quote from a gamevar?
I'm certain I've seen one but I've just been through the wiki and can't find it. I hope I haven't imagined it. :blink:

This post has been edited by Chip: 05 September 2009 - 07:39 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#275

View PostChip, on Sep 5 2009, 08:37 AM, said:

Isn't there a command that plays the quote from a gamevar?
I'm certain I've seen one but I've just been through the wiki and can't find it. I hope I haven't imagined it. :blink:


Just set the player's ftq to the quote number and set fta to the amount of time to display.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#276

I would prefer to use a normal quote <id> command. Before it, just use Qstrcpy to copy of the quote you want to be displayed to the <id> one.
0

User is offline   m210® 

#277

I wish to apply a method of sorting by a bubble to the code.
I have 4 vectors with different values, but the minimum value gets out only from 2 last vectors? Help me to solve a problem:)
Example:
ARRAY[1] = 3000
ARRAY[2] = 400
ARRAY[3] = 1000
ARRAY[4] = 5000
Result of a code is value equal 1000

	setvar tmp 1
	whilevarn tmp 5
	{
		setvarvar tmp2 tmp
		addvar tmp2 1
		setvarvar tmp3 tmp2
		addlogvar ARRAY[tmp]
		addlogvar ARRAY[tmp3]
		ifvarvarg ARRAY[tmp] ARRAY[tmp3] ifvarg ARRAY[tmp3] 0 setvarvar tmp5 ARRAY[tmp3]
		addlogvar tmp5
		addvar tmp 1
	}


This post has been edited by M210: 06 September 2009 - 08:26 AM

0

User is offline   XThX2 

#278

Why do you have a setvar tmp 1 at the beginning ? Remove it, instead, define your tmp as 1 X, where x is either a global, actor, player etc variable.
0

User is offline   m210® 

#279

View PostXThX2, on Sep 6 2009, 08:30 PM, said:

Why do you have a setvar tmp 1 at the beginning ? Remove it, instead, define your tmp as 1 X, where x is either a global, actor, player etc variable.

If it to remove, the code will cease to work and I need to receive the minimum distance every second instead of once

This post has been edited by M210: 06 September 2009 - 08:51 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#280

Could someone explain in clear, plain english what the code is supposed to be doing? Is it supposed to order the array from lowest number to highest or what?
0

User is offline   Chip 

#281

View PostDeeperThought, on Sep 5 2009, 05:15 PM, said:

Just set the player's ftq to the quote number and set fta to the amount of time to display.


I was going to reply saying that I don't think that would work for my code but after realizing that this was done through the get/set player/actor stuff it is sure to be exactly what I was after - thanks :blink:

setplayer[THISACTOR].ftq QUOTEVAR
setplayer[THISACTOR].fta 99

0

User is offline   m210® 

#282

Yes, you have correctly understood. Sorry for my English.
Now my code works fine, DeeperThought what are you think, whether this code of updating demands, my code have a errors?
	setvar tmp 1
	whilevarn tmp 3
	{
		setvarvar tmp2 tmp
		setvar tmp3 2
		whilevarn tmp3 5
		{
			ifvarvarg ARRAY[tmp2] ARRAY[tmp3] { setvarvar tmp2 tmp3 }
			setvarvar tmp4 ARRAY[tmp]
			setarray ARRAY[tmp] ARRAY[tmp2]
			setarray ARRAY[tmp2] tmp4
			addvar tmp3 1
		}
		ifvarvarg ARRAY[1] ARRAY[2] { setvarvar minimum ARRAY[2] } else { setvarvar minimum ARRAY[1] }
		addvar tmp 1
	}
	addlogvar minimum


This post has been edited by M210: 06 September 2009 - 10:11 AM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#283

View PostChip, on Sep 6 2009, 02:41 PM, said:

I was going to reply saying that I don't think that would work for my code but after realizing that this was done through the get/set player/actor stuff it is sure to be exactly what I was after - thanks :blink:

setplayer[THISACTOR].ftq QUOTEVAR
setplayer[THISACTOR].fta 99
As I said, I would prefer use the normal quote and qstrcpy, I feel safer. But if you aren't going to do that, them you may check the fta_on ("Messages: on") too.
0

#284

I have searched the wiki and cant find if there is a way to change the angle that the player sprite faces and the angle that the player fires at.

What do I need to tamper with to change these things? I hope they can be meddled with or else i will have to go a very long way around.

Basically what I am trying to do is make it so when the player presses the back key (onevent MOVE_BACKWARD) it changes the angle of the player sprite and firing, but it can't just change the way the player is facing because that would effectively make him walk the same way he had been doing. Obviously I am working from a 2D perspective, so he will always face the exact same angle when walking a particular way - For example, it might always set his angle so he faces the left of the map, this wouldn't matter because it is only using 2 dimensions anyway.

This post has been edited by High Treason: 07 September 2009 - 12:22 AM

0

User is offline   XThX2 

#285

getplayer[THISACTOR].angle angle1 addvar angle1 1024/subvar angle1 1024 setplayer[THISACTOR].angle angle1


This might work for you. Add/substract is to make him face left/right, in your case back and front (Or I assume it is.) Since the angle of player has changed, all the weapons will fire from that angle. (Unless coded otherwise)
0

User is offline   Danukem 

  • Duke Plus Developer

#286

View PostHigh Treason, on Sep 7 2009, 01:21 AM, said:

I have searched the wiki and cant find if there is a way to change the angle that the player sprite faces and the angle that the player fires at.

What do I need to tamper with to change these things? I hope they can be meddled with or else i will have to go a very long way around.

Basically what I am trying to do is make it so when the player presses the back key (onevent MOVE_BACKWARD) it changes the angle of the player sprite and firing, but it can't just change the way the player is facing because that would effectively make him walk the same way he had been doing. Obviously I am working from a 2D perspective, so he will always face the exact same angle when walking a particular way - For example, it might always set his angle so he faces the left of the map, this wouldn't matter because it is only using 2 dimensions anyway.


http://wiki.eduke32.com/wiki/Ang

Is that what you want? I'm confused by your post.

It sounds like you want the player to automatically turn around each time he reverses direction, like in Contra and a lot of other 2D games. That means he won't be able to run backwards, which I think is a shame, because running backwards while firing is useful. If I were coding it I would make use of the existing turn around key and allow moving backwards to function normally (albeit with an enforced corridor relative angle).

EDIT @XThX2: What do you imagine he is going to do with that code? If you are trying to help an inexperienced person by posting code, you should make sure that it actually works, otherwise it just creates more confusion.

This post has been edited by DeeperThought: 07 September 2009 - 01:41 AM

0

#287

@xthx2
Can't seem to get that working, I fiddled with it a fair amount but just end up with errors, I will keep messing about with it.

@deeperthought
The problem with ang is that it makes the player face that way, so he is moving in the same direction when pressing that key as he was when pressing the other key. Also it causes the camera to face the other way (through a wall usually) and thus I have to tell the camera which way to face in the same event, which usually works but causes occasional flickering.

I guess I could always come up with a weird control scheme where you press the up key to move the player in the direction he is facing and you use the arrow keys to select the way you want him to face, I have played games with a similar scheme but they were top-down view - in fact I think I will give this a go and see how it feels, but my natural instinct when playing a side-scroller (which i spend 80% of my time doing) is to use traditional sidescrolling controls, so it would take some getting used to and I imagine other people wouldn't be too happy with it either.



I'm actually quite enjoying playing about with the codes, even when I get things wrong, interesting results sometimes occur, such as today I somehow managed to disable the gravity and the player exploded as soon as the level started, then you could not start a new game or restart the level, no idea how I managed that by just be messing with the health bar code.
0

User is offline   XThX2 

#288

Well I thought he just asked making the player face the opposite direction, so I gave him what he wanted. If he needs a full working code, I can just explain the way he could do it.

onevent EVENT_MOVEFORWARD
ifvare mykeypress 1 nullop else
{
	getplayer[THISACTOR].ang angle	
	addvar angle 1024
	setplayer[THISACTOR].ang angle
	setvar mykeypress 1
}
endevent

onevent EVENT_MOVEBACKWARD
ifvare mykeypress 2 nullop else
{
	getplayer[THISACTOR].ang angle	
	subvar angle 1024
	setplayer[THISACTOR].ang angle
	setvar mykeypress 2
}
endevent


Here's the working code, in any case. I've used my own variables. In case you might need, define these at defs.con or user.con.

gamevar mykeypress 0 1
gamevar angle 0 1

This post has been edited by XThX2: 07 September 2009 - 03:05 AM

0

#289

I really appreciate the help but that code has the problem where the player is basically walking the same way as he was before because he is now walking backwards when facing the opposite way, it's like if I walked north, then turned and faced south and walked backwards, I would still be going north.

Eventually i did this;

onevent EVENT_DISPLAYREST

setvar cameradist 200000
setplayer[THISACTOR].look_ang angle
endevent

onevent EVENT_GAME
setplayer[THISACTOR].look_ang angle
endevent


onevent EVENT_TURNLEFT
	setvar angle 512
	setplayer[THISACTOR].ang 1024
endevent

onevent EVENT_TURNRIGHT
	setvar angle 1536
	setplayer[THISACTOR].ang 0
endevent


For some reason I also have to do "setplayer[THISACTOR].look_ang angle" under EVENT_GAME or else a horrid flicker occurs, i figure this is somewhat inefficient, but it runs on my Athlon XP so it can't be that bad, the controls in this manner are surprisingly fluent (i think that's the word) - at the moment the camera is facing forward when the game starts, but I think I know how to fix that (rearrange the code a bit and probably define "angle" as 1536 at the top of the .con).
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#290

How do can I diff beetween the player and a Holoduke in EVENT_EGS? Even statnum doesn't work.

This post has been edited by Ilovefoxes: 07 September 2009 - 07:53 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#291

View PostIlovefoxes, on Sep 7 2009, 08:52 PM, said:

How do can I diff beetween the player and a Holoduke in EVENT_EGS? Even statnum doesn't work.


Yeah, they both have statnum 10, which is weird. Try "ifspawnedby APLAYER" which is only true for the hologram.

EDIT: This should work also -- ifvarvarn THISACTOR player[THISACTOR].i // hologram if true

This post has been edited by DeeperThought: 07 September 2009 - 08:10 PM

0

User is offline   TerminX 

  • el fundador

  #292

High Treason, that code is wrong on many levels.

Ilovefoxes: it doesn't look like you can in a reliable way. You would be much better off intercepting EVENT_HOLODUKEON and spawning the sprite yourself.
0

User is offline   XThX2 

#293

That Holoduke thing was discussed on 3D Realms Forums before. You can check there for replies. (I Think it was DeeperThought who answered, too)

HightTreason, check this. "bits"
0

Share this topic:


  • 124 Pages +
  • « First
  • 8
  • 9
  • 10
  • 11
  • 12
  • 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