[REQ/WIP] ModFood: Snippets & Tips

Post » Sat Feb 19, 2011 6:10 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
Heather Dawson
 
Posts: 3348
Joined: Sun Oct 15, 2006 4:14 pm

Post » Fri Feb 18, 2011 8:50 pm

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
Trey Johnson
 
Posts: 3295
Joined: Thu Oct 11, 2007 7:00 pm

Post » Sat Feb 19, 2011 9:37 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
u gone see
 
Posts: 3388
Joined: Tue Oct 02, 2007 2:53 pm

Post » Sat Feb 19, 2011 6:28 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
Anna Watts
 
Posts: 3476
Joined: Sat Jun 17, 2006 8:31 pm

Post » Sat Feb 19, 2011 7:43 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.
User avatar
DAVId Bryant
 
Posts: 3366
Joined: Wed Nov 14, 2007 11:41 pm

Post » Sat Feb 19, 2011 8:41 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
LuCY sCoTT
 
Posts: 3410
Joined: Sun Feb 04, 2007 8:29 am

Post » Fri Feb 18, 2011 8:19 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
carla
 
Posts: 3345
Joined: Wed Aug 23, 2006 8:36 am

Post » Fri Feb 18, 2011 11:18 pm

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
Elina
 
Posts: 3411
Joined: Wed Jun 21, 2006 10:09 pm

Post » Sat Feb 19, 2011 4:35 am

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
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Sat Feb 19, 2011 7:30 am

Thanks for this thread, helped me alot with my mod. Keep it up!
User avatar
Claire Lynham
 
Posts: 3432
Joined: Mon Feb 12, 2007 9:42 am

Post » Sat Feb 19, 2011 11:41 am

Monthly [bump]
User avatar
Crystal Birch
 
Posts: 3416
Joined: Sat Mar 03, 2007 3:34 pm

Post » Fri Feb 18, 2011 7:47 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.
User avatar
Marguerite Dabrin
 
Posts: 3546
Joined: Tue Mar 20, 2007 11:33 am

Post » Fri Feb 18, 2011 8:46 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
carley moss
 
Posts: 3331
Joined: Tue Jun 20, 2006 5:05 pm

Post » Sat Feb 19, 2011 9:58 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
Melly Angelic
 
Posts: 3461
Joined: Wed Aug 15, 2007 7:58 am

Post » Sat Feb 19, 2011 5:41 am

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
Frank Firefly
 
Posts: 3429
Joined: Sun Aug 19, 2007 9:34 am

Post » Fri Feb 18, 2011 7:54 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
RAww DInsaww
 
Posts: 3439
Joined: Sun Feb 25, 2007 5:47 pm

Post » Sat Feb 19, 2011 12:56 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
NeverStopThe
 
Posts: 3405
Joined: Tue Mar 27, 2007 11:25 pm

Post » Fri Feb 18, 2011 11:25 pm

[bump] for the frozen NPC statue tut, and all the other useful snippets in here.
User avatar
Robert Jr
 
Posts: 3447
Joined: Fri Nov 23, 2007 7:49 pm

Post » Sat Feb 19, 2011 11:40 am

[bump]
User avatar
Francesca
 
Posts: 3485
Joined: Thu Jun 22, 2006 5:26 pm

Post » Fri Feb 18, 2011 11:40 pm

What a fantastic thread. Thanks for the mini-tutorials.
User avatar
Andrew Tarango
 
Posts: 3454
Joined: Wed Oct 17, 2007 10:07 am

Post » Sat Feb 19, 2011 12:24 am

Bumping this out of oblivion! Thank god I've managed to find it!
User avatar
[ becca ]
 
Posts: 3514
Joined: Wed Jun 21, 2006 12:59 pm

Post » Sat Feb 19, 2011 9:10 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
Sian Ennis
 
Posts: 3362
Joined: Wed Nov 08, 2006 11:46 am

Post » Fri Feb 18, 2011 8:17 pm

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
Talitha Kukk
 
Posts: 3477
Joined: Sun Oct 08, 2006 1:14 am

Post » Sat Feb 19, 2011 7:05 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.



Well, write it! It should be a community project.
User avatar
Stat Wrecker
 
Posts: 3511
Joined: Mon Sep 24, 2007 6:14 am

Post » Sat Feb 19, 2011 11:51 am

You should add a summon creature script to the list.
User avatar
Dark Mogul
 
Posts: 3438
Joined: Tue Feb 20, 2007 11:51 am

PreviousNext

Return to IV - Oblivion