
EDuke32 Scripting "CON coding help"
#713 Posted 07 November 2011 - 03:03 PM
#714 Posted 07 November 2011 - 04:52 PM

With that problem solved I should be able to finish it on my own now as it seems to be working now that I've changed to displayrooms, I've added a couple more features now, using AI (faceplayerslow) to make the camera face the player, though I will have to devise a way to make the camera look up and down, I know how to make it do this, it's just getting my math right to get the correct angle, shouldn't be too hard. I'm also going to add some kind of delay before switching camera.
In case anyone is interested, this is how it currently looks.
This post has been edited by High Treason: 07 November 2011 - 04:53 PM
#715 Posted 07 November 2011 - 06:58 PM
#716 Posted 14 November 2011 - 03:22 PM
// Following camera useractor notenemy FOLLCAM 1 getactor[THISACTOR].hitag camtag2 cstat 32768 // ifvarvare camtag camtag2 // This does not work unless I remove the "move" command, but I use a different actor for that. camtag is the hitag of the camera activator sprite. ifpdistl 15361 // This is the only way I can get cameras that use "move" to operate, not ideal. { // These vars are later used in event_displayrooms, they set the camerax, cameray etc... getactor[THISACTOR].ang CAMA getactor[THISACTOR].x CAMX getactor[THISACTOR].y CAMY getactor[THISACTOR].z CAMZ getactor[THISACTOR].xvel CAMH } ifmove 0 { move FOLLMOVE faceplayerslow } enda
I hate being a noob at this, I think I'm learning, I've managed to get several other things right (well, working...) at the first attempt now. I guess it's possible that the engine simply doesn't want me to do something like this.
Thanks for any help, as usual, I don't expect this to be re-written for me, just point me in the right direction and I'll experiment until I get it right, I'm just at a dead-end with it right now.
#717 Posted 14 November 2011 - 04:23 PM
So you should make something like this:
( declare HITAGSAVED or whatever you want as a per-actor variable)
eventloadactor FOLLCAM
getactor[THISACTOR].hitag HITAGSAVED
setactor[THISACTOR].hitag 0
enda
Then use directly when needed " ifvarvare camtag HITAGSAVED" in the FOLLCAM actor.
I hope this can solve the problem.
This post has been edited by RichardStorm: 14 November 2011 - 04:24 PM
#718 Posted 14 November 2011 - 05:20 PM
Now I know it's possible to operate actors with AI using variables (I was beginning to think it wasn't) my head is filling with ideas, robots, remote controlled cars and all manner of things I will probably never do.

#719 Posted 15 November 2011 - 04:25 PM
This is how my episode is defined in the con file, and it works as expected:
definevolumename 4 Micky's Revenge (WIP) definelevelname 4 0 wgmicky1.map 03:00 00:52 The Shire definelevelname 4 1 wgmicky2.map 02:30 01:19 Turn of the Tide
And this is how I defined the music:
music 4 wgmicky1.ogg wgmicky2.ogg
Is there anything painfully obvious as to why it's not working?
#720 Posted 15 November 2011 - 04:31 PM
Micky C, on 15 November 2011 - 04:25 PM, said:
Yup. You should be using music 5, not music 4. Music 0 == title screen, music 1 == episode 1, etc.
#721 Posted 17 December 2011 - 11:07 AM
Right now, spawning many rain or snow sprites can heavily degrade performance because of how actors are moved, namely that they clip against other blocking sprites regardless of their own blocking bit. Each such sprite has to check for potential collision with any other sprite in its sector, leading to quadratic run time. r2184 introduces a new actor[].flags bit (settable with 'spriteflags' from CON) that forces them to not clip against any other sprite, again regardless of its blocking bit. The significance of this is that then, the sprite collision check in clipmove() can be skipped entirely, removing the quadratic runtime behavior.
So, assuming you have e.g.
define RAINSPRITE 2287
in your mod, add
spriteflags RAINSPRITE 2048
after the first line and enjoy a significant performance boost with many rain or snow sprites on the screen.
NOTE: This fix will be negated from the time an old savegame is loaded. (That is, even after starting a new game!)
#722 Posted 17 December 2011 - 11:25 AM
#724 Posted 17 December 2011 - 08:25 PM
Helixhorned, on 17 December 2011 - 11:07 AM, said:
Right now, spawning many rain or snow sprites can heavily degrade performance because of how actors are moved, namely that they clip against other blocking sprites regardless of their own blocking bit. Each such sprite has to check for potential collision with any other sprite in its sector, leading to quadratic run time. r2184 introduces a new actor[].flags bit (settable with 'spriteflags' from CON) that forces them to not clip against any other sprite, again regardless of its blocking bit. The significance of this is that then, the sprite collision check in clipmove() can be skipped entirely, removing the quadratic runtime behavior.
So, assuming you have e.g.
define RAINSPRITE 2287
in your mod, add
spriteflags RAINSPRITE 2048
after the first line and enjoy a significant performance boost with many rain or snow sprites on the screen.
NOTE: This fix will be negated from the time an old savegame is loaded. (That is, even after starting a new game!)
Wait what? So... if they start a new game, save, and come back later their fps will be cut massively? Does that still apply if used per-sprite vs per-tile.
#725 Posted 17 December 2011 - 09:13 PM
Mblackwell, on 17 December 2011 - 08:25 PM, said:
Helix was just saying that if you load a saved game that was created with old CON code from before the new flag was added, then that CON code will be in effect until you quit EDuke32 and run it again. It has always worked that way, he was just pointing it out.
#726 Posted 18 December 2011 - 07:01 AM
#727 Posted 05 January 2012 - 06:21 AM
I recoded the devastator, so i shoot the first rocket of the two round burst as the normal weaponX_shoots variable, while the second is fired with "shoot MINIROCKET" (a new projectile) when kickback_pic reaches the proper value. The problem is that while strafing and/or running the second rocket often collides with the player, hurting him. I tested many combination of VEL and VEL_MULT, CLIPDIST, X and Y REPEAT, OFFSET, but the problem persists.
Here is the part of the code related to the new rocket:
action MROCKACTION 0 0 5 1 0 useractor notenemy MINIROCKET 0 MROCKACTION enda defineprojectile MINIROCKET PROJ_WORKSLIKE 4098 defineprojectile MINIROCKET PROJ_EXTRA 50 defineprojectile MINIROCKET PROJ_HITRADIUS 1024 defineprojectile MINIROCKET PROJ_CSTAT 128 defineprojectile MINIROCKET PROJ_XREPEAT 32 defineprojectile MINIROCKET PROJ_YREPEAT 32 defineprojectile MINIROCKET PROJ_VEL 600 defineprojectile MINIROCKET PROJ_VEL_MULT 2 defineprojectile MINIROCKET PROJ_CLIPDIST 0 // and other thing as spawns, trails, sounds etc // in APLAYER actor... // this alternates the offset for left-right barrel ifvare sideswitch 0 setprojectile[MINIROCKET].offset 192 else ifvare sideswitch 1 setprojectile[MINIROCKET].offset -192 // this fires the second rocket ifvare player[THISACTOR].kickback_pick 5 { shoot MINIROCKET } // (and other things as sounds etc) // in event EVENT_EGS, switch PICNUM etc... case MINIROCKET state randomtraj break // it adds/subtract random values to zvel and ang
I'm 99% sure it's a problem about setting the right PROJ_CLIPDIST. I could have the same problem with any projectile fired with the "shoot" command and similar; using weapon flags as the original devastator make minirockets work properly without collisions with the player (but the timing isn't correct)
Anyone can help me ?
This post has been edited by RichardStorm: 05 January 2012 - 06:35 AM
#728 Posted 05 January 2012 - 08:22 AM
#729 Posted 05 January 2012 - 11:57 AM
#730 Posted 05 January 2012 - 12:25 PM
DeeperThought, on 05 January 2012 - 08:22 AM, said:
They hit a force field before reaching the target.
#731 Posted 05 January 2012 - 01:08 PM
EDIT : Doesn't clipdist of projectile determine how far from the floor/ceiling it explodes ?
This post has been edited by XThX2: 05 January 2012 - 01:09 PM
#732 Posted 06 January 2012 - 09:26 AM
I tried to fire the projectile by setting initial X and Y as an emulation of proj_offset (i used trigonometry instead of rotatepoint). The result is that rockets work better the more distant they are spawned from the player, but they explode anyway mantaining a reasonable distance, or they seem to appear in the air.
I could use this method, but doesn't work at 100%. I'm thinking to disable running while firing with new devastator.
This clipdist issue can be very frustrating to control in other cases, i think there is a simplier solution (and 100% working) by setting some flags or attributes... or is an engine bug... i don't know.
//EDIT : There are also a few new projectiles (FIRELASERs) for which changing proj_clipdist doesn't change the fact they hit things with a clipsize of about 300- 400 build unit...
This post has been edited by RichardStorm: 06 January 2012 - 09:38 AM
#733 Posted 06 January 2012 - 12:45 PM
RichardStorm, on 06 January 2012 - 09:26 AM, said:
I'm pretty sure that the projectile structure is only intended for custom projectiles, not hardcoded ones like FIRELASER. To change hardcoded projectiles, try using the sprite structure (no guarantees there either, though).
As for your problem, it's one of those things that I would be able to fix if it were in my mod, but I don't know what to suggest for you given the information I have.
#734 Posted 07 January 2012 - 04:06 PM
This post has been edited by Hendricks266: 07 January 2012 - 04:06 PM
#735 Posted 10 February 2012 - 09:29 AM
eventloadactor HYPNOSCREEN getactor[THISACTOR].hitag hitagsaved setactor[THISACTOR].hitag 0 enda // ^^ Eventloadactor code for the screen. Just grabs the actor's hitag value. action HS_STANDBY 0 0 1 1 56 action HS_STATIC 1 5 1 1 10 action HS_PRESENT 6 0 1 1 56 action HS_LSD 7 0 1 1 56 // ^^ These are the different "screens" that the actor flickers to. Each screen changes out after an intermittent bout of static (the second action listed), and it all loops around to the STANDBY screen. useractor notenemy HYPNOSCREEN 0 HS_STANDBY getactorvar[THISACTOR].hitagsaved temp1 ifvarn temp1 0 { // if the actor's hitag is a nonzero value... ifaction HS_STANDBY { // if it's on the STANDBY screen. stopsound WHITENOISE //stop the WHITENOISE sound soundonce AMBIENCE7 // and start this AMBIENCE sound ifactioncount 10 { action HS_STATIC addvar temp2 1 break } // when its actioncount hits 10, start the STATIC action, and add 1 to variable "temp2" } else ifaction HS_PRESENT { stopsound WHITENOISE ifactioncount 10 { action HS_STATIC addvar temp2 1 break } } else ifaction HS_LSD { stopsound WHITENOISE ifactioncount 10 { action HS_STATIC addvar temp2 1 break } } // ^^ The other actions pretty much do the same thing, apart from playing the AMBIENCE7 sound else ifaction HS_STATIC { // if the STATIC action is playing... stopsound AMBIENCE7 soundonce WHITENOISE // stop the AMBIENCE7 sound, and start the WHITENOISE sound. ifactioncount 40 { // when the actioncount hits 40... ifvare temp2 1 { action HS_PRESENT break } // if the temp2 variable is only at 1, start the HS_PRESENT action. else ifvare temp2 2 { action HS_LSD break } // if it's at 2, start the LSD action. else ifvare temp2 3 { action HS_STANDBY setvar temp2 0 break } // if it's at 3, take it back to the STANDBY action, and reset the temp2 variable to zero, so it can all start over again. } } } enda
Again, this actor works just fine. There's no warnings, no errors, no bugs when it's doing its thing in-game. The game only crashes when I attempt to exit, and since that happens, eDuke can't spit out a log over it either. I've narrowed the problem with this actor down to the sound commands being used. When I first wrote the code, I was only using the WHITENOISE sound (no AMBIENCE7) and I was using the stopactorsound to stop it, for obvious reasons. When I noticed the crash, I changed it to just stopsound, and the crashes became less frequent. But then I added the AMBIENCE7 sound, and it's gone right back to crashing nearly every time I try to exit. Is it how I've set up the code, or am I just using the commands in a way they're not intended to be used?
#736 Posted 10 February 2012 - 11:47 AM
#737 Posted 11 February 2012 - 04:47 AM
DeeperThought, on 10 February 2012 - 11:47 AM, said:
Well, in this case it really isn't random, which is why I brought it up. And while the frequency with which it's happening (nearly every time) is definitely a problem, it isn't just that; the crash is happening on too consistent and too manageable of a basis. If I'm in a map that doesn't have the actor in it, the crash never occurs. If I take all of the sound commands out of the actor, it won't happen either. If I just use the WHITENOISE sound, it happens the majority of the time, and if I use both sounds, it happens every time without fail. I shuffled a few lines of the actor's code around last night so it'd run a bit more efficiently, but nothing's changed, and different builds of eDuke don't give me any different results either. I shouldn't make a big deal out of it, and essentially I'm not since I can just keep the sounds out, push comes to shove. But the whole thing still seems weird, and while I've dealt with exit crashes too, this one seems like its in a league of its own.
*EDIT*
And not even an hour after I posted this, I checked the actor out in-game once more, and the crash isn't happening at all now if I just use the WHITENOISE sound (though it'll still crash every time if the other sound is included). I don't know what the fuck...
This post has been edited by EmericaSkater: 11 February 2012 - 05:38 AM
#738 Posted 11 February 2012 - 05:55 AM
edit: most conveniently in a zip to just -gTHE.zip and run it...
#739 Posted 19 February 2012 - 08:03 PM
EDIT: Another thing, while bugging out my player into the floor I discovered a kind of neat bug(?). Would there be any way to reproduce the weapon motions here via con?
This post has been edited by Wolf: 19 February 2012 - 09:26 PM
#740 Posted 20 February 2012 - 02:27 AM
#741 Posted 21 February 2012 - 07:51 PM
setvar x <SOME_X_POSITION> addvarvar x weapon_xoffset subvarvar x looking_angSR1 setvar y <SOME_Y_POSITION> addvarvar y looking_arc subvarvar y gun_pos
Then modify the player member look_ang:
http://wiki.eduke32.com/wiki/Look_ang
Eg:
setplayer[THISACTOR].ang 1536 getplayer[THISACTOR].angvel ANGVEL getplayer[THISACTOR].look_ang LOOK_ANG addvarvar LOOK_ANG ANGVEL setplayer[THISACTOR].angvel 0
Should give you the general effect. Note that you won't be able to physically turn*, but it will give the impression that you're turning your head around. Have fun!
*Obviously modify the code to fit your design and desires.
#742 Posted 24 February 2012 - 03:35 PM
I used some of the weapon structures here http://wiki.eduke32....layer_structure
Have fun :S
This post has been edited by rasmus thorup: 24 February 2012 - 03:38 PM