Duke4.net Forums: problem with distance and gamevar - Duke4.net Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

problem with distance and gamevar

#1

is it possible to set the distance between two sprites into a gamevar?

if it is then tell me how you did it.

i tried this but it does not work


actor spawnactor 0
getactor[THISACTOR].hitag hitagvar
getactor[THISACTOR].extra extravar
ldist temp APLAYER hitagvar
ifvarvarl temp extravar { spawn 3662 }
enda


the actor works its only the ldist command that does not work. and i also tried with just dist instead of ldist.
also why is it that my actors does not work when i give them a lotag?

anyway.

the hitag of the sprite i put in with mapster is going to define what sprite to spawn. the spawn 3662 command is just a test command i will replace it with eqspawnvar hitagvar killit
extra is going to be used to set a distance before the actor should spawn something.



edit.
i noticed something wrong.
ldist temp APLAYER hitagvar. changed hitagvar to the actor spawnactor. the command should put the distance between the actor and the player into temp. before it was just messed up.
but it did not change anything for me >.<

This post has been edited by Jhect: 06 December 2010 - 08:56 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2

First off, let's acknowledge that you are a beginner at this. Your previous posts made it sound like you were in the middle of making a massive, code intensive TC, but it's clear that is not happening anytime soon unless you get really good at ripping code from other mods.

As for your problem...

As you should know from using mapster, every sprite has a unique ID number. Those ID numbers can be put into variables and used to refer to sprites in ldist and other commands.

APLAYER is not a sprite ID number. It is a pre-defined label which has a constant value of 1405 (the tile # of the player actor).
Your hitagvar variable will equal the hitag of the sprite, which is probably 0. So in your code the ldist command is finding the distance between the sprite with ID 1405 and the sprite with ID 0 (or whatever the hitag is). The results are useless and might as well be random.

For ldist to be useful, you need to have the IDs of both sprites you are interested in. THISACTOR always refers to the sprite running the code, and you need to get the other ID using findnearactor or some other method.
0

#3

first off this is not a tc. its just a mod. its going to be kinda big.
second. you have no idea how far ive come xD
actually not very far but im only modding for fun. and i set this goal that i want this actor to work. thats what im trying to figure out for now. so i dont really understand why you talk about that.

as for my problem...

ldist temp APLAYER spawnactor

let me translate this into what i thought it would say.

ldist temp 1405 3721 // puts the distance between 1405 and 3721 into temp.
ifvarvarl temp 20000 // see the distance between the spawnactor and the APLAYER is under 20000.

i see this is wrong now. so can you tell me a way to put distance between actor1 and actor2 into gamevar? or is it not possible...

This post has been edited by Jhect: 06 December 2010 - 09:30 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#4

View PostJhect, on Dec 6 2010, 09:30 AM, said:

so can you tell me a way to put distance between actor1 and actor2 into gamevar? or is it not possible...


Of course it's possible:

ldist temp THISACTOR actor2


temp is the distance, THISACTOR is the actor running the code, and actor2 is a variable holding the ID of the other actor

I think you would get more useful help if you put the code in context and explained why you need the distance.

This post has been edited by DeeperThought: 06 December 2010 - 09:53 AM

0

#5

ok thanks. and for the advice too.

what i want is to create a new actor
i did that

with mapster i give the actor a hitag of 3662
with mapster i give the actor an extra of 20000

with getactor[THISACTOR].hitag hitagvar
i use eqspawnvar to spawn a number based on the hitag of the actor.
but not before player is closer than 20000.

im not sure if this what what you wanted to know.
0

User is offline   Danukem 

  • Duke Plus Developer

#6

View PostJhect, on Dec 6 2010, 09:59 AM, said:

ok thanks. and for the advice too.

what i want is to create a new actor
i did that

with mapster i give the actor a hitag of 3662
with mapster i give the actor an extra of 20000

with getactor[THISACTOR].hitag hitagvar
i use eqspawnvar to spawn a number based on the hitag of the actor.
but not before player is closer than 20000.

im not sure if this what what you wanted to know.


No, I wanted to know WHY you are doing all of that. Obviously an actor doing those things will have no effect on actual gameplay, so there must be some other purpose.

Also, hitag and extra do not stay set once the game starts. To use those values you have get them from the sprite at map load time, which means you need the eventloadactor command (look it up on the wiki).
0

User is offline   CruX 

#7

View PostJhect, on Dec 6 2010, 09:59 AM, said:

i use eqspawnvar to spawn a number based on the hitag of the actor.


This command doesn't spawn things. It puts them into a queue to be deleted. In think anyway.

This post has been edited by EmericaSkater: 06 December 2010 - 10:27 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#8

View PostEmericaSkater, on Dec 6 2010, 10:24 AM, said:

This command doesn't spawn things. It puts them into a queue to be deleted.


Actually it does both.
0

User is offline   CruX 

#9

Still seems like a bit of an outlandish command to use. Most of the stuff I spawn has it's own fadeout code, though, so I never really worried about deletion queues much.
0

#10

sorry double post xD

This post has been edited by Jhect: 06 December 2010 - 10:54 AM

0

#11

well emericaskater i tested that. it worked.
i know my english is quite bad. but this seems to be my problem:

deeperthought:
Also, hitag and extra do not stay set once the game starts. To use those values you have get them from the sprite at map load time, which means you need the eventloadactor command (look it up on the wiki).

actor spawnactor 0
getactor[THISACTOR].hitag hitagvar
getactor[THISACTOR].extra extravar
ldist temp APLAYER spawnactor
[b]ifvarl temp 20000[/b] { spawn 3662 }
enda

// this one works

actor spawnactor 0
getactor[THISACTOR].hitag hitagvar
getactor[THISACTOR].extra extravar
ldist temp APLAYER spawnactor
[b]ifvarvarl temp extravar[/b] { spawn 3662 }
enda

// this one does not work

so im gonna look that up deeperthought, thanks.



what i really want the actor do is. is to spawn actors similard to the respawn sector effector.
i want my mod to have some events like monsters spawning in different ways. this actor may not be complete because i dont know if i want to add more thinks. it is very possible that i will add more things.
it is going to spawn different kind of items or actors. but with more possibilities than the respawn SE.
it is definently going to be useful.

This post has been edited by Jhect: 06 December 2010 - 10:52 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#12

View PostJhect, on Dec 6 2010, 10:50 AM, said:

what i really want the actor do is. is to spawn actors similard to the respawn sector effector.
i want my mod to have some events like monsters spawning in different ways. this actor may not be complete because i dont know if i want to add more thinks. it is very possible that i will add more things.
it is going to spawn different kind of items or actors. but with more possibilities than the respawn SE.
it is definently going to be useful.


That sounds like the SPAWNER from DukePlus:

Quote

Spawner
A Duke Plus Spawner is similar to a RESPAWN sprite, but with many more options. Once activated, a spawner will periodically spawn a sprite of a certain tile (such as a monster) a certain number of times. Upon spawning the last one, it can operate activators, masterswitches and respawns if you desire. It is highly customizable.

Mapster instructions:
Place a sprite of tile number 2958 (the red S). In game, the Spawner can be activated in three ways. If you give the Spawner a lotag of -1, it will activate as soon as it can "see" the player (just like a monster). With a lotag of 1, it will activate when the player enters its sector. If the Spawner has a lotag higher than 1, then it will be triggered by an ACTIVATOR, ACTIVATORLOCKED, DUKE PLUS TOUCHPLATE or other DP activation with a YVEL equal to that lotag. If you leave the lotag at 0, it will not work at all.

Now that you have set the lotag, set the hitag to the tile number of the sprite (e.g. 2000 for PIGCOP) you want it to spawn. Set its shade to the total number of sprites you want it to spawn, or set the shade to a negative value to spawn without end. Setting its pal lower than 26 will make the spawned sprites have that pal. If pal is 26 or higher, then it acts as a delay (in number of ticks) until the first sprite is spawned (this is not the same as the delay between spawns). If the spawned sprites are monsters, you can set the XVEL of the spawner to the tile number of something you want the monsters to spawn when they die (just like you would set it on individual monsters). Normally, spawned sprites use the TRANSPORTERSTAR effect when they spawn in, but you can disable this by setting XVEL on the spawner to -1 (useful if you are spawning something that isn't a monster, such as TRASH). You can also set the EXTRA on the Spawner to set the monster flags of the spawned monsters (again, just like you would set it on the monster sprites). Set ZVEL to the number of ticks in between spawns (130 would be five seconds). Finally, set YVEL if you want it to operate activators and master switches when the last sprite is spawned (YVEL = the lotag it activates).

A spawner can made to spawn jibs, but you must use one of the following hitags:
2246 // spine

2251 // eyeball

2256 // heart

2261 // intestines

2266 // ribs

0

#13

yea well it does the same so ofcourse it sounds the same. here is the describtion for my actor:

actor spawnactor 3440
spawns a tilenumber
hitag = tilenum to spawn
extra = max distance between APLAYER and actor

im nearly sure that i will add more to it. but thats what i have now. and its not even completed haha
0

Share this topic:


Page 1 of 1
  • 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