EDuke32 Scripting "CON coding help"
#1712 Posted 09 October 2015 - 03:15 PM
The Mechanic, on 09 October 2015 - 09:53 AM, said:
When moving sprites slowly between sectors, there will always be the situation at some point where the center of the sprite is in one sector (and has the correct sectnum value) but part of the sprite is in another sector.
That's fine. It's just recommended to always have sprites on their correct sectors, since otherwise it's undefined behavior and you should expect glitches. For example, you have a sprite in a door sector. If the door closes, the engine will detect that there's no line of sight between the player eyes and that sector, and the sector along with its walls and sprites won't be rendered. If you have a sprite outside of the door sector, but with its current sector ID being that of the door, it will become invisible when the door closes.
#1713 Posted 10 October 2015 - 02:47 AM
#1714 Posted 10 October 2015 - 06:15 AM
Mark., on 10 October 2015 - 02:47 AM, said:
Question is why is the sprite not getting rendered ?
If you have disappearing sprites due to them being in a sector but the sprites were bigger than that sector, you may be able to fix that with two identical sprites, one in the original sector then place the second in the other sector and use xoffset and yoffset to make it render where the first one is. That way if one of them isn't rendered then the other one is.
TTFN,
Jon
#1715 Posted 10 October 2015 - 07:46 AM
This post has been edited by Mark.: 10 October 2015 - 08:17 AM
#1716 Posted 10 October 2015 - 09:59 AM
#1717 Posted 10 October 2015 - 10:42 AM
Mark., on 10 October 2015 - 07:46 AM, said:
I have an idea, though how practical it is in reality I don't know.
Attached image shows red overhead wires, one of which vanishes because it is in a sector (round the corner) not visible to the player. The following code illustrates the idea behind the fix, where the wire that goes missing is hitagged 666 :-
onevent EVENT_GAME getactor[THISACTOR].hitag temp3 ifvare temp3 666 { ifcansee nullop else { getactor[THISACTOR].sectnum temp3 ifvare temp3 0 { setactor[THISACTOR].x 29568 setactor[THISACTOR].xoffset 0 setactor[THISACTOR].sectnum 1 } else { setactor[THISACTOR].x 30080 setactor[THISACTOR].xoffset 8 setactor[THISACTOR].sectnum 0 } } } endevent
OK, I hackcoded it here, but you get the idea. How feasible it'd be to automate this in a more general case I don't know.
Also in the attached map I made a second version - follow the red arrow - no CON code needed, simply duplicated the missing sprite, moved it to another sector and adjusted it's xoffset to put it exactly where the original one was. Visually overlapping which, depending on where you are and where you are looking, one may vanish but the other remains visible. Now I appreciate this may be somewhat awkward with more complex structures.
Thing is, adding a pucka eduke flag isn't so easy. OK, adding the flag is , but how do you define "always render", bearing in mind sorting is needed for who-is-in-front-of-who during rendering, that kinda thing. The situation could be improved if in addition to the rendering process using the center of a sprite for a render/no-render decision, it included say both ends of the sprite. But in particularly complex scenarious even that might fail This would require multiple player-can-see operations as well as calculating sector numbers in which those ends appear. Probably a lot of (computational) effort. Maybe someone with more detailed knowledge of the inner workings of the rendering process could better comment, but my gut feel is it would be difficult.
If I've misunderstood your issue, perhaps start a new thread with a small test map and lets see what we can do.
TTFN,
Jon
[EDit] OK, now I have me specs on, it isn't quite doing what I thought, bear with me whilst I work it out.
Attached File(s)
-
missing-sprite.zip (1.35K)
Number of downloads: 519
This post has been edited by The Mechanic: 10 October 2015 - 11:51 AM
#1718 Posted 10 October 2015 - 11:34 AM
#1719 Posted 10 October 2015 - 12:13 PM
I chose bad example sprites, hidding my error.
It seems xoffset may be ignored if altered during game (or I need to call something I'm not aware of). The version where I just overlapped two sprites worked but the "CON" version doesn't seem to change the xoffset and also wont reset the position to original position when required.
Fox, on 10 October 2015 - 11:34 AM, said:
I think you are absolutely right, the way to do this is to spawn dupicates (triplicates, whatever), moving sprites at runtime just aint gonna work.
The "spawn" command in CON only spawns what a respawn sprite can spawn. How do I spawn/create a regular decorative sprite at runtime?
TTFN,
Jon
#1720 Posted 10 October 2015 - 12:21 PM
#1721 Posted 10 October 2015 - 12:44 PM
Fox, on 10 October 2015 - 12:21 PM, said:
D'Oh ! Yes, I just discovered that. It was odd because I spawned tile 764 (building sprite) and nothing appeared, however using DNDEBUG and loading debug.map it DID appear in mapster when in 2-D mode and even drew "correctly" (as in how I expected it not realising about xrepeat) in 2D mode (when you press the [backspace] key to show textures in 2D mode).
Perhaps Mark could supply a test map giving the idea of the complexity of the areas he is dealing with. There would be lots of corner cases in spawning copies but if those corner cases 'aint going to happen in reality then things could be kept relatively simple. For exampe, xoffset is a fairly coarse adjustment so it is conceivable that you can't actually position the duplicate in the sector you want.
TTFN,
Jon
This post has been edited by The Mechanic: 10 October 2015 - 12:46 PM
#1722 Posted 10 October 2015 - 12:58 PM
EDIT: I re-read my post. Its looking even more impossible to implement. Never mind.
This post has been edited by Mark.: 10 October 2015 - 01:03 PM
#1723 Posted 10 October 2015 - 02:01 PM
Mark., on 10 October 2015 - 12:58 PM, said:
I like the lateral thinking ! Suspect rendering a different view from the position deciding what to render may be a world of pain coding-wise, depends on how tightly coupled things are I guess.
Mark., on 10 October 2015 - 12:58 PM, said:
Aww, you give up to easy Depending on complexity of sectors, it is entirely feasible to have CON code to spawn a duplicate structure somewhere else that is offset to appear in the original position. For efficiency reasons, the mapper might need to tag the sprites that need special treatment, but for the mapper it need be no more complicated that that.
TTFN,
Jon
This post has been edited by The Mechanic: 10 October 2015 - 02:01 PM
#1724 Posted 10 October 2015 - 02:20 PM
This post has been edited by Mark.: 10 October 2015 - 02:26 PM
#1725 Posted 10 October 2015 - 04:01 PM
For set dressing where collision isn't important it might work, but it's just an idea and could fail spectacularly if it (the engine) does any checks after that event triggers.
#1726 Posted 10 October 2015 - 05:26 PM
If you want to force all sprites to be rendered, you can use this:
gamevar Temp1 0 0 gamevar Temp2 0 0 gamearray TempSectnum 16384 appendevent EVENT_DISPLAYSTART ifvarn rendmode 0 ifvare Temp1 0 { setvar Temp2 0 whilevarvarn Temp2 16384 { ifvarn sprite[Temp2].statnum MAXSTATUS { setarray TempSectnum[Temp2] sprite[Temp2].sectnum setactor[Temp2].sectnum camerasect } addvar Temp2 1 } setvar Temp1 1 } endevent appendevent EVENT_DISPLAYREST ifvarn rendmode 0 ifvare Temp1 1 { setvar Temp2 0 whilevarvarn Temp2 16384 { ifvarn sprite[Temp2].statnum MAXSTATUS setactor[Temp2].sectnum TempSectnum[Temp2] addvar Temp2 1 } setvar Temp1 0 } endevent
But there are some issues with this solution:
- It works by changing the current sector to that of the camera view after the game worlds is processed, but before animatesprites. Thus sprites shade, palette or visibility depends on the current camera sector.
- You can see everything from the map through parallaxed skies.
- If there are two sectors occupying the same space, you can see the sprites from one sector on another.
- Always rendering all sprites (or models) it will consume too much CPU. Sprites disappearing is an intended effect afterall.
#1727 Posted 10 October 2015 - 06:07 PM
Its been a long day at the computer. I'll try out your code tomorrow. Thanks.
This post has been edited by Mark.: 10 October 2015 - 06:13 PM
#1728 Posted 10 October 2015 - 07:47 PM
#1729 Posted 11 October 2015 - 12:13 AM
Fox, on 10 October 2015 - 05:26 PM, said:
.... appendevent EVENT_DISPLAYSTART ifvarn rendmode 0 ...
I'm curious, why woudn't this work in rendermode 0 ?
TTFN,
Jon
This post has been edited by The Mechanic: 11 October 2015 - 12:15 AM
#1730 Posted 11 October 2015 - 03:04 AM
// Eduke """"feature"""": 'movesprite' only moves half way, so double delta values mulvar temp1 2 mulvar temp2 2 mulvar temp3 2 // Loop through all sprites in group and move by delta's setvarvar temp4 THISACTOR whilevarn temp4 -1 { // Current pos becomes previous pos getactor[temp4].x temp5 setactor[temp4].htbposx temp5 getactor[temp4].y temp5 setactor[temp4].htbposy temp5 getactor[temp4].z temp5 setactor[temp4].htbposz temp5 // Move da sprite movesprite temp4 temp1 temp2 temp3 0 RETURN // If player 0 was standing on it then move player too - TODO : Multiplayer,enemies... setvar temp5 0 getplayer[temp5].sbs temp5 ifvarvare temp5 temp4 { divvar temp1 2 divvar temp2 2 divvar temp3 2 setvar RETURN 0 getplayer[RETURN].posx temp5 setplayer[RETURN].oposx temp5 addvarvar temp5 temp1 setplayer[RETURN].posx temp5 getplayer[RETURN].posy temp5 setplayer[RETURN].oposy temp5 addvarvar temp5 temp2 setplayer[RETURN].posy temp5 getplayer[RETURN].posz temp5 setplayer[RETURN].oposz temp5 addvarvar temp5 temp3 setplayer[RETURN].posz temp5 updatesectorz player[RETURN].posx player[RETURN].posy player[RETURN].posz temp5 setplayer[RETURN].cursectnum temp5 mulvar temp1 2 mulvar temp2 2 mulvar temp3 2 } getactorvar[temp4].nextsprite temp4 }
When viewing the sprites in motion they are moving nice and smooth in all three dimensions. When Duke is carried on the sprites he also seems to move smoothly judging by the scenery but the group of sprites have a small bobbing up-and-down motion with a cycle of 1 second.
Is there a better way of moving the player ?
TTFN,
Jon
#1731 Posted 11 October 2015 - 03:29 AM
The Mechanic, on 11 October 2015 - 12:13 AM, said:
TTFN,
Jon
No reason, I was just thinking of a hack for models.
#1732 Posted 11 October 2015 - 04:11 AM
This post has been edited by Mark.: 11 October 2015 - 04:11 AM
#1733 Posted 11 October 2015 - 05:50 AM
This post has been edited by Mark.: 11 October 2015 - 06:58 AM
#1734 Posted 11 October 2015 - 07:31 AM
#1735 Posted 11 October 2015 - 07:36 AM
This post has been edited by Mark.: 11 October 2015 - 07:47 AM
#1736 Posted 11 October 2015 - 01:17 PM
Fox, on 11 October 2015 - 07:31 AM, said:
Indeed I'm busy at the moment--from what I understand skimming the conversation, you're talking about always rendering sprites regardless of what sector they're in, for stuff like model-based terrain? It's been talked about before, and I'm going to be working in that area of the renderers for some Duke 64 stuff.
If you clarify to me what the request is, I can add it to the mental pipeline to implementation.
#1737 Posted 11 October 2015 - 02:02 PM
#1738 Posted 12 October 2015 - 09:04 AM
Mblackwell, on 09 October 2015 - 02:22 PM, said:
I must've done something horribly wrong, since the placement of pstomp doesn't change a thing. Yes, I think I tried all the possible placement and the whole code I have written is just bad.
#1739 Posted 12 October 2015 - 10:16 AM
December Man, on 12 October 2015 - 09:04 AM, said:
pstomp begins a sequence which results in the deletion of the sprite that is issuing the command. It is NOT used in conjunction with killit, in any order. You either use pstomp to delete the sprite, or you use killit, you do not use both. If you have any questions, look at how it is used in an unmodified GAME.CON, or look at the source code.