RedBeard

Member
RedBeard submitted a new resource:

Randomly moving NPC - Moving NPC

Thanks @Po0ka for help with this.

This is an NPC script that moves the mobile to different pre set locations based on a timer.
As an example I made a Thief Guildmaster, other ideas I had for this were moving caravans or camps.

Best to put this on a XMLSpawner so you can track movement.

Read more about this resource...
 

Attachments

  • MovingNPC.cs
    2.4 KB · Views: 41
Last edited:
Nice idea, and made me look up how to set spawn location with xmlspawner: http://www.uoroleplay.com/resources...-item39s-at-specific-location39s_post120.html

godfood- 01-06-2006
I'm trying to build a castle gate, and I need to spawn specific itemid's at specific location's. Then i need to set up a lever to raise the gate. (inc z 34) Then when the lever reset's, the gate goes back down.

I should be able to figure out the rest of it, but before I can even try I need to know how to spawn statics at specific locations.

godfood- 01-06-2006
Ok, I think I found it. I forgot there is still tons of information over at RunUO

QUOTE (ArteGordon)
if you want to spawn something at a specific location, you can just set the its x,y coordinates in the spawn entry, like this

orc/x/100/y/100

this will spawn the orc and then move it to 100,100

Now, the orc's Home location will still be where it was actually spawned.
If you wanted to change that as well, you would do

orc/x/100/y/100/home/(100,100,0)

where (100,100,0) is how you would specify a Point3D type of property (thats what Home is).

If you didnt change the home, then it would move to 100,100 and then proceed to wander back to the original home location, which is the little trick that is used in katarquest to start the mob 40 tiles away and then have it wander back.

(edit)

note that you can also set the Location property (which is a Point3D) to move it instead of setting x and y separately, like this

orc/location/(100,100,0)

godfood- 01-07-2006
Ok, I got everything to spawn at the proper locations, then I moved on to adding the lever so I could make it open and close.....No, Of course not. I've tried GOTO's, i've tried DESPAWNS I've tried all kind's of things. I just can't get anything to work. Arte? how can I set up a lever that controls the oppening and closing of my gate?

ArteGordon- 01-07-2006
so to spawn the gate at your location you have something like

irongate,0/location/(x,y,z)

Just assign that to subgroup 1 because you are going to refer to that subgroup # when you assign the target of the lever.

Then add your lever entry with subgroup 2 like

simplelever

and then add entries like this to subgroup 3

SETONSPAWN,2/target0item/GETONSPAWN,1,Serial/target0property/@/z/INC,-40
SETONSPAWN,2/target1item/GETONSPAWN,1,Serial/target1property/@/z/INC,40

Notice how you use the special literal character @ so that you can have slashes in the property string that you assign (it prevents it from parsing the string after that point) since you want the target property string to look like "/z/INC,40"

and when you are done you can have the spawner turn itself off by putting this in subgroup 4

SETONTHIS/running/false

Then just turn on sequential spawning so that it will run through these steps in order, do a reset, turn it on and it will set everything up for you.

Here is the XML for a spawner that does all of that (set up in green acres)

QUOTE

<Spawns>
� <Points>
� � <Name>GateSpawner</Name>
� � <UniqueId>6267c82a-36ff-4a02-85e6-52e210023025</UniqueId>
� � <Map>Felucca</Map>
� � <X>5436</X>
� � <Y>1167</Y>
� � <Width>10</Width>
� � <Height>10</Height>
� � <CentreX>5441</CentreX>
� � <CentreY>1172</CentreY>
� � <CentreZ>0</CentreZ>
� � <Range>5</Range>
� � <MaxCount>5</MaxCount>
� � <MinDelay>0</MinDelay>
� � <MaxDelay>0</MaxDelay>
� � <DelayInSec>False</DelayInSec>
� � <Duration>0</Duration>
� � <DespawnTime>0</DespawnTime>
� � <ProximityRange>-1</ProximityRange>
� � <ProximityTriggerSound>500</ProximityTriggerSound>
� � <TriggerProbability>1</TriggerProbability>
� � <InContainer>False</InContainer>
� � <MinRefractory>0</MinRefractory>
� � <MaxRefractory>0</MaxRefractory>
� � <TODStart>0</TODStart>
� � <TODEnd>0</TODEnd>
� � <TODMode>0</TODMode>
� � <KillReset>1</KillReset>
� � <ExternalTriggering>False</ExternalTriggering>
� � <SequentialSpawning>0</SequentialSpawning>
� � <AllowGhostTriggering>False</AllowGhostTriggering>
� � <SpawnOnTrigger>False</SpawnOnTrigger>
� � <SmartSpawning>False</SmartSpawning>
� � <Team>0</Team>
� � <Amount>1</Amount>
� � <IsGroup>False</IsGroup>
� � <IsRunning>False</IsRunning>
� � <IsHomeRangeRelative>True</IsHomeRangeRelative>
� � <Objects2>irongate,0/location/(5440,1176,0):MX=1:SB=1:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=simplelever/location/(5438,1178,0):MX=1:SB=2:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONSPAWN,2/target0item/GETONSPAWN,1,Serial/target0property/@/z/INC,-40:MX=1:SB=3:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONSPAWN,2/target1item/GETONSPAWN,1,Serial/target1property/@/z/INC,40:MX=1:SB=3:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONTHIS/running/false:MX=1:SB=4:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1</Objects2>
� </Points>
</Spawns>


Oh, and if you wanted to do this with a timed lever just use that instead of the simple lever and set the min/maxdelay, like

timedlever/mindelay/00:00:10/maxdelay/00:00:10

godfood- 01-10-2006
Ok, FINALLY got around to trying this out. It work's great . For 1 gate. Unfortunately my gate has 12 pieces that move together as one. any ideas Arte?

ArteGordon- 01-10-2006
You could either chain together a bunch of levers (could make some invisible) to control the other gates.
That would mean repeating that stuff 12 times.

Or, you could have spawners to control all 12 pieces. Just have your setup spawner place your various gate pieces together in subgroup 1, and then your controlling spawner would do the increment of z with a line like

SETONSPAWN,setupspawner,1/z/INC,40

That would change the z for all of the subgroup 1 entries (your gate pieces).

Then you could do the same for lowering.

Then have the lever activating those spawners instead of setting the gate z properties directly.

godfood- 01-10-2006
>_< now I can't seem to get it to trigger.....

[add xmlspawner
props>Proxmityrange 1
props>spawnontrigger true
props>Set the trigger object
props>Set the trigger prop to "leverstate=1"

add 1 orc into the spawner entry

Flip the lever, nothing.

I also tried this with a door and open=true to see if it had anything to do with your new link system.

Mage-Solitaire- 01-10-2006
try "LeverState = 1"
or come directly where my crafter donjon is, tonight, i'll show you Godfood

ArteGordon- 01-10-2006
it is probably because you have your min/maxdelay set to something large and you were not moving when you threw the lever.

When you set the ProximityRange and the SpawnOnTrigger, it will trigger on movement and immediately spawn the orc if the lever is thrown, but if the player is standing still and throws it, then the spawner has to wait until the next tick to detect them. Passive player detection only occurs during the spawners OnTick.

Set your min/maxdelay to zero and it will allow you to detect stationary players as well as moving ones.

(edit)

Case is ignored for properties names so 'leverstate' and 'LeverState' will both work.

ArteGordon- 01-10-2006
If you just want a spawn that will be instantly spawned whenever a player throws the lever, try it this way

1) put your orc on a spawner, and set the ProximityRange to -2. This creates a spawner that can only be triggered externally.

2) Then add your lever, set the Target1Item to point to the spawner.
Set the Target1Property to the string "/proximityactivated/true/nextspawn/0"

Now, whenever you throw the lever into the 1 position it will force the spawner trigger immediately.

This doesnt rely on player movement, or player proximity detection, and doesnt have to have the spawner checking on the lever all the time so it doesnt matter what min/maxdelay are set to.

This is the recommended way to actively trigger a spawner externally.

(edit)

note, this will give you 'one-shot' behavior, which means that the orc will only appear when you actually throw the lever to the 1 position causing the spawner to be triggered once. The lever would have to go back to 0 and be thrown to 1 again to retrigger it.

Doing it the other way will allow orcs to continue to be respawned after they are killed for as long as the lever is in the 1 position.

ArteGordon- 01-10-2006
I attached a spawn file that implements the single lever raising and lowering multiple gates using spawners in the way that I described earlier.

It spawns the gates, spawns a timedlever, and has 2 controller spawners - one to raise the gates, the other to lower.
I even added some sound effects to the raising and lowering of the gates.

It is set up in green acres. You can add as many gates to the GateSpawner#1 as you like and they will all still be under the control of the one lever.

ArteGordon- 01-10-2006
here is another variant. It uses sequential spawning for the gate raising to animate the process, going through 4 intermediate lifting stages.


godfood- 01-18-2006
QUOTE
so to spawn the gate at your location you have something like

irongate,0/location/(x,y,z)

Just assign that to subgroup 1 because you are going to refer to that subgroup # when you assign the target of the lever.

Then add your lever entry with subgroup 2 like

simplelever

and then add entries like this to subgroup 3

SETONSPAWN,2/target0item/GETONSPAWN,1,Serial/target0property/@/z/INC,-40
SETONSPAWN,2/target1item/GETONSPAWN,1,Serial/target1property/@/z/INC,40

Notice how you use the special literal character @ so that you can have slashes in the property string that you assign (it prevents it from parsing the string after that point) since you want the target property string to look like "/z/INC,40"

and when you are done you can have the spawner turn itself off by putting this in subgroup 4

SETONTHIS/running/false

Then just turn on sequential spawning so that it will run through these steps in order, do a reset, turn it on and it will set everything up for you.


Is there a simple way like this to control a MULTIADDON? I tried this method and the lever isn't getting anything for a "targetXitem" just the "TargetXproperty".

I can do the multiple soawner method, but that's just messy .

ArteGordon- 01-19-2006
It will work the same for multiaddons as any other object.
You probably didnt set it up to sequential spawn. It has to go through the entries in order. Here is an example

CODE

<Spawns>
<Points>
<Name>MultiControl</Name>
<UniqueId>69575a45-6737-43f9-893b-68f869c10d25</UniqueId>
<Map>Felucca</Map>
<X>5445</X>
<Y>1159</Y>
<Width>0</Width>
<Height>0</Height>
<CentreX>5445</CentreX>
<CentreY>1159</CentreY>
<CentreZ>0</CentreZ>
<Range>5</Range>
<MaxCount>5</MaxCount>
<MinDelay>0</MinDelay>
<MaxDelay>0</MaxDelay>
<DelayInSec>False</DelayInSec>
<Duration>0</Duration>
<DespawnTime>0</DespawnTime>
<ProximityRange>-1</ProximityRange>
<ProximityTriggerSound>500</ProximityTriggerSound>
<TriggerProbability>1</TriggerProbability>
<InContainer>False</InContainer>
<MinRefractory>0</MinRefractory>
<MaxRefractory>0</MaxRefractory>
<TODStart>0</TODStart>
<TODEnd>0</TODEnd>
<TODMode>0</TODMode>
<KillReset>1</KillReset>
<ExternalTriggering>False</ExternalTriggering>
<SequentialSpawning>1</SequentialSpawning>
<AllowGhostTriggering>False</AllowGhostTriggering>
<SpawnOnTrigger>False</SpawnOnTrigger>
<SmartSpawning>False</SmartSpawning>
<Team>0</Team>
<Amount>1</Amount>
<IsGroup>False</IsGroup>
<IsRunning>False</IsRunning>
<IsHomeRangeRelative>True</IsHomeRangeRelative>
<Objects2>MULTIADDON,undead.txt:MX=1:SB=1:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=simplelever:MX=1:SB=2:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONSPAWN,2/target0item/GETONSPAWN,1,Serial/target0property/@/z/INC,-40:MX=1:SB=3:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONSPAWN,2/target1item/GETONSPAWN,1,Serial/target1property/@/z/INC,40:MX=1:SB=3:RT=0:TO=0:KL=0:RK=0:CA=0:DN=-1:DX=-1:SP=1:OBJ=SETONTHIS/running/false:MX=1:SB=4:RT=0:TO=0:KL=0:RK=0:CA=1:DN=-1:DX=-1:SP=1</Objects2>
</Points>
</Spawns>

godfood- 01-19-2006
QUOTE
You probably didnt set it up to sequential spawn


I'm pretty sure I did, but I will look again and get back to you.
 
great job. I have been trying to do this for a forest quest. Have a npc that gives a headpiece if you kill him, but wanted to have it totally non camp able
 

Active Shards

Donations

Total amount
$50.00
Goal
$1,000.00
Back