EDuke32 Scripting "CON coding help"
#2298 Posted 14 August 2018 - 12:33 PM
#2299 Posted 14 August 2018 - 02:42 PM
#2300 Posted 14 August 2018 - 07:21 PM
thisbecasper, on 14 August 2018 - 02:42 PM, said:
The only way I know how to "fix" that also breaks sync in multiplayer.
#2301 Posted 15 August 2018 - 05:38 PM
#2302 Posted 16 August 2018 - 04:07 PM
#2303 Posted 16 August 2018 - 04:34 PM
thisbecasper, on 15 August 2018 - 05:38 PM, said:
The difficulty is that all of the monster movement commands are oriented to the nearest player, even if the player is dead. A properly coded monster will check for "ifp palive" before firing, but they will generally still seek the nearest player regardless.
I guess the easiest way would be to insert some code into the monsters via EVENT_GAME. The code would check for if the nearest player is dead, and if so would change the angle of the monster so that it moved in a more appropriate direction. Depending on how much work you wanted to put into it, you could do something simple like make the monster walk off in a random direction, or you could write your own pathfinding code.
Here's a very simple and untested attempt at what I'm talking about:
move ENEMYWANDERVELS 160
appendevent EVENT_GAME
switch sprite[].picnum
case LIZTROOP
case PIGCOP
case LIZMAN
// keep adding cases...
ifp palive nullop
else ifmultiplayer
{
ifmove ENEMYWANDERVELS nullop else
move ENEMYWANDERVELS randomangle
}
break
endswitch
endevent
Note: you may need to make adjustments if you are using an old version of EDuke32 that doesn't allow the abbreviated CON commands
This post has been edited by Trooper Dan: 16 August 2018 - 04:45 PM
#2304 Posted 19 August 2018 - 07:06 AM
#2305 Posted 19 August 2018 - 09:07 AM
#2306 Posted 19 August 2018 - 12:32 PM
If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.
#2307 Posted 19 August 2018 - 02:18 PM
Trooper Dan, on 19 August 2018 - 12:32 PM, said:
If you make a gametype that requires killing all the monsters, you really need to put in safeguards. When I have coded invasion gameplay in the past, I have made all the monsters count the amount of time they have no contact with the player. If the count goes high enough, they get teleported somewhere -- their original start position might be a good choice, or some location that you know the player can get to. If that sound hard or bewildering then you may be in over your head and you may need to change your plans until you have a better grasp of the engine and scripting system.
Yeah, after some testing I've found that they clip through "doors" that are less than 256 units wide. I've considered what you are suggesting with the teleporting, but for now the map just have huge doors (they still try to clip it, but gets squished instead (mission accomplished?)).
A whole other thing, and I'm kinda embarrased to ask this but: What's the most elegant or simplest way to have a switch for things in general? Let me give an example: Monsters drop this crystalammo from time to time, and when the player picks it up, all monsters run a block of code. So what I'm currently doing is setting a global gamevar = 1 in the crystalammo code when the player picks it up while having the monsters check for this gamevar. Then I would like the gamevar to be set back to 0 when all monsters (actors, really) have been iterated once. I've come up with all kind of weird methods, but in the end they doesn't seem logical...
#2308 Posted 19 August 2018 - 02:30 PM
thisbecasper, on 19 August 2018 - 02:18 PM, said:
What does the block of code actually do? My first reaction would be to make the crystalammo run the code instead, by looping through all the monsters. I think this would be less confusing to read, as well.
EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.
This post has been edited by Trooper Dan: 19 August 2018 - 02:34 PM
#2309 Posted 19 August 2018 - 03:04 PM
Trooper Dan, on 19 August 2018 - 02:30 PM, said:
EDIT:
On a related note, you should probably have a per-actor gamevar set to a certain value on all of the "monsters" when they initialize, so that you can easily identify them.
The code will do different things depending on the item the player picks up (but in this case it kills them), but stuff has to happen to the player too, but I guess that could be done by looping too. Only reason to why I'm not looping, is because I haven't learned it yet! Is there anything on the wiki about looping though actors?
#2310 Posted 19 August 2018 - 03:36 PM
There's lots of examples of looping through sprites in published mods, such as pretty much any of mine.
#2311 Posted 03 September 2018 - 02:30 AM
onevent EVENT_ENTERLEVEL
{
setvar w_wall_number 0
whilevarvarn w_wall_number NUMWALLS {
getwall[w_wall_number].picnum w_wall_picnum
ifvare w_wall_picnum 889 {
setwall[w_wall_number].picnum 7224
}
addvar w_wall_number 1
}
}
endevent
However, this does not cover masked walls. Wat do?
#2312 Posted 03 September 2018 - 03:17 AM
#2313 Posted 03 September 2018 - 01:01 PM
Trooper Dan, on 03 September 2018 - 03:17 AM, said:
Does this work when attempting to replace a 4 frame animation with a more-than-4 frame animation (e.g. 8)?
#2314 Posted 03 September 2018 - 01:10 PM
December Man, on 03 September 2018 - 01:01 PM, said:
Are you saying there aren't enough spaces in the art file to put your new animation without bumping into some other existing tiles? Then that's a problem. What happens when you make your loop replace overpicnum as well as picnum?
#2315 Posted 03 September 2018 - 02:05 PM
Trooper Dan, on 03 September 2018 - 01:10 PM, said:
Well damn, haven't thought about doing it like this. It works! Thank you very much!
This post has been edited by December Man: 03 September 2018 - 02:05 PM
#2316 Posted 07 September 2018 - 01:38 PM
Then I had the bright idea that those commands are probably used in the maphacks files. Sure enough, there they are. So I created a MYPROJECT.MHK file and entered in the line "sprite 6673 pitch 128" . I wasn't sure if maphack files need to be called so I typed "include MYPROJECT.MHK at the top of GAME.CON
When run I get an con error message. "expected a keyword but found sprite"
How does one implement pitch, roll and the other similar commands?
Also, for sprite ID is pitch looking for the ID from Mapster or the ID from DEFS.CON? I'm assuming from mapster
This post has been edited by Mark: 07 September 2018 - 01:44 PM
#2317 Posted 07 September 2018 - 02:19 PM
Mark, on 07 September 2018 - 01:38 PM, said:
I don't know what went wrong, but you just set the .pitch and .roll members of the sprite struct to the values you want, either with numbers or gamevars.
https://wiki.eduke32.../Model_rotation
So for example seta[].pitch 512 would make the actor face plant.
#2318 Posted 07 September 2018 - 04:45 PM
This once again points out the severe lack of simple examples for entries. For instance, your example shows that the model to manipulate must be made an actor. Not mentioned in the wiki. Noob coders are not going to automatically know that like the experienced coder does. And since the only example I could find of that command was in a maphack file that was simply: "sprite 6673 pitch 128" I naturally figured thats how to use it. Now I know better.
#2319 Posted 07 September 2018 - 05:21 PM
Mark, on 07 September 2018 - 04:45 PM, said:
You can set the structs on any sprite in the game, it doesn't have to be an actor. I think the real issue here is that people look up individual pages that assume knowledge of how to use sprite structs, without knowing how to use sprite structs. Ideally, the novice CON coder has already read this page first:
https://wiki.eduke32...tructure_access
But it's not desirable to have tutorials on structure access in every entry about a sprite struct. That would make the entries bloated and hard to read, not to mention it would be a ton of work. The correct solution is to have the wiki organized in such a way that the novice has a clear order to read stuff in so they get all the basics. In theory, the novice would come here first and work their way through most of that page.
#2320 Posted 07 September 2018 - 05:35 PM
#2321 Posted 18 September 2018 - 09:08 AM
This post has been edited by thisbecasper: 18 September 2018 - 10:00 AM
#2322 Posted 18 September 2018 - 11:59 AM
Dunno the code but I know what you mean.
I'm trying to find out how is done.
if I find out ill let u know
I'm sure someone with more knowledge on things teleporting near players will help
This post has been edited by Zaxtor: 18 September 2018 - 11:59 AM
#2323 Posted 23 September 2018 - 05:26 AM

I want those two sprites to stay with the player. If he moves, they move with him, and if he rotates, they also rotate, but always keeping the same distance. Is this something possible to do?
#2324 Posted 23 September 2018 - 05:38 AM
#2325 Posted 23 September 2018 - 11:29 AM
defstate doangle
getactor[THISACTOR].ang temp
setactor[actor0].ang temp
setactor[actor1].ang temp
addvar temp 512 // rotate angle 90 degrees
cos x temp
sin y temp
mulscale x2 radius x 14
mulscale y2 radius y 14
getactor[THISACTOR].x temp
addvarvar temp x2
setactor[actor0].x temp
getactor[THISACTOR].y temp
addvarvar temp y2
setactor[actor0].y temp
getactor[THISACTOR].x temp
subvarvar temp x2
setactor[actor1].x temp
getactor[THISACTOR].y temp
subvarvar temp y2
setactor[actor1].y temp
endsThere may be more steps for the motion to look correct in relation to movement interpolation.
#2327 Posted 24 September 2018 - 05:08 PM
Perro Seco, on 24 September 2018 - 02:17 PM, said:
The other solution that Mark referred to makes use of of the rotatepoint command; the results should be equivalent.
You have 3 choices with regard to how the side-sprites will appear to move: jumpy (current solutions), smooth, or smooth and laggy. The reason they will appear jumpy right now is that they are being teleported 30 times per second, but otherwise not moving. Whereas the player and other sprites get movement interpolation in between tics (that's what Hendricks266 was referring to.) I don't know how you would give them proper interpolation and also make them keep up with the player. An improper but proven way to do it is to set their t-sprites based on camera coordinates in a display event, in addition to setting their actual sprites in actor code.

Help
Duke4.net
DNF #1
Duke 3D #1









