ID:140003
 
here is my DM code..

world
New()
..()
for(var/area/Weather/W in world)
spawn() W.DayCycle()
for(var/area/Weather/Hiliut/H in world)
spawn() H.HiliutWeather()

area
Weather
layer = 10
name = null
var
Day = 1
proc
DayCycle()
Day = 1 - Day
if(Day)
overlays += /obj/Weather/Night/Shadow1
sleep(100)
overlays -= /obj/Weather/Night/Shadow1
overlays += /obj/Weather/Night/Shadow2
else
overlays -= /obj/Weather/Night/Shadow1
sleep(100)
overlays += /obj/Weather/Night/Shadow1
overlays -= /obj/Weather/Night/Shadow2
spawn(20) DayCycle()
Hiliut
name = null
proc
HiliutWeather()
pick(
prob(200)
Clear(),
prob(50)
Rain()
)
Clear()
pick(
Clear300(),
Clear60(),
Clear30(),
Clear120(),
Clear500(),
)
Clear300()
sleep(300)
spawn() HiliutWeather()
Clear60()
sleep(60)
spawn() HiliutWeather()
Clear30()
sleep(30)
spawn() HiliutWeather()
Clear120()
sleep(120)
spawn() HiliutWeather()
Clear500()
sleep(500)
spawn() HiliutWeather()
Rain()
pick(
prob(100)
RainShower(),
prob(50)
RainStorm(),
prob(25)
Hurricane()
)
RainShower()
overlays += new/obj/Weather/Weather/Rain/RainShower
pick(
Shower300(),
Shower120(),
Shower600(),
Shower60(),
Shower30(),
Shower90(),
Shower260(),
Shower400(),
)
Shower300()
sleep(300)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower120()
sleep(120)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower600()
sleep(600)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower60()
sleep(60)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower30()
sleep(30)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower90()
sleep(90)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower260()
sleep(260)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
Shower400()
sleep(400)
overlays -= /obj/Weather/Weather/Rain/RainShower
spawn() HiliutWeather()
RainStorm()
overlays += new/obj/Weather/Weather/Rain/RainStorm
spawn() HiliutWeather()
Hurricane()
overlays += new/obj/Weather/Weather/Rain/RainStorm
spawn() HiliutWeather()
obj
Weather
layer = 10
Weather
Rain
RainShower
icon = 'Weather.dmi'
icon_state="RainShower"
RainStorm
icon= 'Weather.dmi'
icon_state="RainStorm"
Hurricane

Snow
SnowStorm1
icon='Weather.dmi'
icon_state="SnowStorm1"
SnowStorm2
icon='Weather.dmi'
icon_state="SnowStorm2"
SnowStrom3
icon='Weather.dmi'
icon_state="SnowStorm3"
Blizzard1
icon='Weather.dmi'
icon_state="Blizzard1"
Blizzard2
icon='Weather.dmi'
icon_state="Blizzard2"
Other
SandStorm
icon='Weather.dmi'
icon_state="SandStorm"
Fog
icon='Weather.dmi'
icon_state="Fog"
Mist
icon='Weather.dmi'
icon_state="Mist"
Night
layer = 11
Shadow1
icon='Weather.dmi'
icon_state="Shadow1"
Shadow2
icon='Weather.dmi'
icon_state="Shadow2"


when ever then thing changes to rain or snow etc

i want 3 NPC to change their locations according ot the weather

can some help me or give me any suggestions?
You would just change their loc. Are you sure you wrote that code by yourself? You should know how to change a location of something if you are able to do that, assuming you aren't borrowing an idea or something of the sort.
In response to Darkjohn66
hmmm...
no its not mine i found this demo and liked it so i used it...

i want it like when the weather changes the location of the NOC changes
Gokussj22 wrote:
                    pick(
Shower300(),
Shower120(),
Shower600(),
Shower60(),
Shower30(),
Shower90(),
Shower260(),
Shower400(),
)


This doesn't do what you think it does. What is ACTUALLY happening is that Shower300() is called, then Shower120() is called, then, then Shower600() is called, etc. until they're all called, then it picks between their return values (which are all null). What you want is to remove all these procs, just have one Shower(var/X) proc, and have it sleep(X) and do whatever it is you want it to do. Then, you would do var/time = rand(30,600); Shower(time). Or, use pick() for time if you absolutely MUST have it pick from one of those values.

Same with Clear.

Anyway, to have your NPCs respond to the weather, either have the area loop through each mob in its contents to call a proc on all the NPCs in it when the weather changes, or have the NPC check its area's weather, like so:

var/area/Weather/W = loc.loc
if(istype(W))
if(W.weather == "sunny")
//blah blah blah


You'd also have to give the Weather area a weather variable to keep track of the current weather, obviously.
In response to Garthor
Garthor wrote:
Gokussj22 wrote:
                    pick(
> Shower300(),
> Shower120(),
> Shower600(),
> Shower60(),
> Shower30(),
> Shower90(),
> Shower260(),
> Shower400(),
> )

This doesn't do what you think it does. What is ACTUALLY happening is that Shower300() is called, then Shower120() is called, then, then Shower600() is called, etc. until they're all called, then it picks between their return values (which are all null). What you want is to remove all these procs, just have one Shower(var/X) proc, and have it sleep(X) and do whatever it is you want it to do. Then, you would do var/time = rand(30,600); Shower(time). Or, use pick() for time if you absolutely MUST have it pick from one of those values.

Same with Clear.

Anyway, to have your NPCs respond to the weather, either have the area loop through each mob in its contents to call a proc on all the NPCs in it when the weather changes, or have the NPC check its area's weather, like so:

var/area/Weather/W = loc.loc
> if(istype(W))
> if(W.weather == "sunny")
> //blah blah blah


AND WHAT IS THIS "BLAH BLAH BLAH"??
You'd also have to give the Weather area a weather variable to keep track of the current weather, obviously.



anyways thnks very much for making my code flaw less..


but my question was How will i make 3 NPC's change their Location according to weather
In response to Gokussj22
"blah blah blah" is whatever it is you want to happen when that condition is met. If you want them to move elsewhere, then that's what it is.

In retrospect, my example should've been the other way around, as I doubt your NPCs would have a constantly-running AI loop. So:

// When the weather changes:
for(var/mob/NPC/N in src)
spawn() N.react_to_weather("what the new weather is")

mob/NPC/proc/react_to_weather(var/weather)
if(weather == "X")
// do stuff related to the weather being X
else if(weather == "Y")
// do stuff related to the weather being Y
In response to Garthor
Garthor wrote:
"blah blah blah" is whatever it is you want to happen when that condition is met. If you want them to move elsewhere, then that's what it is.

In retrospect, my example should've been the other way around, as I doubt your NPCs would have a constantly-running AI loop. So:

// When the weather changes:
> for(var/mob/NPC/N in src)
> spawn() N.react_to_weather("what the new weather is")
>
> mob/NPC/proc/react_to_weather(var/weather)
> if(weather == "X")
> // do stuff related to the weather being X
> else if(weather == "Y")
> // do stuff related to the weather being Y



do i put it to the NPC code??
and btw, i want to change their location

In response to Gokussj22
You misunderstand Garthor.
He's expecting you to put forth a minimal effort on your own and display a basic understanding of the language at hand, since without this any effort to help you would be in vain and you'd be better off with just hiring assistance. He won't provide you with a copy and paste-able code snippet and detailed instructions as to where to paste this code into 'your own'. He provided the logic structure and pointed out the main functionality you'd want to look at in order to implement this yourself.