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

User is offline   lycanox 

#294

View PostIlovefoxes, on Sep 8 2009, 05:52 AM, said:

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

Both are essentially the same actor. (Which is probably how the game fools enemies to attack it. )

If you want the holoduke actor to actually do simple stuff. Ifpdistg 1000 or ifspawnedby APLAYER might have some effect.
(However do seem have side effects while teleporting or jet packing against a ridge.)

However, the best method I found is to spawn your own actor and quickly turn the holoduke off to get rid of the holoduke actor.

XThX2 said:

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

I was the one that asked it back then. And came to the same conclusion.

This post has been edited by lycanox: 08 September 2009 - 04:11 AM

0

User is offline   Chip 

#295

I'm getting a lot of console errors relating to the dist command not working because its trying to get a distance to an invalid sprite.
I don't have access to my computer now so I can't give you my exact code (I'll try tomorrow) but here's the gist of it:

When my actor has a positive value from his htextra he'll then do the following (plus more but that's not relevent)

gamevar MYENEMY -1 2 // records who my actor will attack
gamevar DTEMP1 -1 2 // records the ID of what projectile (or attack) that hit the actor
gamevar DTEMP2 0 2 // used as a temp value
gamevar DTEMP3 -1 2 // records the ID of who shot the actor or inflicted damage if melee
gamevar RECORD1 -1 2 // used as a temp, in this case it'll record the distance obtained through the dist command
gamevar RECORD2 -1 2 // used as a temp, in this case it'll record the distance obtained through the dist command





ifvare DTEMP3 -1 // you were hit but this value was not set meaning it was a projectile that hit the actor
{
   getactor[THISACTOR].htowner DTEMP3 // know who's hit you
   getactor[THISACTOR].htpicnum DTEMP1 // know what's hitting you
}

ifvare MYENEMY -1 setvarvar MYENEMY DTEMP3 // if you have no enemy ID then treat who hit you as the enemy
else // you had an enemy ID but now you have 2!
{

 ifvarg MYENEMY -1 // you have an enemy ID
	 {
	  getactor[MYENEMY]statnum DTEMP2 
	 ifvarn DTEMP2 1024 dist [RECORD1] [THISACTOR] MYENEMY
	 }
 else setvar RECORD1 99999

 ifvarg DTEMP3 -1 // you have an ID of the projectile's owner
	   {
	   getactor[DTEMP3]statnum DTEMP2 
	   ifvarn DTEMP2 1024 dist [RECORD2] [THISACTOR] DTEMP3
	   }
 else setvar RECORD2 99999

 ifvarvarl RECORD2 RECORD1 setvarvar MYENEMY DTEMP3 // the new enemy is closer so record his ID!
}
setvar DTEMP1 -1 // erase the knowledge of who hit you - its no longer needed.
setvar RECORD1 -1
setvar RECORD2 -1


My errors bascally say something like that "error with dist - invalid sprite" meaning the actor does not exist but I made sure its being checked for with the statnum checking.....

This post has been edited by Chip: 08 September 2009 - 12:33 PM

0

User is offline   XThX2 

#296

Why are the variables in parantheses ? Also you forgot a "." with statnum of DTEMP2. Check if RECORD2 is -1 before initiating the dist command, too.
0

User is offline   Chip 

#297

View PostXThX2, on Sep 8 2009, 09:27 PM, said:

Why are the variables in parantheses ?


If you're refering to the [ ] on a gamevar in the dist command, that's because the game throws a fit if I don't put them on saying stuff like "RECORD1" is not a game array...


Quote

Also you forgot a "." with statnum of DTEMP2.

Ignore that, I've just written this out now so things like that which would cause the game to not load up don't exist in my real code.


Quote

Check if RECORD2 is -1 before initiating the dist command, too.


I'm going to have to but I didn't get time today but the fact is by rights the game shouldn't read those dist commands if my actor doesn't have an enemy ID or if so then not if it has a statnum of 1024.

This post has been edited by Chip: 08 September 2009 - 12:32 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#298

I don't feel like wading through that code to find the errors, but in general you should never assume that a variable holds a valid sprite ID. Always check to make sure it is not -1. Even htowner can be -1 sometimes, I've seen it happen.
0

User is offline   Chip 

#299

View PostDeeperThought, on Sep 8 2009, 09:45 PM, said:

I don't feel like wading through that code to find the errors, but in general you should never assume that a variable holds a valid sprite ID.


Here's a quick run down where the error happens:

ifvarg DTEMP3 -1 // you have an ID of the projectile's owner
	   {
	   getactor[DTEMP3]statnum DTEMP2 
	   ifvarn DTEMP2 1024 dist [RECORD2] [THISACTOR] DTEMP3
	   }
else setvar RECORD2 99999



If the gamevar DTEMP3 holds a value of 0+ then check its existance with the statnum. If the statnum gamevar is not 1024 then check the distance between the actor and the enemy id that DTEMP3 holds.


I'm going to have to post my actual code tomorrow but I'm certain there's no difference between this and that...with the exception that the main code checks to make sure the actor THISACTOR actually exists incase it was somehow running this state from beond the void.
0

User is offline   Danukem 

  • Duke Plus Developer

#300

View PostXThX2, on Sep 8 2009, 01:27 PM, said:

Why are the variables in parantheses ? Also you forgot a "." with statnum of DTEMP2.


Right, but it's not his "actual code", so it's waste of our time to even look at it.
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