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

Jump to content

  • 124 Pages +
  • « First
  • 60
  • 61
  • 62
  • 63
  • 64
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Zaxtor 

#1831

It works but how we reverse it.
So the thing "undo" the blocking first wall?

I have a global tempb1,2,3 or so (works the same) as temp

This post has been edited by Zaxtor: 19 January 2016 - 06:26 PM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1832

View PostThe Mechanic, on 19 January 2016 - 05:09 AM, said:

Any ideas ?

It's tricky, the wall pushing sound is checker internally only for hard-coded operators. I suppose stopactorsound <actor> <sound> with the player actor id should work, but I haven't tested it. It's also not a 100% solution since theoretically it would cut the sound after it has been playing for 1 tic.
0

User is online   Danukem 

  • Duke Plus Developer

#1833

View PostThe Mechanic, on 19 January 2016 - 05:09 AM, said:

the undocumented EVENT_WORLD


What is that?
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1834

It's like EVENT_GAME but it doesn't run from any actor.
0

User is online   Danukem 

  • Duke Plus Developer

#1835

View PostFox, on 20 January 2016 - 01:37 AM, said:

It's like EVENT_GAME but it doesn't run from any actor.


And it happens once per game tic?

So, in singleplayer, what would be the advantage of using EVENT_WORLD over executing code from the player actor?
0

#1836

View PostZaxtor, on 19 January 2016 - 06:26 PM, said:

It works but how we reverse it.
So the thing "undo" the blocking first wall?

I have a global tempb1,2,3 or so (works the same) as temp


Replace the

orvar temp2 1


with either

andvar temp2 32766


(32767 minus the-value-you-are-trying-to-remove)

or, if you _know_ the wall is already blocking,

xorvar temp2 1


The latter method is more useful when dealing higher bits as the maths is easier :thumbsup:

View PostFox, on 19 January 2016 - 10:09 PM, said:

It's tricky, the wall pushing sound is checker internally only for hard-coded operators. I suppose stopactorsound <actor> <sound> with the player actor id should work, but I haven't tested it. It's also not a 100% solution since theoretically it would cut the sound after it has been playing for 1 tic.


I tried that way first but as you said you still get a short burst of the sound. Sounded longer than 1/30th of a second too, wonder if there is a delay between stoping a sound and it actually stopping, such as letting a audio buffer finish emptying or something (not that that would normally be an issue, just curious).

View PostTrooper Dan, on 19 January 2016 - 11:43 PM, said:

(EVENT_WORLD) What is that?


I empirically found out that it runs once per game tic. Because my sound hack worked I think the sequence really is:

(Eduke does hardcoded wall detection, plays sounds)
EVENT_WORLD
EVENT_GAME * lots

and not

(Eduke does hardcoded wall detection, plays sounds)
EVENT_GAME * lots
EVENT_WORLD

Basically I intercepted every game event and logged a different number when each ran so I could see the order in which things ran and discovered EVENT_WORLD which until then I wrongly assumed was related to initialisation. Don't like resorting to undocumented events but EVENT_WORLD can be useful.

TTFN,
Jon
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1837

View PostTrooper Dan, on 20 January 2016 - 01:48 AM, said:

And it happens once per game tic?

So, in singleplayer, what would be the advantage of using EVENT_WORLD over executing code from the player actor?

If you are using the player, theoretically the same code would be compiled several times in multiplayer.

There are three events, PRELEVEL, PREWORLD and WORLD. They are equivalents to LOADACTOR, PREGAME and GAME except they doesn't originate from any sprite. To use commands that depends on the ID of an sprite such as spawn or ifp you can set the userdef structures vm_sprite, vm_player and vm_distance (ID of the current sprite, ID of the closest player and distance to the player).

There are several advantages with this. You don't need to find a sprite or player to run a global code, which is an ugly hack. If there are no actors in the map, it's impossible to do something during EVENT_LOADACTOR. If you run a code that affects all actors in the map, you don't have to worry about which actor will have the code compiled first of last during the same tic (the player for example probably won't be the first or last actor).

This post has been edited by Fox: 20 January 2016 - 10:48 AM

1

User is offline   Hendricks266 

  • Weaponized Autism

  #1838

The idea behind EVENT_WORLD is that EVENT_GAME is terribly inefficient. It is a lot of overhead to run an event for every actor, only to conditionally branch X number of times, where X is the number of actors you want to control with EVENT_GAME. EVENT_WORLD lets you loop through actors only in the ways you need, such as with the spritesect and spritestat linked lists.
2

User is online   Danukem 

  • Duke Plus Developer

#1839

Thanks, guys. So it works the way that one would expect it to work.

I will say this in defense of EVENT_GAME: It's convenient to be able to reference actors with THISACTOR or simply [], and if used properly, a great deal of the overhead can be avoided. What I do is run a switch statement on the picnums of interest, then I use the htflag which prevents sprites from being processed in that event for the default case. That way, only sprites of interest will be processed in the event after the first game tic.

From the sound of it, EVENT_WORLD is a better choice when I want to process entire statnums (e.g. doing something to all of the projectiles).
1

#1840

View PostTrooper Dan, on 20 January 2016 - 12:01 PM, said:

What I do is run a switch statement on the picnums of interest, then I use the htflag which prevents sprites from being processed in that event for the default case. That way, only sprites of interest will be processed in the event after the first game tic.


Cool. I hadn't realised SFLAG_NOEVENTS existed and like you I use EVENT_GAME plus a switch statement for my stuff.

TTFN,
Jon
0

#1841

Ah .. I ran Holywood Holocaust with and without using SFLAG_NOEVENTS in EVENT_GAME and can see no difference in frame rate. Are direct writes to htflags actually ignored ? The reason I ask is that I previously scrapped an idea because writing to htflags didn't work. For example, the new feature to make items slimer-edible, I did:

        // Temp1 = what to make edible eg 4670 (NEWBEASTHANG)

	getactor[THISACTOR].sectnum temp5

	headspritesect temp5 temp5
	whilevarn temp5 -1
	{
		getactor[temp5].picnum temp6
		ifvarvare temp6 temp1
		{			
			addlogvar temp6	

			getactor[temp5].htflags temp6
			orvar temp6 8388608 // SFLAG_GREENSLIMEFOOD
			setactor[temp5].htflags temp6
			
			// Just so I know it did something :thumbsup:
			addlogvar temp5
			addlogvar temp6
		}
		nextspritesect temp5 temp5
	}


Like SFLAG_NOEVENTS this too had absolutely no effect (using r5501).

TTFN,
Jon
0

User is online   Danukem 

  • Duke Plus Developer

#1842

I know that it used to work, and that in some of my mods it did make a significant difference to framerate. To test whether it is working now, you could set the flag on a sprite and then have it log its ID in the event; if it keeps logging, then it's not working.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1843

View PostThe Mechanic, on 20 January 2016 - 02:01 PM, said:

Ah .. I ran Holywood Holocaust with and without using SFLAG_NOEVENTS in EVENT_GAME and can see no difference in frame rate. Are direct writes to htflags actually ignored ?

I wouldn't expected it to increase the performance to an extend you can actually notice the difference, except for a mod that uses EVENT_GAME a gazillion of times.

View PostThe Mechanic, on 20 January 2016 - 02:01 PM, said:

The reason I ask is that I previously scrapped an idea because writing to htflags didn't work. For example, the new feature to make items slimer-edible, I did:

The slimer code check the tilenum of the sprite. So you have to set the flag to the tile, not the actor.

Use it outside of any actor or event:
spriteflags NEWBEASTHANG 8388608

1

#1844

View PostTrooper Dan, on 20 January 2016 - 02:20 PM, said:

I know that it used to work, and that in some of my mods it did make a significant difference to framerate. To test whether it is working now, you could set the flag on a sprite and then have it log its ID in the event; if it keeps logging, then it's not working.


OK, tried that and SFLAG_NOEVENTS does seem to work, phew ! Perhaps it'll really pay when there is a lot going on (projectiles, snow effects, that kinda thing). Anyhow, does no harm so shall use it.

Which just leaves the issue of why SFLAG_GREENSLIMEFOOD isn't working - ah, wait a mo ....

View PostFox, on 20 January 2016 - 02:42 PM, said:

The slimer code check the tilenum of the sprite. So you have to set the flag to the tile, not the actor.

Use it outside of any actor or event:
spriteflags NEWBEASTHANG 8388608



D'Oh. As htflags is a per-sprite variable I assumed you could set it on an individual sprite. Drats. And double drats :thumbsup: So, is there a way of modifying the flag from _inside_ EVENT_GAME (even if it means affecting all sprites of the same picnum) ?

TTFN,
Jon
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1845

Like I said, the slimer is hard-coded to check the tilenum, so it's not supposed to be set in-game. This way it should also be possible to define flags for sector or wall textures, such as breakable monitors.
0

#1846

That's a shame. Being able to "do something" to an enemy in-game to make it edible did open up a few possibilities.

TTFN,
Jon
0

User is online   Danukem 

  • Duke Plus Developer

#1847

View PostThe Mechanic, on 20 January 2016 - 03:44 PM, said:

That's a shame. Being able to "do something" to an enemy in-game to make it edible did open up a few possibilities.


Most of those flags do work in-game. The slimer flag just isn't one of them.
0

#1848

View PostTrooper Dan, on 20 January 2016 - 10:21 PM, said:

Most of those flags do work in-game. The slimer flag just isn't one of them.


OK. Which ones ? Hang on, I've just looked at the wiki page again and notice some flags have a "Provided CON Label" and some don't, is it the ones that don't that can't be modified in-game ?

TTFN,
Jon

PS: Who do I have to ask about being given the ability to edit the wiki ? There's a fair bit of missing detail I could add.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #1849

View PostThe Mechanic, on 21 January 2016 - 02:17 AM, said:

PS: Who do I have to ask about being given the ability to edit the wiki ? There's a fair bit of missing detail I could add.

All you have to do is create an account. The prompt to give us a certain amount of text about yourself is an anti-spam feature that has reduced our wiki vandalism to zero, so figure something out that will let us know that you're human and we'll approve it.
1

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1850

View PostTrooper Dan, on 03 January 2016 - 04:47 PM, said:

I know this was covered a long time ago, but could someone explain why it would be prohibitively difficult to enhance CON language so that we can do things like this:

addvar sprite[THISACTOR].z 1024


A great deal of writing CON code involves getting struct members into variables and then manipulating those variables before putting them back into the structs. It makes for a lot of typing and it reduces readability.

I just wanted to add that this is mostly impossible to work out. It would be limited to the number of bits available to each structure members, unlike gamevars which all use 16 bit.

For example, if I wanted to make a sprite with a consistent size regardless of the height in pixels of the tile:
setactor[].xrepeat 64
shiftl sprite[].xrepeat 6
div sprite[].xrepeat tilesizy[MYTILE]

This would not work because xrepeat is limited to 8 bit (0-255), and the value would overflow in the second line.

This post has been edited by Fox: 24 January 2016 - 07:58 AM

0

User is online   Danukem 

  • Duke Plus Developer

#1851

View PostFox, on 24 January 2016 - 07:58 AM, said:

This would not work because xrepeat is limited to 8 bit (0-255), and the value would overflow in the second line.


That would be user error, though. How is that worse than setting xrepeat to an invalid value using setactor?
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1852

It's different. The final value is within the limit of the .xrepeat, however it temporary sets to an invalid value during calculation.
0

User is offline   Kyanos 

#1853

Can i stop the 7 key from bringing up the expander when the player has the shrinker selected?

I tried this:
onevent <EVENT_WEAPKEY7>
{
  setvar RETURN 6
}
endevent


which I thought would do it, then experimented with curr_weapon checks and never got it to work at all.


EDIT:

nevermind I got it figured out.

This post has been edited by Drek: 29 January 2016 - 09:24 PM

0

#1854

Via CON scripting is it possible to pause background music and later restore it to it's previous state ?

TTFN,
Jon
0

User is offline   Hendricks266 

  • Weaponized Autism

  #1855

Yes, in a roundabout way. First getmusicposition, then starttrack to a blank.ogg. When you're done starttrack back to your current level and setmusicposition.
1

#1856

View PostHendricks266, on 01 February 2016 - 01:43 PM, said:

Yes, in a roundabout way. First getmusicposition, then starttrack to a blank.ogg. When you're done starttrack back to your current level and setmusicposition.


Excellent :dukeaffirmative: In order to avoid modifying DEFS.CON I saved my alternative sound track as "watrwld1.ogg" (==e1l4) and used "starttrack 3" and that worked a treat.

Is there a way of getting Eduke to always look for alternative tracks in the same folder as the map that is running ? I know in the startup screen there is a dropdown where you specify the appropriate folder and obviously that works but it is easilly overlooked.

TTFN,
Jon
0

User is offline   Zaxtor 

#1857

Having little trouble making a projectile that is thrown (upward-diagonally)
then falls, bounces few times and explodes.
When I tried other ways it doesn't bounce high.

I've tried OFFSET, Similar to a spit etc.
It partially works but not much.

I want the projectile to "aim" at the player but if I use RPG style (WORKSLIKE 2) it wont bounce but will explode on impact.

defineprojectile 16270 PROJ_WORKSLIKE (???what to put to do like in the picture below???)
defineprojectile 16270 PROJ_TRAIL SMALLSMOKE
defineprojectile 16270 PROJ_CLIPDIST 19
defineprojectile 16270 PROJ_VEL 911
defineprojectile 16270 PROJ_VEL_MULT 4 (speed may change if too fast since throwing and RPG speed seems to be different)
defineprojectile 16270 PROJ_EXTRA 410
defineprojectile 16270 PROJ_OFFSET 224 (like a morter but doesn't work right probably due to wrong WORKSLIKE)
defineprojectile 16270 PROJ_DROP -131
defineprojectile 16270 PROJ_BOUNCES 4
defineprojectile 16270 PROJ_BSOUND HARDIMPACT
defineprojectile 16270 PROJ_HITRADIUS 3666
defineprojectile 16270 PROJ_XREPEAT 18
defineprojectile 16270 PROJ_YREPEAT 18
defineprojectile 16270 PROJ_ISOUND PIPEBOMB_EXPLODE
defineprojectile 16270 PROJ_FLASH_COLOR 2
defineprojectile 16270 PROJ_SPAWNS EXPLOSION2

Here is the pic in details.
Posted Image

This post has been edited by Zaxtor: 06 February 2016 - 10:45 AM

0

User is online   Danukem 

  • Duke Plus Developer

#1858

I'm not going to check your flags, but make sure that you have used the "loses velocity flag". Your starting speed seems way too high btw. To make it bounce high, you can aim it at the ground. If the projectile falls naturally, then of course it will only bounce based on how fast it was falling. If you want it to bounce higher, then you have to monitor the projectile in EVENT_GAME or EVENT_WORLD and subtract from its zvel at the appropriate time. I will not be providing a tutorial.
0

User is offline   Kyanos 

#1859

View PostZaxtor, on 06 February 2016 - 10:44 AM, said:

I want the projectile to "aim" at the player but if I use RPG style (WORKSLIKE 2) it wont bounce but will explode on impact.


Here is a workslike flag I use for a projectile that bounces off floors and walls without exploding... till reaching numbouces
36870
=
32768 damage on impact for rpg-type (rather than damage only by hitradius)
+
4096 noaim...doesn't autoaim
+
4 bounces off walls

You will want to take out the 4096 for noaim, and add in the timer flag I'd imagine, plus that loses velocity one TD mentioned.

Spoiler

0

User is offline   Zaxtor 

#1860

I kinda found an alternative way to make it work shortly before Dan replied.
proj goes upward then fall (bounced few times and explode)
but semi-aims at you once it finishes going up and then slightly-heading toward you.

Spoiler



However I may use those for diff projectile.
3

Share this topic:


  • 124 Pages +
  • « First
  • 60
  • 61
  • 62
  • 63
  • 64
  • 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