EDuke32 Scripting "CON coding help"
#1 Posted 16 May 2009 - 01:15 PM
This post has been edited by Hendricks266: 24 May 2012 - 09:08 PM
Reason for edit: fixed name of source port
#2 Posted 16 May 2009 - 01:27 PM
#3 Posted 16 May 2009 - 02:53 PM
#4 Posted 16 May 2009 - 03:06 PM
onevent EVENT_GAME ifactor LIZTROOP changespritestat THISACTOR 1 endevent
The method above is not CPU efficient but it works.
Note that you can make an actor's code execute at startup by defining it as a useractor notenemy, but if the player is not around they will quickly fall asleep (statnum 2). Also, even with dynamicremap, I wonder if you are running into some hardcoded issue with LIZTROOP.
#5 Posted 16 May 2009 - 04:09 PM
This post has been edited by CraigFatman: 16 May 2009 - 04:09 PM
#6 Posted 16 May 2009 - 09:18 PM
Using this as well isn't very CPU efficient, though you will still need DT code to wake them first I believe.
#7 Posted 18 May 2009 - 01:44 PM
I'm trying to learn the CON language, It's going rather slow. I do have some C, Java, VB, Python, PHP experience but I'm just not picking up on this for some reason. Anyway, I'm trying to start slow by doing a couple of things that, at least in my mind, seem short and simple. There are 2 things that I really want to do right now but I don't have the slightest Idea where to begin.
First, I want to have a message appear at the top of the screen whenever the player approaches an object that they can interact with ( to the effect of "Press <activate> to operate switch/door/whatever") and I want the message to be customized to each type of item.
From what I've learned so far I know it involves using "ifpdistl" and "ifp pfacing" to determine if the player is close enough and actually looking at the object. And also I know I need to define gamequotes (and can also redifine them at runtime) and utilize the gametext command. The fact that gametext has to be called from within a game event is what seems to be throwing me off. Is there any way to have an event that listens for an actor to pass a quote to it and display it to the screen or is that not how this stuff works?
Second, I'm trying to program an airlock for an underwater/space level where the user walks into it, flips a switch, the first door closes then a pressurizing/depressurizing sound plays and then finally the other door opens. I know it can be done without CON manipulation by using a tram system for timing, but I don't know how to do this and would rather have it done through CON code to save sectors/walls/sprites/time.
If anyone can help me out with these two things and give me any tips on CON coding, I'd appreciate it.
#8 Posted 18 May 2009 - 02:17 PM
The second one is is a little harder to explain. Make an activator that opens the second door. Don't put anything in the map that actually triggers the activator. In mapster, set EXTRA on the switch sprite (the one that closes the first door) to the lotag of the activator. Use eventloadactor on the picnum of the switch and grab EXTRA, storing it in a per actor variable if EXTRA is > 0. With that all set up, you will monitor the switch in EVENT_GAME. When a switch that has the per actor variable set changes picnum (meaning it has been used), start a countdown timer (a per actor one on the switch) and when it gets to 1 use operateactivators on the activation number you grabbed from EXTRA when the map loaded. I left out a few details but that's how I would do it.
This post has been edited by DeeperThought: 18 May 2009 - 02:19 PM
#9 Posted 18 May 2009 - 02:35 PM
Also, I did know about the quote command but gametext appears to be much more versatile and I like having options.
#10 Posted 18 May 2009 - 05:56 PM
#11 Posted 18 May 2009 - 10:49 PM
I'm guessing that this is defined somewhere in the original GAME.CON, but I was curious if you can override it with a custom .CON file? Or am I going to have to crack duke3d.grp, find the original setting, and modify it?
Maybe I'm just a bad player, but I frequently use water as a basic survival technique on the harder difficulty levels (like "Damn, I'm Good"). 1 health per drink just takes too long.
#12 Posted 19 May 2009 - 03:52 AM
A Number One, on May 19 2009, 08:49 AM, said:
I'm guessing that this is defined somewhere in the original GAME.CON, but I was curious if you can override it with a custom .CON file? Or am I going to have to crack duke3d.grp, find the original setting, and modify it?
Maybe I'm just a bad player, but I frequently use water as a basic survival technique on the harder difficulty levels (like "Damn, I'm Good"). 1 health per drink just takes too long.
My first guess would be including a code like this somewhere after def.con and user.con
gamevar PICNUM 0 2
onevent EVENT_GAME
getactor[THISACTOR].picnum PICNUM
ifvare PICNUM WATERFOUNTAIN
{
ifp palive
ifpdistl RETRIEVEDISTANCE
ifp pfacing
ifactioncount 32
ifphealthl MAXPLAYERHEALTH
ifhitspace
ifcansee
{
addphealth 5
globalsound DUKE_DRINKING
resetactioncount
}
}
endevent
#13 Posted 19 May 2009 - 06:28 AM
#14 Posted 19 May 2009 - 06:41 AM
DeeperThought, on May 19 2009, 07:28 AM, said:
Thanks. I was thinking it was probably something simple like that, but I guess I do need to crack open the duke3d.grp to get to the CON file. Which is no big deal, just takes a little more time.
#15 Posted 19 May 2009 - 06:50 AM
DeeperThought, on May 19 2009, 04:28 PM, said:
I was describing the code as it would be if placed in a separate con file.
#16 Posted 19 May 2009 - 03:18 PM
DeeperThought, on May 18 2009, 06:17 PM, said:
Quick question; How do check to see if the switch changes picnum? Keep in mind that I do have multiple switches controlling the same airlock (One inside, and one outside each door). I am utilizing the map caching feature and designing the maps in such a way that there is no guarantee as to which side of the airlock the player may encounter first or what state it may be in (I also plan to allow enemies to be able to go through the airlocks as well but I'll tackle the project later).
#17 Posted 19 May 2009 - 03:22 PM
#18 Posted 19 May 2009 - 04:39 PM
ReaperTK, on May 19 2009, 07:18 PM, said:
OK I've got it checking for the picnum change (probably a better way to do it though than what I did). I had it store the current picnum to a per actor variable in the eventloadactor code then grabbed the picnum again in the EVENT_GAME code (after checking the EXTRA value) I then compared the two to determine if a change had occurred.
Now I just need to know the proper use of the operateactivators command to activate the doors (I threw in some debugging code to arbitrarily change the switches picnum as you'll see below just to make sure the proper conditions are actually being met.
onevent EVENT_GAME { ifvare EXTRA 20 { // Airlock Switch getactor[THISACTOR].picnum AIRLKNPIC ifvarvarn AIRLKNPIC AIRLKCPIC { // Switch has been activated operateactivators AIRLK 0 // setactor[THISACTOR].picnum 135 setvarvar AIRLKCPIC AIRLKNPIC } // end ifvarn } // end ifvare } // end EVENT_GAME endevent
I'm so close I can taste it.
EDIT: Nevermind, I've got it working perfectly now. I had an issue in the map that was preventing the doors from opening.
This post has been edited by ReaperTK: 19 May 2009 - 04:57 PM
#19 Posted 19 May 2009 - 07:37 PM
ReaperTK, on May 19 2009, 05:39 PM, said:
Haha, I do it the same way in my switch effects. I can't think of any other way of doing it at the moment.
#20 Posted 23 May 2009 - 02:03 AM
I'm no good at con editing so I'd need someone to tell me exactly what to do.
So if there is anyone out there who has the time and is willing to help me, I'll be forever in your debt.
EDIT: Sorry, just downloaded latest dukeplus and it includes the sd "blood clouds", which more that satisfy my needs... (for now!)
This post has been edited by XenoMatriX: 23 May 2009 - 03:49 AM
#21 Posted 06 June 2009 - 12:14 AM
#22 Posted 06 June 2009 - 12:52 AM
James, on Jun 6 2009, 01:14 AM, said:
That reminds me, I did this for one of the Blood mods a while ago. I was supposed to port the code for Dimebog, but I've been otherwise occupied. I am attaching the code that I used:
EDUKE.zip (1.48K)
Number of downloads: 1539
Simplifying a bit, what I did was to add or subtract a number from the player's angle depending on the part of the firing sequence you are at. The angle is reset after firing so you can't tell that the player is turning. So: check altfire counter variable, and depending on what that is you change angle, fire bullet, reset angle (in the player's code). Then there is display code that syncs up with the firing.
#24 Posted 11 June 2009 - 04:05 AM
onevent EVENT_GAME . . . ifactor MACE2 { getactorvar[THISACTOR].ACTORCOUNT countvar addvar countvar 1 setactorvar[THISACTOR].ACTORCOUNT countvar ifvare countvar 5 { ifaction MACEFRAMES action MACEFRAMES2 else ifaction MACEFRAMES2 action MACEFRAMES3 else ifaction MACEFRAMES3 action MACEFRAMES4 else ifaction MACEFRAMES4 action MACEFRAMES5 else ifaction MACEFRAMES5 action MACEFRAMES6 else ifaction MACEFRAMES6 action MACEFRAMES7 else ifaction MACEFRAMES7 action MACEFRAMES setvar countvar 0 setactorvar[THISACTOR].ACTORCOUNT countvar } } . . . endevent define MACE2 7408 define MACESTAND 7414 action MACEFRAMES 0 1 1 action MACEFRAMES2 1 1 1 action MACEFRAMES3 2 1 1 action MACEFRAMES4 3 1 1 action MACEFRAMES5 4 1 1 action MACEFRAMES6 5 1 1 action MACEFRAMES7 6 1 1 defineprojectile MACE2 PROJ_WORKSLIKE 6278 //4096 + 2048 + 4 + 2 defineprojectile MACE2 PROJ_SPAWNS MACESTAND defineprojectile MACE2 PROJ_VEL 125 defineprojectile MACE2 PROJ_EXTRA 0 defineprojectile MACE2 PROJ_DROP -75 defineprojectile MACE2 PROJ_ISOUND -1 defineprojectile MACE2 PROJ_HITRADIUS 1 defineprojectile MACE2 PROJ_BOUNCES 4 defineprojectile MACE2 PROJ_BSOUND -1 defineprojectile MACE2 PROJ_XREPEAT 50 defineprojectile MACE2 PROJ_YREPEAT 50 defineprojectile MACE2 PROJ_CSTAT 1 defineprojectile MACE2 PROJ_CLIPDIST 70 useractor notenemy MACE2 0 MACEFRAMES enda useractor notenemy MACESTAND 0 sizeat 50 50 enda
That's the code I used for an object that is spawned upon the death of a monster... It basically spawns, falls on the ground, spins 4 times, and then disappears... it doesn't spawn the MACESTAND actor. What's wrong? And, this code USED to work on old versions.
This post has been edited by XThX2: 11 June 2009 - 04:06 AM
#25 Posted 11 June 2009 - 06:36 AM
XThX2, on Jun 11 2009, 05:05 AM, said:
onevent EVENT_GAME . . . ifactor MACE2 { getactorvar[THISACTOR].ACTORCOUNT countvar addvar countvar 1 setactorvar[THISACTOR].ACTORCOUNT countvar ifvare countvar 5 { ifaction MACEFRAMES action MACEFRAMES2 else ifaction MACEFRAMES2 action MACEFRAMES3 else ifaction MACEFRAMES3 action MACEFRAMES4 else ifaction MACEFRAMES4 action MACEFRAMES5 else ifaction MACEFRAMES5 action MACEFRAMES6 else ifaction MACEFRAMES6 action MACEFRAMES7 else ifaction MACEFRAMES7 action MACEFRAMES setvar countvar 0 setactorvar[THISACTOR].ACTORCOUNT countvar } } . . . endevent define MACE2 7408 define MACESTAND 7414 action MACEFRAMES 0 1 1 action MACEFRAMES2 1 1 1 action MACEFRAMES3 2 1 1 action MACEFRAMES4 3 1 1 action MACEFRAMES5 4 1 1 action MACEFRAMES6 5 1 1 action MACEFRAMES7 6 1 1 defineprojectile MACE2 PROJ_WORKSLIKE 6278 //4096 + 2048 + 4 + 2 defineprojectile MACE2 PROJ_SPAWNS MACESTAND defineprojectile MACE2 PROJ_VEL 125 defineprojectile MACE2 PROJ_EXTRA 0 defineprojectile MACE2 PROJ_DROP -75 defineprojectile MACE2 PROJ_ISOUND -1 defineprojectile MACE2 PROJ_HITRADIUS 1 defineprojectile MACE2 PROJ_BOUNCES 4 defineprojectile MACE2 PROJ_BSOUND -1 defineprojectile MACE2 PROJ_XREPEAT 50 defineprojectile MACE2 PROJ_YREPEAT 50 defineprojectile MACE2 PROJ_CSTAT 1 defineprojectile MACE2 PROJ_CLIPDIST 70 useractor notenemy MACE2 0 MACEFRAMES enda useractor notenemy MACESTAND 0 sizeat 50 50 enda
That's the code I used for an object that is spawned upon the death of a monster... It basically spawns, falls on the ground, spins 4 times, and then disappears... it doesn't spawn the MACESTAND actor. What's wrong? And, this code USED to work on old versions.
There is a bug in the current version of EDuke32 which causes actors spawned by bouncing projectiles to end up in random places (often so far away from the projectiles it appears they aren't spawning at all). The bug has been fixed, but the fixed version won't be released until polymer is. If you want the fix you need to use a recent polymer build.
As a workaround, you can change spawns to -1 and have the projectile spawn the actor in EVENT_KILLIT.
#27 Posted 12 June 2009 - 07:26 AM
DeeperThought, on Jun 11 2009, 06:36 AM, said:
As a workaround, you can change spawns to -1 and have the projectile spawn the actor in EVENT_KILLIT.
Hmm I guess I can wait the polymer's release... (I hope it is released shortly)
#28 Posted 16 June 2009 - 09:20 AM
#29 Posted 16 June 2009 - 09:35 AM
Unfortunately I can't remember what causes it. What was the last thing you implemented before you saw the bug?