Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 124 Pages +
  • « First
  • 55
  • 56
  • 57
  • 58
  • 59
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#1681

Three kinda related questions.

Firstly I want to create an equivalent of a sector effector to perform various custom trickery. The issue will be if I implement this as a useractor then it's actor code may not run because it is sleeping (statnum = zombie). So, is there a way of making a never-sleeps useractor ?

I notice there are events 'EVENT_GAME' or 'EVENT PREGAME' which fire for each actor per game tic, but it is not clear whether these will still run for zombie actors. If there was an EVENT_TIC (which there isn't) then I guess I could use it to force my custom sprite's statnum back to 1 (awake) and I might be able to infer my hypothetical EVENT_TIC using some logic in EVENT_GAME, but this is all sounding rather wasteful of CPU cycles as well as messy.

Or .. is there another better way to implement this?

Secondly, as part of said trickery, how do I detect when a 'channel' fires (e.g. from switch, touchplate, etc) ? It would be jolly useful if there was a game event that signalled this but I can't see one. For switches I could iterate through all sprites (or a subset based on statnum) looking for appropriately tagged switches and get their state from picnum but that feels like it could add a lot of processor overhead if I did it on every game tic.

Finally it would be nice if my custom sector effector would allow me to utilise the lotag for my own purposes but currently if this is non-zero then my custom sector effector is deleted in game, presumably 'cos the lotag is being interpretted as multiplayer only or something (or is it skill level ? I forget). Whatever is there a way around this behaviour?

[Edit] Ah-ha ! Saving the lotag in a gamevar during eventloadactor and then setting lotag 0 fixes that last issue.

TTFN,
Jon

This post has been edited by The Mechanic: 26 September 2015 - 04:28 AM

0

#1682

It's me again. Is there as a way to disable the pistol casing and shotgun shell sprites ejecting without editing tiles art files? Just with pure con editing? I added casings that drop on the floor as projectiles etc. but now you have these projectiles and the old casings.

This post has been edited by December Man: 27 September 2015 - 03:24 AM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #1683

http://wiki.eduke32....efined_gamevars
http://wiki.eduke32....i/WEAPONx_SPAWN
0

#1684

View PostHendricks266, on 27 September 2015 - 06:46 AM, said:



Well... damn. Thanks.
0

User is offline   Jenz/Amaka 

#1685

Managed to create full copy of Lizman but I got few problems.
First is that Lizman's Copy size ingame is huge. I know that I gotta put this code, but I don't know where.
{
      sizeat 42 40
	  cstator 257
}


And also them Lizman's copies seem to attack immediately even when the player is not seen.
0

User is offline   Daedolon 

  • Ancient Blood God

#1686

Anywhere after (user)actor. Preferably at the top.
0

User is online   Mark 

#1687

Check for lines containing "ifcansee" or "ifcanseetarget" and see if there is something there that needs tweaking. If there are no lines with those commands then you will need to add some. I don't know if you have done this or not, but I recommend looking through other people's custom con files from mods and TCs to get an idea how some things work. That helped me a lot.

This post has been edited by Mark.: 30 September 2015 - 11:07 AM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1688

View PostJenz/Amaka, on 30 September 2015 - 07:36 AM, said:

Managed to create full copy of Lizman but I got few problems.
First is that Lizman's Copy size ingame is huge. I know that I gotta put this code, but I don't know where.
{
      sizeat 42 40
	  cstator 257
}


And also them Lizman's copies seem to attack immediately even when the player is not seen.

That's because some enemies are hard-coded. In other words, part of the code is written directly in the executable.

Add this somewhere in the CON (obviously not using the LIZMAN tile):
appendevent EVENT_LOADACTOR
  switch sprite[THISACTOR].picnum
  case LIZMAN
  case LIZMANSTAYPUT
  case LIZMANSPITTING
  case LIZMANJUMP
    sizeat 40 40
    clipdist 80
    cstator 257
  break
  endswitch
endevent


Find these parts:
actor LIZMANSTAYPUT LIZSTRENGTH ai AILIZGETENEMY cactor LIZMAN enda

actor LIZMANSPITTING LIZSTRENGTH ai AILIZSPIT cactor LIZMAN enda

actor LIZMANJUMP LIZSTRENGTH ai AILIZJUMPENEMY cactor LIZMAN enda

actor LIZMAN LIZSTRENGTH

Replace with:
useractor enemy LIZMANSTAYPUT LIZSTRENGTH ai AILIZGETENEMY cactor LIZMAN enda

useractor enemy LIZMANSPITTING LIZSTRENGTH ai AILIZSPIT cactor LIZMAN enda

useractor enemy LIZMANJUMP LIZSTRENGTH ai AILIZJUMPENEMY cactor LIZMAN enda

useractor enemy LIZMAN LIZSTRENGTH


This post has been edited by Fox: 01 October 2015 - 01:36 AM

1

User is offline   Jenz/Amaka 

#1689

Aaaalmost there.

View PostFox, on 30 September 2015 - 01:02 PM, said:

That's because some enemies are hard-coded. In other words, part of the code is written directly in the executable.

Add this somewhere in the CON (obviously not using the LIZMAN tile):
appendevent EVENT_LOADACTOR
  switch sprite[THISACTOR].picnum
  case LIZMAN
  case LIZMANSTAYPUT
  case LIZMANSPITTING
  case LIZMANJUMP
    sizeat 40 40
    clipdist 80
    cstator 257
  break
  endswitch



I tried adding that code. I tried at the start of .con, end, different .con, and they all give same errors.

DS_GAME.CON: In event `EVENT_LOADACTOR':
DS_GAME.CON:33: error: parameter `ANULLACTION' is undefined.
DS_GAME.CON:33: error: expected a keyword but found `0'.
Found 0 warning(s), 2 error(s).

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1690

Sorry, I missed the endevent. :/
1

User is offline   Daedolon 

  • Ancient Blood God

#1691

You've removed this from GAME.CON

action ANULLACTION 0


nvm

This post has been edited by Daedolon: 01 October 2015 - 01:37 AM

0

User is offline   Jenz/Amaka 

#1692

View PostFox, on 01 October 2015 - 01:36 AM, said:

Sorry, I missed the endevent. :/

That did it! Many thanks, Fox! :)
0

#1693

I'm intending to respawn enimies from within a CON script (and the standard RESPAWN sprite 'aint gonna cut it). Whilst I can spawn stuff easilly, how do I update the total enemy count ? If the player hasn't killed a monster I have, or intended to have, spawned then it needs to be added to the number of missed kills.

Also, if I may, a repeat of previous question - how do I detect an activator firing from within CON code ? Possible ? Not possible ?

TTFN,
Jon
0

User is offline   Danukem 

  • Duke Plus Developer

#1694

View PostThe Mechanic, on 02 October 2015 - 11:22 AM, said:

I'm intending to respawn enimies from within a CON script (and the standard RESPAWN sprite 'aint gonna cut it). Whilst I can spawn stuff easilly, how do I update the total enemy count ? If the player hasn't killed a monster I have, or intended to have, spawned then it needs to be added to the number of missed kills.


I'm not entirely sure what you are asking, but you might be saying that when you spawn an enemy, the max number of kills in the map does not get increased. If that's the case, then you can fix that by reading/writing the following:

http://wiki.eduke32....x_actors_killed

View PostThe Mechanic, on 02 October 2015 - 11:22 AM, said:

Also, if I may, a repeat of previous question - how do I detect an activator firing from within CON code ? Possible ? Not possible ?


You can try this command:

http://wiki.eduke32....activatormotion

IIRC it only works in certain contexts. I ended up making my own special activators by looping through sprites and changing, checking per-actor gamevars.
1

#1695

View PostTrooper Dan, on 02 October 2015 - 01:22 PM, said:

I'm not entirely sure what you are asking, but you might be saying that when you spawn an enemy, the max number of kills in the map does not get increased. If that's the case, then you can fix that by reading/writing the following:

http://wiki.eduke32....x_actors_killed


D'oh ! :) Yes, that is what I need, I thought I'd searched the wiki thoroughly, it just didn't click that it'd be a per-player thing which, of course, now seems obvious. Cheers ! Yes, I want (in theory at least) to be able to have infinite respawns, I think it may be of encouraging players not to revisit an area too often which they can take as a hint they are going the wrong way. After all, if Duke has cleared an area, why wouldn't the aliens send in re-inforcements?

Anyhow, when I detect a player triggering one of my respawns alls I'll know is the player's THISACTOR value. How would I convert this to the relevent index into the player structures ? Or is the script system smart enough such that getplayer[THISACTOR] will re-interpret THISACTOR for me ? Or should I just ignore multiplayer and use getplayer[0] ? (I don't play multiplayer and I'm sure I read somewhere that current Eduke versions aren't multiplayer anyway?).

View PostTrooper Dan, on 02 October 2015 - 01:22 PM, said:

You can try this command:

http://wiki.eduke32....activatormotion

IIRC it only works in certain contexts. I ended up making my own special activators by looping through sprites and changing, checking per-actor gamevars.


I couldn't see how to use checkactivatormotion. At the moment I've implemented what you have done, my own activator system and grouping sprites as a chains of groups of sprites (debugging a linked list of linked lists in a primitive script language and no debugging tools nearly did for what little is left of my sanity!). Unfortunately it does mean I need helper sectors (e.g. a door) to translate a standard activator to jonz system, which is a nuiscence.

Can you provide any further info on the contexts in which Checkactivatormotion works ?

Currently my main game loop looks like this:
gamevar ticky 0 0
gamevar startupdebug 1 0

// Called once per "tic" _per_ _actor_. Not clear if this gets called for actors that the
//   game has decided are temporarily zombied ? Jonz sprites are not useractors so maybe
//   will never be zombied ??
onevent EVENT_GAME

	ifvarn startupdebug 0
	{
		... dump some debug stuff
		setvar startupdebug 0
	}
	
	// Fudge: There is no event that runs once per tick so we need to infer one.
	// Ticks are roughly in milliseconds. This is NOT accurate for multiplayer
	//   and game should never sync to this for multiplayer. TODO: Use what else?
	getticks temp1
	setvarvar temp2 temp1
	
	subvarvar temp2 ticky
	
	ifvarg temp2 33	// Roughly 30 times per second. Ish. 
	{
		setvarvar ticky temp1
		
		// Process jonz main sprite system
		//   This is more efficient this way otherwise I'd be searching chains of
		//   groups of sprites for every actor on every tick. What I need is an EVENT_GAME
		//    that runs once per game tic but there isn't one ?
		state process_allsectormonitors
		
		state update_sectorchangers

                //state move_sprite_groups   TODO
		
		// TODO : revise this if how sounds are played is influenced by THISACTOR
		state update_jsounds
	}
	
	// These effects may spawn objects so will only work if THISACTOR is correctly set.
	state update_alljeffects
	
	state update_alljrespawns

endevent


It has happened this way because I'm not confident about when, or what happens, should my sprites get marked by Eduke as zombied because the player hasn't seen them in a while (however they are _not_ useractors). Also unless I've missed something there is no event that fires once per game tick - plus I dont know the interval of a game tick.

TTFN,
Jon
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1696

Dude, what a mess. o_O

View PostThe Mechanic, on 02 October 2015 - 11:40 PM, said:

D'oh ! :) Yes, that is what I need, I thought I'd searched the wiki thoroughly, it just didn't click that it'd be a per-player thing which, of course, now seems obvious. Cheers ! Yes, I want (in theory at least) to be able to have infinite respawns, I think it may be of encouraging players not to revisit an area too often which they can take as a hint they are going the wrong way. After all, if Duke has cleared an area, why wouldn't the aliens send in re-inforcements?

If you want RESPAWNs to continue working after being activated, use this:

appendevent EVENT_KILLIT
  ifactor RESPAWN
  {
    setvar RETURN -1
    setactor[THISACTOR].extra 0
  }
endevent


View PostThe Mechanic, on 02 October 2015 - 11:40 PM, said:

Anyhow, when I detect a player triggering one of my respawns alls I'll know is the player's THISACTOR value. How would I convert this to the relevent index into the player structures ? Or is the script system smart enough such that getplayer[THISACTOR] will re-interpret THISACTOR for me ? Or should I just ignore multiplayer and use getplayer[0] ? (I don't play multiplayer and I'm sure I read somewhere that current Eduke versions aren't multiplayer anyway?).

Yes, it will re-interpret THISACTOR. If you use it for getactor, THISACTOR returns the current actor ID, for getplayer it will be the nearest player ID, and for getsector it will be the current actor sector ID.

It's tricky, but in multiplayer you would have to change the value of max_actors_killed for all players...

View PostThe Mechanic, on 02 October 2015 - 11:40 PM, said:

Currently my main game loop looks like this:
[...]

It has happened this way because I'm not confident about when, or what happens, should my sprites get marked by Eduke as zombied because the player hasn't seen them in a while (however they are _not_ useractors). Also unless I've missed something there is no event that fires once per game tick - plus I dont know the interval of a game tick.

TTFN,
Jon

Not sure where you are getting with this. First of all, EVENT_GAME runs every tic for all existing sprites in the map, including sleeping (zombie) actors. So a global gamevar would be overwritten.

If you want to prevent an actor from ever sleeping, I believe this would work:
onevent EVENT_GAME
  ifactor MYACTOR
    setactor[THISACTOR].httimetosleep 0
endevent


This post has been edited by Fox: 03 October 2015 - 12:22 AM

1

#1697

View PostFox, on 03 October 2015 - 12:22 AM, said:

Dude, what a mess. o_O


I did enquire about how to achieve what I'm trying to do in previous threads when I was at the planning stage, this so far has been the only way I've been able to move forward.

I have sprites grouped into functional groups as sprites within a group interact with each other, with one sprite within that group acting as a master. When I wrote that piece of code you need to bear in mind that I couldn't get an answer on whether EVENT_GAME would still get called for sleeping sprites so this was the only way I could see to absolutely gaurentee my sprites would get processed. A gaurentee that EVENT_GAME is _always_ called for every sprite will certainly make my life easier.

View PostFox, on 03 October 2015 - 12:22 AM, said:

If you want RESPAWNs to continue working after being activated, use this:

appendevent EVENT_KILLIT
  ifactor RESPAWN
  {
    setvar RETURN -1
    setactor[THISACTOR].extra 0
  }
endevent




If a RESPAWN has never respawned during a game then that should be counted as one enemy the player failed to kill. After the first respawn, it does _not_ count as a missed enemy unless it has actually spawned another enemy. I doubt that logic is built into the game.

Hello, what is the actor's 'extra' doing that requires it to be set to 0 ?

View PostFox, on 03 October 2015 - 12:22 AM, said:

Yes, it will re-interpret THISACTOR. If you use it for getactor, THISACTOR returns the current actor ID, for getplayer it will be the nearest player ID, and for getsector it will be the current actor sector ID.


Just to clarify, are you saying that:
getactor[THISACTOR].sectnum temp
getsector[temp].somethingorother ....


can actually be done with
getsector[THISACTOR].somethingorother ...


That'd be useful.

View PostFox, on 03 October 2015 - 12:22 AM, said:

It's tricky, but in multiplayer you would have to change the value of max_actors_killed for all players...


Indeed, I'm hoping that using extspritestat and specifying STAT_PLAYER will iterate through each player, though I'm not sure if the sprite values returned by that function will be valid in accessing the player-specifc sprite vars. Gonna just have to suck it and see.

View PostFox, on 03 October 2015 - 12:22 AM, said:

Not sure where you are getting with this. First of all, EVENT_GAME runs every tic for all existing sprites in the map, including sleeping (zombie) actors. So a global gamevar would be overwritten.

This was the vital answer that I hadn't been able to find stated explicitly. When I sketched out the game loop I posted I did not have that as a gaurentee, hence implementing things the way I did.

View PostFox, on 03 October 2015 - 12:22 AM, said:

If you want to prevent an actor from ever sleeping, I believe this would work:
onevent EVENT_GAME
  ifactor MYACTOR
    setactor[THISACTOR].httimetosleep 0
endevent



Ah, I'd been using this wiki page which didn't mention httimetosleep. After a search, it is listed in this page which shows even more interesting looking stuff. What's going on ? Is the first page a general sprite structure, and the second page adds gamevars that are also applicable to sprites defined as (user)actors? i.e. setactor[THISACTOR].httimetosleep will work for a (user)actor but blow up if I tried to use it on a regular every day decorative sprite ?

TTFN,
Jon

PS: I want 'ifsoundvar' but it doesn't exist. Is there an alternative ? Currently I've a 450 line monster func to attempt this functionality - yeuk! - IIRC, the first time I've used a spreadsheet to generate code !
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1698

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

If a RESPAWN has never respawned during a game then that should be counted as one enemy the player failed to kill. After the first respawn, it does _not_ count as a missed enemy unless it has actually spawned another enemy. I doubt that logic is built into the game.

I had written a code for that some time ago, as far I remember the results were very precise. I may take a look at it again...

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

Hello, what is the actor's 'extra' doing that requires it to be set to 0 ?

It's used by the game to make RESPAWNs work. Not my fault.

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

Just to clarify, are you saying that:
getactor[THISACTOR].sectnum temp
getsector[temp].somethingorother ....


can actually be done with
getsector[THISACTOR].somethingorother ...


That'd be useful.

Correct.

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

Indeed, I'm hoping that using extspritestat and specifying STAT_PLAYER will iterate through each player, though I'm not sure if the sprite values returned by that function will be valid in accessing the player-specifc sprite vars. Gonna just have to suck it and see.

In this case, you wouldn't loop through the player actors, but the player IDs.

  setvar temp 0
  whilevarvarn temp MULTIMODE
  {
    getplayer[temp].max_actors_killed temp2
    addvar temp2 1
    setplayer[temp].max_actors_killed temp2
    addvar temp 1
  }


View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

This was the vital answer that I hadn't been able to find stated explicitly. When I sketched out the game loop I posted I did not have that as a gaurentee, hence implementing things the way I did.

Being even more explicit, note that I said sprites, not actors, because EVENT_GAME also run through decorative sprites or projectiles.

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

Ah, I'd been using this wiki page which didn't mention httimetosleep. After a search, it is listed in this page which shows even more interesting looking stuff. What's going on ? Is the first page a general sprite structure, and the second page adds gamevars that are also applicable to sprites defined as (user)actors? i.e. setactor[THISACTOR].httimetosleep will work for a (user)actor but blow up if I tried to use it on a regular every day decorative sprite ?

These pages are redundant. In a website running on a wiki software you define categories for pages, which serve merely for an organizational purpose. However EDukeWiki has its own page for structures, which are preferable.

These structures exist for all sorts of sprites.

View PostThe Mechanic, on 03 October 2015 - 01:47 AM, said:

PS: I want 'ifsoundvar' but it doesn't exist. Is there an alternative ? Currently I've a 450 line monster func to attempt this functionality - yeuk! - IIRC, the first time I've used a spreadsheet to generate code !

Indeed, that command doesn't appear to exist. Don't forget ifsound is unsynchronized, so be careful!

This post has been edited by Fox: 03 October 2015 - 02:14 AM

0

User is offline   Jblade 

#1699

ifsound should just accept a variable itself, have you tried it?
1

#1700

View PostFox, on 03 October 2015 - 02:14 AM, said:

  setvar temp 0
  whilevarvarn temp MULTIMODE
  {
    getplayer[temp].max_actors_killed temp2
    addvar temp2 1
    setplayer[temp].max_actors_killed temp2
    addvar temp 1
  }



Ah-ha, so the mysterious MULTIMODE is in fact the number of players. (Does a bit more delving) should that be numplayers as that doesn't include bot players? (for the original purposes of kill count I doubt it makes any difference, but I'm thinking more generally).

View PostFox, on 03 October 2015 - 02:14 AM, said:

Don't forget ifsound is unsynchronized, so be careful!


Do you mean unsynchronised between multiple players ? Or something worse ?

The reason I'm using my "ifsoundvar" is only to enable playing one sound effect after another finishes (I've given up doing this with door sectors as duke's door-generated sounds are bloody unpredictable at best), or loop a sound (save building elevator help sectors - that really was a neat trick). I'm not using the end of a sound to do anything more than that so should I get away with it ?

If my object spawns a sound - 71, say - and whilst that is playing some other game event also starts a sound 71 then yes my object will be waiting for the second one to finish, but that is a minor limitation of my system. In practice the sounds spawned by my object are likely to not crop up at the same time elsewhere.

View PostJblade, on 03 October 2015 - 02:50 AM, said:

ifsound should just accept a variable itself, have you tried it?


By accident yes. (Indeed, 75% of errors I make are 'cos I forget the additioanl 'var' on the end of funcs).

There is 'sound' for playing a fixed sound, 'soundvar' for sounds based on a variable, 'ifsound' to check for a fixed sound and .... (drum roll) ... no fricken 'ifsoundvar' :)

TTFN,
Jon

This post has been edited by The Mechanic: 03 October 2015 - 05:03 AM

0

User is online   Mark 

#1701

How about just creating your own custom sounds instead of complicated code or Build tricks to play one sound after another, etc...

This post has been edited by Mark.: 03 October 2015 - 05:57 AM

0

#1702

View PostMark., on 03 October 2015 - 05:26 AM, said:

How about just creating your own custom sounds instead of complicated code or Build tricks to play one sound after another, etc...


Because I'm creating a re-usable library - think extended/improved version of sector effectors and such. The sound system is also a lot more than only stitching sounds together.

I agree if I were only working on a specific map then, yes, simply whip out CoolEdit Pro or Audacity and stitch the necessary sounds together, job done.

TTFN,
Jon
0

User is online   Mark 

#1703

Ok. I didn't realise your goal was creating something for everyone. Your doin' great, carry on. :)
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1704

View PostThe Mechanic, on 03 October 2015 - 04:57 AM, said:

Do you mean unsynchronised between multiple players ? Or something worse ?

Yeah. It's okay to use ifsound to check if a sound should be played. But, for example, sounds are never played if you have sounds off in the menu, so anything that affects the game would break the sync in multiplayer.
1

#1705

Me again. This CON system is driving me _nuts_!

I desperately need an explanation of what is going on with sprite indexes as seen in a CON file and actual sprite numbers I see in mapster and how they might change.

Example: using headspritesect + nextspritesect, during a particular EVENT_LOADACTOR, I'm iterating round some sprites in a sector. In my test map I get three sprites (223,220,208). Fine. I have this:

gamevar myvar -1 2 // Per actor

I use myvar to keep a reference to the next sprite - a linked list. So, 223 has myvar=220, 220 has myvar=208 and 208 has myvar=-1 cos its the last one.

When the game is running, my CON file access sprite 223 only to find it's myvar is now -1 !?!? Wtf !?!? . So, just for a test, I also wrote the myvar values into each sprite's xvel,yvel and zvel (just to be thorough) and used DNDEBUG to dump a map and see what the hell is going on. Well, the three sprites in the sector all have xvel,yvel and zvel as I'd expected - only the the sprite numbers are different - according to mapster, they are sprites 219, 216 and 204. In effect, they've been moved down by 4. I've noticed these sprites get set an "owner", e.g. sprite 219 has an owner of 223 and so forth.

Purely for test purposes I subtracted 4 from the myvar values. As expected I now accessed the correct sprite number - 219 instead or 223 - and (....drum roll...) the sodding value of myvar was still -1 :)

I've clearly missed something fundamental - but what ? How _should_ I be keeping a reference to specific sprites ? Could something happen during the game that could cause sprite numbers to re-arrange yet again ? Or can I assume that prior to the first EVENT_GAME sprite data moves around but once the first EVENT_GAME occurs the sprite data finally stays put ?

TTFN,
Jon
0

User is offline   Mblackwell 

  • Evil Overlord

#1706

Question(s):

Why are you doing the iteration in LOADACTOR?
What's your goal?
Did you remember to use s/getactorvar[actorid].myvar ?


If the sprites are being spawned at any point (beyond initial load) the IDs can definitely change. Nothing to do with CON, it's the engine itself.
0

#1707

View PostMblackwell, on 05 October 2015 - 12:12 PM, said:

Question(s):

Why are you doing the iteration in LOADACTOR?
What's your goal?
Did you remember to use s/getactorvar[actorid].myvar ?


If the sprites are being spawned at any point (beyond initial load) the IDs can definitely change. Nothing to do with CON, it's the engine itself.


I'm grouping sprites together during initialisation so I can subsequently manipulate them as group of sprites.

As an example, I've a custom "locator" sprite which get grouped together (via hitag) in a user defined order (lotag) in order to define a path, imagine the overhead of sorting that little lot on every game tic. Then there is grouping regular sprites - such as a platform made of regular sprites - which are linked together in a group and follow a path defined by those locators. Pretty much impossible if the sprite indexes keep moving around.

If I can't reliably identify the exact same sprite on different game tics then that pretty much destroys a lot of what I'm wanting to achieve :)

TTFN,
Jon
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#1708

If I get it, you are using the hitag to store the ID of another sprites? That's a no-no. Sprites are not supposed to keep their ID when the map is loaded by the game.
0

User is offline   Mblackwell 

  • Evil Overlord

#1709

You should always save hi and lo tags into a var and then set them to 0, I assume you're doing that already.

A couple of better bets might be:

1) Use custom statnums and headspritestat. (This is great for random stuff)

2) A better method still for LOCATOR type things would probably be to create arrays with offsets. To do it of course you'll need to figure out the max/how many points you want in each path. The hitag would be ordered rather than a random unique number. Each mylocator would simply have to insert its sprite id at position mylotag*MAXPOINTS+myhitag in the array. So for 30 separate paths with 30 different points you'd need an array size of 930 (actually you'd get 31 paths I think due to path 0 but I'm not going to do the math atm). Then individual actors just need to traverse their assigned set of mylocators.
1

#1710

View PostFox, on 05 October 2015 - 04:23 PM, said:

If I get it, you are using the hitag to store the ID of another sprites? That's a no-no. Sprites are not supposed to keep their ID when the map is loaded by the game.


No. The hitag is used as the "channel" that marks an actor as part of that group. The idea was during initialisation this would be used to set up linked list pointers (implemented as per-actor gamevars). Where sorting was needed that was done via lotag. Advantages:
1) After initialisation, lotag and hitag are redundant
2) When I fire an activation (a jonz version at this point in time) I just scoot across the first sprites in the group and flag that they've been activated and need to do something when it is their turn.
3) When moving a group of sprites they absolutely have to move at exactly the same time and not wait for their respective EVENT_GAME calls else they will flicker. A linked list of exactly the ones to move is quick and simple.

All in all a brilliant plan - right up to the point where ID's change :D

The effects are totally configured via standard mapster, so primarily they need configuring via lotag/hitag, 'extra' if I need a bit more, and so on (I've a csutom mapster with a menu system which will simplify this setup, but the effects will always be configurable via standard mapster). Part of initialisation is to stash these values and if necessary reset them. With very few exceptions, I leave standard sprite array data well alone after initialisation.

View PostMblackwell, on 05 October 2015 - 07:08 PM, said:

You should always save hi and lo tags into a var and then set them to 0, I assume you're doing that already.

Indeed. Other than borrowing a few flags in cstat (which has some debugging advantages) I'm avoiding reusing standard sprite variables.

View PostMblackwell, on 05 October 2015 - 07:08 PM, said:

A couple of better bets might be:

1) Use custom statnums and headspritestat. (This is great for random stuff)


I didn't think I could use statnum (wiki page) as I infered it might change in, or influence, the game operation.

"Unassigned status numbers are reserved for future EDuke32 features. Please ask the developers to allocate an official user statnum range for CON-side features, should this be desired." You start the petition to allocate statnum > 1024 for user defined use whilst I print the campaign t-shirts and mugs :) With luck, the Eduke developers need do no more than update the wiki so very little effort required?

View PostMblackwell, on 05 October 2015 - 07:08 PM, said:

2) A better method still for LOCATOR type things would probably be to create arrays with offsets.


Do you mean that, using my previous example sprites {223,220,208}, their ID's may move but their relative ID's will always be the same e.g. {222,219,207}, or {23,20,08} etc ? Otherwise I don't see how an array will help.

View PostMblackwell, on 05 October 2015 - 07:08 PM, said:

To do it of course you'll need to figure out the max/how many points you want in each path. The hitag would be ordered rather than a random unique number. Each mylocator would simply have to insert its sprite id at position mylotag*MAXPOINTS+myhitag in the array.


But the ID changes and its been suggested this isn't just on completion of initialisation but also if during the game something is spawned.

View PostMblackwell, on 05 October 2015 - 07:08 PM, said:

So for 30 separate paths with 30 different points you'd need an array size of 930 (actually you'd get 31 paths I think due to path 0 but I'm not going to do the math atm). Then individual actors just need to traverse their assigned set of mylocators.


Again, how do they find their associated locators as the ID's of these locators may change?

OK, example. My group of sprites, lets say {42,69}, are moving from locator 100 to locator 110. Suddenly, something is spawned and causes sprite ID's to change, lets say my locators are now 98 and 108 and group of sprites {22,49}. How does my group of sprites find these locators? Bear in mind this is unsynchronised, that is, the group of sprites may move after the locator's ID's have changed but before the locator's have been processed so that they could update some table to reflect their new ID's ?

AH! (lightbulb finally flickers into life), maybe I've just seen where you were going. Assign each group a unique statnum value and use this as the linking mechanism e.g. sprites with statnum 1025 follow the path of locators statnum 1234. I'll take a peek in the code for the size of statnum - if I'm _real_ lucky I could simply use statnum = 1024 + original hitag value. No need for any extra tables at all. Mblackwell, I owe you one. :)

Right, off to re-write half me darn code :)

TTFN,
Jon

[Edit] Sprites that are blocking, hitable and have hitag (=>destructable) have their statnums set to 17 so above method for grouping needs to be to iterate all sprites with matching statnums AND all sprites with satnum 17 and matching hitag. Given I'm not interacting with enemies,players,weapons,projectiles and so forth- only inanimate objects - additional checking for statnum 17's is the only extra effort I need. I hope.

This post has been edited by The Mechanic: 06 October 2015 - 02:30 AM

1

Share this topic:


  • 124 Pages +
  • « First
  • 55
  • 56
  • 57
  • 58
  • 59
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options