[REQWIP] ModFood: Snippets & Tips

Post » Mon May 07, 2012 5:11 am

I assume there is a reason for the time limit to be implemented? I am sure it has to do with tard's.

Anyway, this is one of my favorites.

OBJECTIVE: Attack/Defensive Magic Activator!

If the player has the item (HEROmanorKey) then the activator will not cast magic at the player.
If the player does not have the item, and is within (1200) units of the activator, and (1) second has passed, then a random (1-7) spell will be cast at the player. (where a 7 will cast no spell)

I use this on an ICObilisk created as an activator outside my Manor house. If you get to close to the house without the key, zap zap! It could also be used in a quest so you have to have an item before you can continue in a dungeon passage.

Scriptname HeroDefense1_Scriptfloat timershort spltypBegin GameMode	if player.getitemcount HEROmanorKey == 0		if getdistance player < 1200			if timer > 0				set timer to timer - getsecondspassed			else				set timer to timer + 1				set spltyp to 1 + (GetRandomPercent * 7 ) / 99				if spltyp == 1					cast StandardShockDamageTarget3Journeyman player				endif				if spltyp == 2					cast StandardFireDamageArea3Journeyman player				endif				if spltyp == 3					cast StandardDamageHealthTarget4Expert player				endif				if spltyp == 4					cast StandardBurdenTarget4Expert player				endif				if spltyp == 5					cast StandardFrostDamageTarget3Journeyman player				endif				if spltyp == 6					cast StandardParalyze4Expert player				endif			endif		endif	endifEnd
User avatar
Ashley Campos
 
Posts: 3415
Joined: Fri Sep 22, 2006 9:03 pm

Post » Mon May 07, 2012 10:33 am

Nice thread guys but please test the scripts before posting!

Some of these scripts wont work and others should come with an explaination of what will happen in certain game-play situations.
User avatar
Nims
 
Posts: 3352
Joined: Thu Jun 07, 2007 3:29 pm

Post » Mon May 07, 2012 3:47 am

had to put this one up here, as I remember the hell I went through trying to figure it out... lol...

How to make a static object summon creatures

Scriptname SummoningStationref Xivilairef GWraithref Lichref Daedrothshort aliveshort buttonshort stagebegin onactivate  set Xivilai to SummonXivilaiWR.createfullactorcopy  set GWraith to SummonGloomWraithWR.createfullactorcopy  set Lich to SummonLichWR.createfullactorcopy  set Daedroth to SummonDaedrothWR.createfullactorcopy MessageBox "Which monster would you like to summon?", "Xivilai", "Gloom Wraith", "Lich", "Daedroth", "Cancel"  set stage to 1  set alive to 1endbegin gamemode		set Button to getButtonPressed			if stage == 1 && button == 0  Xivilai.moveto killroommarker	  Message "Xivilai Summoned."  if alive	if Xivilai.getdead	  set alive to 0	  Xivilai.deletefullactorcopy	endif  endif	  set stage to 0			Returnelseif stage == 1 && button == 1  GWraith.moveto killroommarker	  Message "Gloom Wraith Summoned."  if alive	if GWraith.getdead	  set alive to 0	  GWraith.deletefullactorcopy	endif  endif	  set stage to 0			Returnelseif stage == 1 && button == 1  Lich.moveto killroommarker	  Message "Lich Summoned."  if alive	if Lich.getdead	  set alive to 0	  Lich.deletefullactorcopy	endif  endif	  set stage to 0			Returnelseif stage == 1 && button == 1  Daedroth.moveto killroommarker	  Message "Daedroth Summoned."  if alive	if Daedroth.getdead	  set alive to 0	  Daedroth.deletefullactorcopy	endif  endif	  set stage to 0			Returnelseif stage == 1 && button == 4		set stage to 0				Return			endifEnd

What you want to do is create a room in the cell you are editing that the player cannot see. I simply added a room that wasn't even attached to my mage tower. Now, you need to go to the Object Window and select Actors->Creature and select the creatures you'd like to spawn. Place them in the aforementioned room. Double-click on them, and give them a name in the Reference ID space. As you can see from above, the names I gave mine were SummonXivilaiWR, SummonGWraithWR, and so on. Then, in that main window, check the "Persistant Reference" option.
User avatar
Alexis Estrada
 
Posts: 3507
Joined: Tue Aug 29, 2006 6:22 pm

Post » Mon May 07, 2012 3:53 am

Nice thread guys but please test the scripts before posting!
Some of these scripts wont work and others should come with an explaination of what will happen in certain game-play situations.
Wow, that was helpful! Thanks for taking the time to post that! :rolleyes:
User avatar
Robert Jr
 
Posts: 3447
Joined: Fri Nov 23, 2007 7:49 pm

Post » Mon May 07, 2012 7:28 pm

It would be better to use the normal Predator faction I think, since using a new faction would require you to add these factions to every creature.

The only reason guards, etc - Fight with these creatiures normally is because these creatires initiate combat first.
User avatar
Natalie Harvey
 
Posts: 3433
Joined: Fri Aug 18, 2006 12:15 pm

Post » Mon May 07, 2012 5:06 am

It would be better to use the normal Predator faction I think, since using a new faction would require you to add these factions to every creature.

The only reason guards, etc - Fight with these creatiures normally is because these creatires initiate combat first.

I am not sure what post you are referring to???

If it is my scripting on making passive wildlife, I think it is better to use a new faction.

Why? Because, it you add 'CreatureFaction' (what you call Predator) faction to yourself, then you get the baggage that goes with it, specifically, Prey is now -50. If you add 'Prey', then CreatureFaction will now attack you because you are now prey... (-50)

Guards fight creatures, not because they initiate combat first, but because the creature is not part of the Guard faction, and the guard is not part of the CreatureFaction. Anything will attack anything that is not part of their faction.
User avatar
Luis Longoria
 
Posts: 3323
Joined: Fri Sep 07, 2007 1:21 am

Post » Mon May 07, 2012 4:18 pm

Objective: Ensuring your Messagebox is Read

The problem: Whenever a second messagebox is displayed the first disappears. The player won't be able to read your messagebox or respond to it, and your script will be stuck in an infiinite loop trying to figure out which button was pressed.

The solution: When the player presses a button on the second messagebox, only the script that called the second messagebox will be able to tell which button was pressed. So, no worries about your script recieving the wrong button, and you can put a timer on your script that will show the messagebox again. The timer won't run while the player is looking at the message, only afterwards, so the player can take however long they wish to read your message. Also, the timer won't run in options menus (player presses ) and some other menumodes that don't denote that the player has closed a messagebox. As the timer is only running when the player closes a messagebox, you can make it short. I've made it 1 second, but it can be much shorter.

float Timershort Buttonshort Choosing...if (Choosing == -1)		messagebox "Your message"		set Timer to 1		set Button to GetButtonPressed		set Choosing to 1		returnelseif (Choosing == 1)	  if (Button == -1)		if (Timer > 0)		  set Button to GetButtonPressed		  if (MenuMode 1001 == 0)			if (MenuMode 1004) || (MenuMode 1005) || (MenuMode 1006) || (MenuMode 1010) || (MenuMode 1011) || (MenuMode 1013) || (MenuMode 1015) || (MenuMode 1016) || (MenuMode 1017) || (MenuMode 1018) || (MenuMode 1019) || (MenuMode 1020) || (MenuMode 1021) || (MenuMode 1024) || (MenuMode 1038) || (MenuMode 1039) || (MenuMode 1044) || (MenuMode 1045) || (MenuMode 1046) || (MenuMode 1047) || (MenuMode 1057)			  return			else			  set Timer to (Timer - GetSecondsPassed)			  return			endif		  endif		else		  message "Trying options again."		  set Choosing to -1		endif		return	  else...
User avatar
Casey
 
Posts: 3376
Joined: Mon Nov 12, 2007 8:38 am

Post » Mon May 07, 2012 9:54 am

I am not sure what post you are referring to???

If it is my scripting on making passive wildlife, I think it is better to use a new faction.

Why? Because, it you add 'CreatureFaction' (what you call Predator) faction to yourself, then you get the baggage that goes with it, specifically, Prey is now -50. If you add 'Prey', then CreatureFaction will now attack you because you are now prey... (-50)

Guards fight creatures, not because they initiate combat first, but because the creature is not part of the Guard faction, and the guard is not part of the CreatureFaction. Anything will attack anything that is not part of their faction.


lol - Thats so untrue its funny.

Guards never attack anyone, Guards have an aggression of 5, which means they can never initiate combat. Guards only attack Creatures because those creatures initiate combat with them. NPCs do not attack anyone in their faction, and the player is not prey.
User avatar
Sammi Jones
 
Posts: 3407
Joined: Thu Nov 23, 2006 7:59 am

Post » Mon May 07, 2012 1:58 pm

Objective: Moving a subsection of an inventory from one container to another (Requires OBSE 9a/b/c)

Credit should also go to Wolfhound for this one.

This will move a portion of items from one non-player container to another. The items will stay exactly as they are - statuses, health, charge, script variables, etc.

1. Make 3 persistent reference containers and place them in a far-off cell the player can never enter (preferably one of your own). In this example they will be TempInvCont, TempListEquip, and TempListQuest for temporary inventory container, temporary list of equipped items, and temporary list of quest items.

2. Have a script that grabs the reference to the old container and the new container. Here the old container's reference is pOldCont and the new container's reference is pNewCont.

3. Add this to the appropriate script. You will probably want to place it in both a MenuMode block and a GameMode block. If you do, make sure you use different labels for each block.

short InvPositionref pInvObj	 ;Initialize		TempInvCont.RemoveAllItems		TempListEquip.RemoveAllItems		TempListQuest.RemoveAllItems	 ;Figure out player's equipment and quest items, remove everything from their inventory to TempInvCont		set InvPosition to (player.GetNumItems - 1)		Label 1		if (InvPosition >= 0)		  set pInvObj to (player.GetInventoryObject InvPosition)		  if (IsQuestItem pInvObj == 0)			if (player.GetEquipped pInvObj)			  TempListEquip.AddItem pInvObj 1			endif		  else			TempListQuest.AddItem pInvObj 1			SetQuestItem 0 pInvObj		  endif		  set InvPosition to (InvPosition - 1)		  Goto 1		endif		player.RemoveAllItems TempInvCont, 1	 ;Figure out which items in the old container (pOldCont) are what you want and which are quest items, move to player		set InvPosition to (pOldCont.GetNumItems - 1)		Label 2		if (InvPosition >= 0)		  set pInvObj to (pOldCont.GetInventoryObject InvPosition)		  if (IsQuestItem pInvObj == 0)			if (IsIngredient pInvObj == 0);or whatever test(s) you want			  SetQuestItem 1 pInvObj			endif		  else			TempListQuest.AddItem pInvObj 1		  endif		  set InvPosition to (InvPosition - 1)		  Goto 2		endif		pIngCont.RemoveAllItems player, 1	 ;Move all of the desired items to the new container (pNewCont)		player.RemoveAllItems pNewCont, 1	 ;Move all of the items back to the old container (pOldCont)		set InvPosition to (player.GetNumItems - 1)		Label 3		if (InvPosition >= 0)		  set pInvObj to (player.GetInventoryObject InvPosition)		  SetQuestItem 0 pInvObj		  set InvPosition to (InvPosition - 1)		  Goto 3		endif		player.RemoveAllItems pOldCont, 1	 ;Move all of the player's items back to the player		TempInvCont.RemoveAllItems player, 1	 ;Turn everything back into quest items		set InvPosition to (TempListQuest.GetNumItems - 1)		Label 4		if (InvPosition >= 0)		  set pInvObj to (TempListQuest.GetInventoryObject InvPosition)		  SetQuestItem 1 pInvObj		  set InvPosition to (InvPosition - 1)		  Goto 4		endif	 ;Re-equip the player		message " "		message " "		set InvPosition to (TempListEquip.GetNumItems - 1)		Label 5		if (InvPosition >= 0)		  set pInvObj to (TempListEquip.GetInventoryObject InvPosition)		  player.EquipItem pInvObj		  set InvPosition to (InvPosition - 1)		  Goto 5		endif
User avatar
meghan lock
 
Posts: 3451
Joined: Thu Jan 11, 2007 10:26 pm

Post » Mon May 07, 2012 10:28 am

Thanks for this thread, helped me alot with my mod. Keep it up!
User avatar
(G-yen)
 
Posts: 3385
Joined: Thu Oct 11, 2007 11:10 pm

Post » Mon May 07, 2012 2:46 pm

Monthly [bump]
User avatar
Yama Pi
 
Posts: 3384
Joined: Wed Apr 18, 2007 3:51 am

Post » Mon May 07, 2012 9:20 am

This really needs to be pinned! I just stumbled across this thread doing a search, and this is very educational for beginning scripters. I'd like to see more people contribute script snippets, as I'm a hungry learner.
User avatar
Juanita Hernandez
 
Posts: 3269
Joined: Sat Jan 06, 2007 10:36 am

Post » Mon May 07, 2012 1:02 pm

This really needs to be pinned! I just stumbled across this thread doing a search, and this is very educational for beginning scripters. I'd like to see more people contribute script snippets, as I'm a hungry learner.
I would love to see more posted, but they're bound to be lost here. I would suggest posting them on the wiki, or posting them here first and then eventually to the wiki (or, at the very least, give permission for others to post it to the wiki). As of now, I think I'm the only one that remembers this thread and bumps it. (By the way, there was another snippet thread, around January I think. I've forgotten the name of it completely and haven't been able to find it again, but it was good stuff so could someone find it and [bump] it)
User avatar
keri seymour
 
Posts: 3361
Joined: Thu Oct 19, 2006 4:09 am

Post » Mon May 07, 2012 11:43 am

Felic hasn't been on in ages so bumps are about all we can do...

I think we could possibly copy all the texts from the most important posts and then recreate one.

Because this is a good resource for modders.
User avatar
hannaH
 
Posts: 3513
Joined: Tue Aug 15, 2006 4:50 am

Post » Mon May 07, 2012 3:00 pm

Some of the people who contributed are still active, so any comments on wiki'ing?

Felic hasn't been on in ages so bumps are about all we can do...

I think we could possibly copy all the texts from the most important posts and then recreate one.

Because this is a good resource for modders.
That sounds like a good idea, something that will continue to be indexed...

Looking through it again - Logam, you did a bound arrow tutorial. Did you go any further with it? Namely, did you happen to figure out how to force-equip more than one arrow at a time (or is it not a problem with bound arrows)?
User avatar
Hella Beast
 
Posts: 3434
Joined: Mon Jul 16, 2007 2:50 am

Post » Mon May 07, 2012 12:08 pm

I dont know it was my first script so I probably made an error in there :P

Also I put it on the wiki and it can be found here: http://cs.elderscrolls.com/constwiki/index.php/Bound_Arrows_Tutorial
User avatar
An Lor
 
Posts: 3439
Joined: Sun Feb 18, 2007 8:46 pm

Post » Mon May 07, 2012 10:35 am

I bookmarked that particular Wiki page. Didn't even know it was there, and I've looked for things like this on the Wiki. I think the button navigation bar needs to add more stuff to make things like this more accessible. Still, I'd like to see more scripts added here. Has anyone ever thought of making a "Oblivion Scripting for Dummies" for those who are not familiar with programming? I've been learning C++ and that is the only way I'm making sense of Oblivion scripting. Months ago before I picked up my "C++ for Dummies" book, I looked at Oblivion scripting and was totally clueless. I'm getting things now, but only by learning another programming language.
User avatar
Mrs shelly Sugarplum
 
Posts: 3440
Joined: Thu Jun 15, 2006 2:16 am

Post » Mon May 07, 2012 4:36 pm

[bump] for the frozen NPC statue tut, and all the other useful snippets in here.
User avatar
ZANEY82
 
Posts: 3314
Joined: Mon Dec 18, 2006 3:10 am

Post » Mon May 07, 2012 7:14 am

[bump]
User avatar
neen
 
Posts: 3517
Joined: Sun Nov 26, 2006 1:19 pm

Post » Mon May 07, 2012 5:05 am

What a fantastic thread. Thanks for the mini-tutorials.
User avatar
Cat
 
Posts: 3451
Joined: Mon Dec 18, 2006 5:10 am

Post » Mon May 07, 2012 3:00 pm

Bumping this out of oblivion! Thank god I've managed to find it!
User avatar
Paula Rose
 
Posts: 3305
Joined: Fri Feb 16, 2007 8:12 am

Post » Mon May 07, 2012 5:32 am

I think you should mention OBSE, because I didn't see it in your first post. Some of them are simply fixed, like the Avoiding Message Spam, you can just use OBSE's AddItemNS.
User avatar
Danny Blight
 
Posts: 3400
Joined: Wed Jun 27, 2007 11:30 am

Post » Mon May 07, 2012 10:37 am

Awesome thread guys, thanks Felic for starting this. This will no doubt be invaluable to me later on when I need to do some scripting for my mod.
User avatar
Connie Thomas
 
Posts: 3362
Joined: Sun Nov 19, 2006 9:58 am

Post » Mon May 07, 2012 1:46 pm

I think you should mention OBSE, because I didn't see it in your first post. Some of them are simply fixed, like the Avoiding Message Spam, you can just use OBSE's AddItemNS.


Well, write it! It should be a community project.
User avatar
Tania Bunic
 
Posts: 3392
Joined: Sun Jun 18, 2006 9:26 am

Post » Mon May 07, 2012 9:29 am

You should add a summon creature script to the list.
User avatar
DeeD
 
Posts: 3439
Joined: Sat Jul 14, 2007 6:50 pm

PreviousNext

Return to IV - Oblivion