
EDuke32 Scripting "CON coding help"
#1997 Posted 24 June 2017 - 11:48 AM
EDIT: I see Drek is here. I also see a potential problem with my code suggestion. Save us!
This post has been edited by Mark.: 24 June 2017 - 01:42 PM
#1998 Posted 24 June 2017 - 10:08 PM
David B., on 24 June 2017 - 05:27 AM, said:
I tried also 'savegamevar' & 'readgamevar' for "closed 1" thinking it didn't record its value, with no result.
It isn't supposed to happen, since all your code is placed inside the "ifaction 0" condition. Action 0 is the default action for an actor, which can be used to initialize its properties, and as soon as you switch to another action (opening animation), that code is never executed again. Your door actually should have four different states, as actor animations keep looping forever after reaching last frame. Use "ifactioncount" to check for the right time to stop opening animation and put the actor into a fixed opened state (separate action, 'closed' variable isn't needed), from which it can begin closing.
This post has been edited by Jan Satcitananda: 24 June 2017 - 10:10 PM
#1999 Posted 26 June 2017 - 09:21 AM
action OPENING 1 9 0 1 0 action CLOSING 1 9 0 -1 0 state open soundonce 450 action OPENING ends state close // (opened) soundonce 455 action CLOSING resetactioncount ends useractor notenemy TEST_DOOR 0 ifpdistl 1024 ifhitspace ifcansee { ifactioncount 0 { state open break } else { ifactioncount 9 { state close } } } enda
Only the first part is working before the else. Once the door is opened, I hear the same opening sound (450) when I hit space, not the closing sound (455). The door doesn't close.
The script executes each time the open state while actioncount should normally be incremented (or I think so).
This post has been edited by David B.: 26 June 2017 - 09:22 AM
#2000 Posted 26 June 2017 - 10:11 AM
David B., on 26 June 2017 - 09:21 AM, said:
The backwards animation defined with the -1 increment should begin on the tile where the first one ends, not on the same tile as the first one. Also, before going to state close you should be checking whether the action is action OPENING; you don't want it to loop the action CLOSING animation.
Good rule of thumb: if you are having trouble getting an animation to display, test the animation by itself before adding the animation to other code. More generally: when code isn't working and you can't figure out why, isolate the problem by testing individual components of the code. If you don't understand the individual components well enough to test them, then expect problems when you put them together.
#2001 Posted 29 June 2017 - 05:16 PM
I'm creating human enemies. Instead of the enemies growling I want them to just say a few taunting lines. But I don't want them to say "Hey!" every time they see the player. It would get annoying and if I made each type of enemy say something different it would still get repetitive after awhile. It would be nice to get the trooper to say a random set of five lines so it has variety throughout the map. Same with the pig cop and lizard chain gunner guy., etc.
Is it just a line of code to add? I know how to define sounds in the game and know a little bit about .con files. Sometimes it's a matter of changing values. But this seems a little more detailed. Anybody have ideas?
#2002 Posted 30 June 2017 - 12:30 AM
To sum up, instead of playing the recog sound, you would use rand to generate a number then if statements that check the random number to determine which sounds to play.
#2003 Posted 30 June 2017 - 11:42 AM
Drek, on 30 June 2017 - 12:30 AM, said:
To sum up, instead of playing the recog sound, you would use rand to generate a number then if statements that check the random number to determine which sounds to play.
He's going to have a problem if he is using the default enemy tile numbers (PIGCOP, LIZMAN, etc.). The game is hardcoded to play their RECOG sounds when those enemies appear -- there is no CON code for him to edit. So, before he can even do what you suggest, he either has to replace the sounds on the recog sound numbers with null sounds, or write code that detects playback of the recog sounds, stops them and then plays a different random sound.
#2004 Posted 30 June 2017 - 11:45 AM
#2005 Posted 01 July 2017 - 10:04 AM
I have chosen to add tiles for the closing animation in the model instead of using backward animation in the script.
I'm posting it in case someone else would be interested by the script. Here's the feedback :
action OPENING 1 8 1 1 0 action CLOSING 10 8 1 1 0 useractor notenemy OPERABLE_DOOR1 ifaction 0 ifpdistl 1800 ifcansee ifhitspace { soundonce 450 action OPENING cstat 0 } ifactioncount 30 ifaction OPENING ifpdistl 1800 ifcansee ifhitspace { soundonce 455 action CLOSING cstat 1 } ifactioncount 30 ifaction CLOSING ifpdistl 1800 ifcansee ifhitspace { soundonce 450 action OPENING cstat 0 } enda
Thank you guys.
This post has been edited by David B.: 01 July 2017 - 11:21 AM
#2006 Posted 25 July 2017 - 11:24 AM
Is it possible to control a point light (SE49) with a script ? I need a way to light up a room with real light source, when a switch is used.
#2007 Posted 25 July 2017 - 11:42 AM
This post has been edited by Mark.: 25 July 2017 - 11:44 AM
#2009 Posted 01 August 2017 - 07:58 AM
How to control a SE (SE12 in my case for controlling the lighting of a room) with a custom light switch model ? (I know how to do for activators but I haven't found nothing for SE).
In fact I need a model because it must also execute other stuffs like change the picnum of the wall-light model (5439 to 5440, the last being defined with a glow map when the room is bright).
eventloadactor SWITCH getactor[THISACTOR].lotag SPRITE_LOTAG // = SECTOR EFFECTOR CHANNEL setactor[THISACTOR].lotag 0 enda useractor notenemy SWITCH [...] ifvare MODE 1 ifhitspace ifcansee { // MODE 1 being conditions like facing it, being close to it, ... don't worry. operatemasterswitches SPRITE_LOTAG // Is there a right command for what I want ? // OR : operateactivators SPRITE_LOTAG 0 // doesn't work neither as SE is not an activator of course;) } enda
-Subsidiary issue : is it possible to activate a glow map on a model directly by a script instead of defining two wall-light models and switching their picnum ?
This post has been edited by David B.: 01 August 2017 - 07:59 AM
#2010 Posted 01 August 2017 - 09:59 AM
This post has been edited by Mark.: 01 August 2017 - 10:01 AM
#2011 Posted 01 August 2017 - 11:24 AM
Mark., on 01 August 2017 - 09:59 AM, said:
#2012 Posted 01 August 2017 - 11:57 AM
This post has been edited by Mark.: 01 August 2017 - 11:59 AM
#2013 Posted 02 August 2017 - 12:59 AM
Mark., on 01 August 2017 - 11:57 AM, said:
#2014 Posted 03 August 2017 - 01:37 PM
David B., on 02 August 2017 - 12:59 AM, said:
You need to use spritenoshade on the lamp model tile number, then code the lamp to switch between normal shade value and full bright shade (-127) depending on whether it is "lit".
#2015 Posted 03 August 2017 - 02:19 PM
This post has been edited by Mark.: 03 August 2017 - 02:22 PM
#2016 Posted 03 August 2017 - 02:25 PM
#2017 Posted 04 August 2017 - 06:09 AM
Even after placing some SE49 or 50 in the model, the lamp is not bright enough when it's "on", so I need to define a glow map and maybe working with two models, one has the glow, the other not.
But Confetti work with original switches from duke nukem and I don't know how they are hardcoded so to control the SE12.
Also I tried to add a script to the LIGHTSWITCH2 but this make it disappear from the game.
This was the script I started :
useractor notenemy LIGHTSWITCH2 ifp pfacing ifcansee ifhitspace ifpdistl 512 { getactor[THISACTOR].pal SIGNAL_ON } enda
My idea was getting the pal number of the switch and use it as a channel, and furtherly link it to the lamp with the same matching pal number (so the engine finds the right model in the map and changes its picnum when the global variable SIGNAL_ON is greater than zero).
That was the point.
This post has been edited by David B.: 04 August 2017 - 06:21 AM
#2018 Posted 04 August 2017 - 06:13 AM
Drek, on 03 August 2017 - 02:25 PM, said:
This post has been edited by David B.: 04 August 2017 - 06:21 AM
#2019 Posted 04 August 2017 - 11:04 AM
something like:
ifvarl sector[THISACTOR].floorshade 10 spritepal 3 else spritepal 0
Basically this would just detect if the sector is at a certain shade level (say under 10) and then change the sprite's skin to your lit version. You can of course change the 10 to whatever value you set the lit sector to. If this works and you want a more flexible version of the code, just ask again and I can whip something up for you.
#2020 Posted 05 August 2017 - 02:19 AM
Jblade, on 04 August 2017 - 11:04 AM, said:
something like:
ifvarl sector[THISACTOR].floorshade 10 spritepal 3 else spritepal 0
Basically this would just detect if the sector is at a certain shade level (say under 10) and then change the sprite's skin to your lit version. You can of course change the 10 to whatever value you set the lit sector to. If this works and you want a more flexible version of the code, just ask again and I can whip something up for you.
#2021 Posted 19 August 2017 - 10:37 AM
It comes after the final clips when u finish an EP etc.
How do we remove dis and ore replace it?

This post has been edited by Zaxtor: 19 August 2017 - 10:37 AM
#2022 Posted 19 August 2017 - 11:15 AM
Zaxtor, on 19 August 2017 - 10:37 AM, said:
I'm not sure, but it might be the NODUKETEAMTEXT bit on the predefined LOGO_FLAGS gamevar. You can declare it with a different value and see what happens.
http://wiki.eduke32....wiki/LOGO_FLAGS
Specifically, include this line in your var declarations:
gamevar LOGO_FLAGS 524544 0
#2023 Posted 19 August 2017 - 11:49 AM
if I put "gamevar LOGO_FLAGS 524544 0 " it disables all clips.
if I do
gamevar NODUKETEAMTEXT 524288 0
and
gamevar NODUKETEAMTEXT 524544 0
it wont work
#2024 Posted 19 August 2017 - 02:34 PM
#2025 Posted 19 August 2017 - 03:07 PM
Cus EP4 accepts "level placements without warping you to wrong level when you hit nuke button after going through 3 secret levels etc, (sector you walk in to finish level etc).
Dunno if they fixed it on Duke's today standard.
I remember in Oblivion level placements on EP1 were "weird" to have more levels than the EP1 limit.
This post has been edited by Zaxtor: 19 August 2017 - 03:08 PM