Racial scripting

Post » Sat Sep 12, 2009 1:37 am

Okay, so I'm making this new race of people for one of my mods, and, long story short, I want to make them go blind if they're caught outside in the sunlight. They regain their sight if they go inside a building or once the sun sets. Can a script be made that covers an entire race, or that only applies to interiors?
User avatar
QuinDINGDONGcey
 
Posts: 3369
Joined: Mon Jul 23, 2007 4:11 pm

Post » Sat Sep 12, 2009 5:36 am

Are you intending this to be used with the player only, or with NPCs are well? You can easily make time-of-day checks combined with weather checks and a GetWindSpeed check to see if someone is in an exterior (or false exterior) during a clear sunny day, and apply or remove a blind effect as necessary.

I know that you can use GetRace to check against particular IDs, but I don't know if it is usable with additional races beyond the defaults (anyone know?). If it is, you could have a global script checking if the player is of the correct race, and if so, check the other conditions as outlined above. If not, the script could shut itself off (since the player's race won't change midgame).
User avatar
Emma Copeland
 
Posts: 3383
Joined: Sat Jul 01, 2006 12:37 am

Post » Sat Sep 12, 2009 10:51 am

Are you intending this to be used with the player only, or with NPCs are well? You can easily make time-of-day checks combined with weather checks and a GetWindSpeed check to see if someone is in an exterior (or false exterior) during a clear sunny day, and apply or remove a blind effect as necessary.

I know that you can use GetRace to check against particular IDs, but I don't know if it is usable with additional races beyond the defaults (anyone know?). If it is, you could have a global script checking if the player is of the correct race, and if so, check the other conditions as outlined above. If not, the script could shut itself off (since the player's race won't change midgame).


Thanks! Well, that solves the player script. Would it cause trouble if one were to use the RunScript (or whatever) command in conjunction with another script? This is a very small and isolated group of people, so repeating the script for all of their race wouldn't be terrible. The only problem I see with this would be any glitches involved with running the global day-blind for quest characters (who have their own scripts).
User avatar
Bedford White
 
Posts: 3307
Joined: Tue Jun 12, 2007 2:09 am

Post » Sat Sep 12, 2009 12:40 pm

So for the player, it might just be convenient to use the global script like I mentioned previously.

For NPCs which do not currently have a script, you can create one local script in the CS and specify that same script to control each NPC, since a local script can be reused as many times as you want in the CS.

For NPCs which already have a script, you're stuck with I think two main options. One option is to rewrite each of their respective scripts to also include this functionality, and the other is to make a copy of the NPC local script for each of them and at runtime use "NPC"->StartScript "LocalScript_Name" to target them with it. The problem is, targeted global scripts can only run on one NPC at a time, hence the need to make a copy for each of them. You could probably tie these into the player's global script or a separate one -- check to see if these special NPCs have the right script running on them, and if not, start it.


Good luck!
User avatar
Becky Palmer
 
Posts: 3387
Joined: Wed Oct 04, 2006 4:43 am

Post » Fri Sep 11, 2009 10:04 pm

So for the player, it might just be convenient to use the global script like I mentioned previously.

For NPCs which do not currently have a script, you can create one local script in the CS and specify that same script to control each NPC, since a local script can be reused as many times as you want in the CS.

For NPCs which already have a script, you're stuck with I think two main options. One option is to rewrite each of their respective scripts to also include this functionality, and the other is to make a copy of the NPC local script for each of them and at runtime use "NPC"->StartScript "LocalScript_Name" to target them with it. The problem is, targeted global scripts can only run on one NPC at a time, hence the need to make a copy for each of them. You could probably tie these into the player's global script or a separate one -- check to see if these special NPCs have the right script running on them, and if not, start it.


Good luck!


Thanks again! Now to get to work...
User avatar
jessica sonny
 
Posts: 3531
Joined: Thu Nov 02, 2006 6:27 pm


Return to III - Morrowind