Has anyone made these yet? Want to release code as resource

Post » Thu May 03, 2012 4:18 pm

About two years ago, I coded ally/enemy detection based on some stuff. Including who the target is, their disposition towards player, who they are fighting against, and whether their enemy poses threat to the player or not. This allows - for example - a spell to hit only potential enemy, and not friendlies or vice versa

I also coded a basic... "framework"? To switch to a whole set of equipments, and still remember the last set of equipment before switching, allowing - for example - easier transition between adventuring and coming home. With just a few steps you can don your favorite armor, switch between sets of armors if need be, and with just a click you can remove all of 'em and go back to your clothing before switching

It's highly unlikely for me to go back to Oblivion and finish my work, so I'd like to share my 2 year old logic

Anyone here already made 'em? Or want to have 'em? Don't wanna go around claiming I made 'em and someone beat me to it.
User avatar
Charlotte Lloyd-Jones
 
Posts: 3345
Joined: Fri Jun 30, 2006 4:53 pm

Post » Fri May 04, 2012 12:47 am

There are a few mods that do the outfit switching, I use Enhanced Hotkeys, but I'd bet your implementation is different.

Not sure about the first one.
User avatar
Miranda Taylor
 
Posts: 3406
Joined: Sat Feb 24, 2007 3:39 pm

Post » Fri May 04, 2012 1:22 am

There are a few mods that do the outfit switching, I use Enhanced Hotkeys, but I'd bet your implementation is different.

Not sure about the first one.
Never heard about Enhanced Hotkeys. 9 hotkeys was quite enough for me. But I guess since this will be modder's resource, the whole point of "Who made it first" is pretty moot. So I'll just go ahead. I think I'll release these over at TES Nexus too

Note that these are best viewed in Notepad++ or TESCS Script Editor window. Primarily because I use apostrophe in the documentation for proper English, but the forum regards it as a starting point for a String

These codes requires OBSE 0017 or greater (perhaps 0018 or greater, I forgot)
You may have to study these codes a bit, but they are well documented


Ally/Enemy Detection

This is my take on detecting allies and enemies. This logic implements the "The enemy of my enemy is my friend" system, and additionally detects whether an actor is potential threat or not. So "The enemy of my enemy is my friend so long as he won't backstab me after this"

This particular piece of code is an example where I heal only potential allies and deal damage only to potential enemies, allowing players to cast spells without worry of friendly fire. This code can be executed both in and outside of combat to provide benefits, and this code has to target an actor

scriptname RaestlozSunburnSpellScriptref me	;holds a reference to the actor who are affected by this spellref source   ;holds a reference to the activatorshort aggro   ;holds actor's aggresivenessshort aggro2  ;holds actor's enemy's aggressivenessref combattarget ;reference to actor's enemyref combattarget2 ;reference to actor's enemy's enemyshort health   ;holds actor's max healthshort health2  ;holds actor's current healthBegin ScriptEffectStart;get a reference to this actorset me to GetSelfif me == playerreturnendifset aggro to GetShouldAttack player   ;determines if target is harmful or notIf IsInCombat == 1		 ;only works in combatIf GetCombatTarget != player	   ;code for those not fighting player   set combattarget to GetCombatTarget		;determines the actor's enemy   set combattarget2 to combattarget.getCombatTarget  ;determines the actor's enemy's enemy   set aggro to GetShouldAttack player   ;determines if target is harmful or not   set aggro2 to combattarget.getShouldAttack player  ;determines if actor's enemy is harmful or not   if combattarget2 == player	;heals those fighting player's current enemy	set source to Source	source.MoveTo me 0, 0, 15	source.cast StandardRestoreHealthTarget4Expert me	return   elseif aggro2 > 0	 ;if actor's enemy is harmful	if aggro > 0	;does nothing if actor is also harmful	 return	else	 set source to Source   ;heals unharmful unit that is fighting harmful unit	 source.MoveTo me 0, 0, 15				 source.cast StandardRestoreHealthTarget4Expert me  	 return	endif   elseif aggro > 0	set source to Source	;damages those harmful against player	source.MoveTo me 0, 0, 15				source.cast RaestlozSunburnSpell me  	return   elseif aggro < 0	set source to Source	;heals allies  	source.MoveTo me 0, 0, 15				source.cast StandardRestoreHealthTarget4Expert me  	return   endif  else   set source to Source	 ;damages those fighting the player   source.MoveTo me 0, 0, 15			   source.cast RaestlozSunburnSpell me     returnendifelse		 ;If not in combatset health to GetBaseActorValue healthset health2 to GetActorValue Healthif health - health2 >= 0  returnelseif aggro < 0  set source to Source	;heals only unharmful unit    source.MoveTo me 0, 0, 15			  source.cast StandardRestoreHealthTarget4Expert me    returnendifendifEnd


Armor Set Switching

This is my take in switching sets of armor. The code remembers the last "normal" set of outfits that you wear, and allows you to switch to a full set of armor in one go, even allowing you to switch between sets of armor and you'll still be able to revert to your "normal" outfit. The armor set that you switch into cannot be unequipped. You have to revert back before unequipping anything

Note that "normal" here means "pieces of armor that you wear before switching to any armor set defined by the code.


This is the part that defines the "armor set". In this case, I have a set of armor I nicknamed "Dendrobium", which consists of 8 pieces of equipments


scn RaestlozDendrobiumModeScript;normal equipmentsref swordref headref hairref chestref legsref footref glovesref tailref amuletref arrowsref shield;transforming equipmentsref sword1ref head1ref hair1ref chest1ref legs1ref foot1ref gloves1ref tail1ref amulet1ref arrows1ref shield1short transformingshort modenumberbegin scripteffectstartset transforming to VariableContainer.transformingset modenumber to VariableContainer.modenumberif modenumber == 2; does nothing if currently in Dendrobium Modereturnelseif transforming == 0 ; makes sure transformation from other mode doesn't interfere with detransformation mode; check player equipmentsset chest to player.getequipmentslotmask 4 ; upper bodyset foot to player.getequipmentslotmask 32 ; footset sword to player.getequipmentslotmask 65536 ; weaponif sword == 0  set sword to player.getequipmentslotmask 262144 ; in case of using bowendifset arrows to player.getequipmentslotmask 131072 ; arrowsset head to player.getequipmentslotmask 1; headset hair to player.getequipmentslotmask 2 ;hairset legs to player.getequipmentslotmask 8 ; lower bodyset amulet to player.getequipmentslotmask 256 ;necklaceset tail to player.getequipmentslotmask 32768 ; in case of tail-slot accessoriesset gloves to player.getequipmentslotmask 16 ;gauntlets and glovesset shield to player.getequipmentslotmask 8192 ; shield; store reference to these itemsset VariableContainer.sword to swordset VariableContainer.head to headset VariableContainer.hair to hairset VariableContainer.chest to chestset VariableContainer.legs to legsset VariableContainer.foot to footset VariableContainer.gloves to glovesset VariableContainer.tail to tailset VariableContainer.amulet to amuletset VariableContainer.arrows to arrowsset VariableContainer.shield to shield;set tranformation informationset VariableContainer.transforming to 1elseif transforming == 1; check player equipmentsset chest1 to player.getequipmentslotmask 4 ; upper bodyset foot1 to player.getequipmentslotmask 32 ; footset sword1 to player.getequipmentslotmask 65536 ; weaponif sword1 == 0  set sword1 to player.getequipmentslotmask 262144 ; in case of using bowendifset arrows1 to player.getequipmentslotmask 131072 ; arrowsset head1 to player.getequipmentslotmask 1; headset hair1 to player.getequipmentslotmask 2 ;hairset legs1 to player.getequipmentslotmask 8 ; lower bodyset amulet1 to player.getequipmentslotmask 256 ;necklaceset tail1 to player.getequipmentslotmask 32768 ; in case of tail-slot accessoriesset gloves1 to player.getequipmentslotmask 16 ;gauntlets and glovesset shield1 to player.getequipmentslotmask 8192 ; shieldendif;removing clothings for transformationif transforming == 0player.unequipitemns swordplayer.unequipitemns headplayer.unequipitemns hairplayer.unequipitemns chestplayer.unequipitemns legsplayer.unequipitemns footplayer.unequipitemns glovesplayer.unequipitemns tailplayer.unequipitemns amuletplayer.unequipitemns arrowsplayer.unequipitemns shieldelseif transforming == 1player.unequipitemns sword1player.unequipitemns head1player.unequipitemns hair1player.unequipitemns chest1player.unequipitemns legs1player.unequipitemns foot1player.unequipitemns gloves1player.unequipitemns tail1player.unequipitemns amulet1player.unequipitemns arrows1player.unequipitemns shield1endif;equipping transformation setplayer.equipitemNS RaestlozDendrobiumArmor 1player.equipitemNS RaestlozDendrobiumBoots 1player.equipitemNS RaestlozDendrobiumGauntlets 1player.equipitemNS RaestlozDendrobiumGreaves 1player.equipitemNS RaestlozDendrobiumHelmet 1player.equipitemNS RaestlozInvisibleShield 1player.equipitemns RaestlozFrostmourne 1set VariableContainer.modenumber to 2endifend


And this is the part where you revert back to normal
scn RaestlozTransformDispelScriptref swordref headref hairref chestref legsref footref glovesref tailref amuletref arrowsref shieldref sword1ref head1ref hair1ref chest1ref legs1ref foot1ref gloves1ref tail1ref amulet1ref arrows1ref shield1short arrowcountshort transformingbegin scripteffectstart;initializationset transforming to VariableContainer.transformingif transforming == 0 ;does nothing if currently in normal modereturnelseset VariableContainer.transforming to 0;check current mode's equipmentset chest1 to player.getequipmentslotmask 4 ; upper bodyset foot1 to player.getequipmentslotmask 32 ; footset sword1 to player.getequipmentslotmask 65536 ; weaponif sword1 == 0set sword1 to player.getequipmentslotmask 262144 ; in case of using bowendifset arrows1 to player.getequipmentslotmask 131072 ; arrowsset head1 to player.getequipmentslotmask 1; headset hair1 to player.getequipmentslotmask 2 ;hairset legs1 to player.getequipmentslotmask 8 ; lower bodyset amulet1 to player.getequipmentslotmask 256 ;necklaceset tail1 to player.getequipmentslotmask 32768 ; in case of tail-slot accessoriesset gloves1 to player.getequipmentslotmask 16 ;gauntlets and glovesset shield1 to player.getequipmentslotmask 8192 ; shield;initialize last equipmentset sword to VariableContainer.swordset head to VariableContainer.headset hair to VariableContainer.hairset chest to VariableContainer.chestset legs to VariableContainer.legsset foot to VariableContainer.footset gloves to VariableContainer.glovesset tail to VariableContainer.tailset amulet to VariableContainer.amuletset arrows to VariableContainer.arrowsset shield to VariableContainer.shieldendif;detransformationplayer.unequipitemns sword1player.unequipitemns head1player.unequipitemns hair1player.unequipitemns chest1player.unequipitemns legs1player.unequipitemns foot1player.unequipitemns gloves1player.unequipitemns tail1player.unequipitemns amulet1player.unequipitemns arrows1player.unequipitemns shield1;equip last equipments backif sword != 0player.equipitemns swordendifif head != 0player.equipitemns headendifif hair !=0player.equipitemns hairendifif chest != 0player.equipitemns chestendifif legs != 0player.equipitemns legsendifif foot !=0player.equipitemns footendifif gloves !=0player.equipitemns glovesendifif tail != 0player.equipitemns tailendifif amulet !=0player.equipitemns amuletendifif arrows!=0set arrowcount to (GetItemCount arrows) -1player.removeitemns arrows arrowcountplayer.equipitemns arrowsendifif shield!=0player.equipitemns shieldendifendbegin scripteffectfinishplayer.additemns arrows arrowcountset VariableContainer.modenumber to 0 ;neutralize mode numberend

Lastly, you'll need to define an empty Script which serves as an independent container:
scn RaestlozVariableContainerScriptref swordref headref hairref chestref legsref footref glovesref tailref amuletref arrowsref shieldshort transformingshort modenumber
User avatar
Jah Allen
 
Posts: 3444
Joined: Wed Jan 24, 2007 2:09 am


Return to IV - Oblivion