Jump to content


Photo

AI heroes retreating back to fortress


  • Please log in to reply
6 replies to this topic

#1 oblivionator

oblivionator
  • Members
  • 73 posts

Posted 29 November 2009 - 06:10 AM

Hello, I'm back with a new, personal modding question. :p For a while now, I've been trying to make the heroes controlled by the AI to retreat back to their fortress when damaged, very much in a similar manner to the SEE mod. When a hero is badly damaged, an invisible One-Ring-like object is spawned over them, causing them to go and give this object to the fortress. This is really to buy the hero some time to heal. A neat way to use (or misuse...hehe) codes. :p So I've been closely following SEE's codes to see how they did it, and so far I've gotten a hero to retreat back to the fortress and deliver the invisible object, but when they do, it's like they get the One Ring upgrade and have that halo of words above their fortress. :) What I'm trying to do now is make the fortress not receive the One Ring upgrade when the AI-controlled hero delivers the object, but don't have a clue how to do it. What would need to be done? Thank you in advance for any of your help.

Edit: Yes. I managed to figure it out in 17 steps.

Edited by oblivionator, 02 December 2009 - 02:02 AM.

Posted Image

#2 Guest_Guest_Vermilion_*_*

Guest_Guest_Vermilion_*_*
  • Guests

Posted 10 February 2010 - 12:27 PM

Hello, I'm back with a new, personal modding question. :rolleyes: For a while now, I've been trying to make the heroes controlled by the AI to retreat back to their fortress when damaged, very much in a similar manner to the SEE mod. When a hero is badly damaged, an invisible One-Ring-like object is spawned over them, causing them to go and give this object to the fortress. This is really to buy the hero some time to heal. A neat way to use (or misuse...hehe) codes. :good: So I've been closely following SEE's codes to see how they did it, and so far I've gotten a hero to retreat back to the fortress and deliver the invisible object, but when they do, it's like they get the One Ring upgrade and have that halo of words above their fortress. :) What I'm trying to do now is make the fortress not receive the One Ring upgrade when the AI-controlled hero delivers the object, but don't have a clue how to do it. What would need to be done? Thank you in advance for any of your help.

Edit: Yes. I managed to figure it out in 17 steps.



Would be very interested in how you did it (please all your codes) because I made a mod where all heroes are not resurectable, so I wanted them to also to heal if badly damaged.

#3 Prolong

Prolong
  • Members
  • 133 posts

Posted 13 February 2010 - 05:01 PM

Woah that is a really smart idea to improve the AI, does SEE allow us to use its code? Gonna try that :p

#4 Sûlherokhh

Sûlherokhh

    Sagacious Engineer

  • Project Team
  • 3,754 posts
  • Location:Central Germany
  • Projects:S.E.E., Sage A.I., Code Advisor
  •  'Axe'er of the Gordic Knot

Posted 14 February 2010 - 01:51 PM

Check it out and post what you find. I am eager to see if you can figure out what i did to the codes.

Some advice:
1. Lua provides the upgrade which (along with the AI-upgrade i introduced) adds a ONE_RING variation.
2. Lua will remove the upgrade when the Hero is no longer BADLYDAMAGED.
3. The new status adds an Aura that provides any Fortress closeby a ModelCondition that ...
4. ... triggers the fortresses own Aura which forcebly removes the ONE_RING variation.
4a. --> The fortress won't get the RING.
4b. --> The hero will follow the AI command of entering the fortress no matter if the status has already been changed, but once coming out is again ready to receive AI orders.

5. A damaged AI hero is no longer able to carry/pick up the ring (it already has one) until entering and exiting a fortress.

Looks complicated, eh?
That's why i liked BfMe1's AI much better.

bannerreal01mittelit3.jpg
Axed Head and A.I. Coder for S.E.E. and ... stuff

".. coding is basically boring. What's fun is finding out how things work, take them apart and then put them together in ways that were not intended nor even conceived."


#5 Guest_Guest_Vermilion_*_*

Guest_Guest_Vermilion_*_*
  • Guests

Posted 14 February 2010 - 02:09 PM

Check it out and post what you find. I am eager to see if you can figure out what i did to the codes.

Some advice:
1. Lua provides the upgrade which (along with the AI-upgrade i introduced) adds a ONE_RING variation.
2. Lua will remove the upgrade when the Hero is no longer BADLYDAMAGED.
3. The new status adds an Aura that provides any Fortress closeby a ModelCondition that ...
4. ... triggers the fortresses own Aura which forcebly removes the ONE_RING variation.
4a. --> The fortress won't get the RING.
4b. --> The hero will follow the AI command of entering the fortress no matter if the status has already been changed, but once coming out is again ready to receive AI orders.

5. A damaged AI hero is no longer able to carry/pick up the ring (it already has one) until entering and exiting a fortress.

Looks complicated, eh?
That's why i liked BfMe1's AI much better.



I tried to take the codes from SEE Mod but did not find the definition of "badlydamaged_see" or "badlydamaged" so the AI doesnt know what this upgrade is. I dont know in which ini its defined what the upgrade exactly does, so it did not work for me as I had to say I am no good modder. I will try if I have enough time but of course if someone here knows what to do please insert codes here. Sorry for my bad english.

#6 oblivionator

oblivionator
  • Members
  • 73 posts

Posted 16 February 2010 - 07:56 PM

Ah yeah, I guess I should have at least posted how I did it, in case others might wonder how to do it. ^_^
I think I did it a little different than how SEE did it and don't fully understand all the codes, but it works for me. I might be bad at explaining things, but here is what I did, it's a little lengthy (ROTWK):

I added this code into a new INC file that went into the "includes" folder, so it could be added into all the hero's INI files easily.
HeroAIInjuredBehavior.inc
; #include "..\..\..\..\includes\HeroAIInjuredBehavior.inc"

;--------------------------------------------------------------------------
;;; Return Home Behavior
;--------------------------------------------------------------------------

	Behavior = OCLSpecialPower ModuleTag_MaketheHomingCall
		StartsPaused				= No
		SpecialPowerTemplate		= SpecialAbilityAIMaketheHomingCall
		OCL							= OCL_AIMaketheHomingCall
		CreateLocation				= CREATE_AT_LOCATION
	End

	Behavior = AISpecialPowerUpdate MaketheHomingCallAI
		CommandButtonName = Command_MaketheHomingCall_AI
		SpecialPowerAIType = AI_SPECIAL_POWER_STANCEBATTLE	   ;This seems to be used when the AI-controlled hero has around 1/4 health left.
	End
Added new special power code for the "HeroAIInjuredBehavior.inc" file above.
specialpower.ini
SpecialPower SpecialAbilityAIMaketheHomingCall
	Enum						= SPECIAL_GENERAL_TARGETLESS_THREE
	ReloadTime					= 60000
End
Added new OCL code for the "HeroAIInjuredBehavior.inc" file above.
objectcreationlist.ini
ObjectCreationList OCL_AIMaketheHomingCall
	CreateObject
		ObjectNames = HeroHomingBeacon
		Count = 1
		FadeIn					= Yes
		FadeTime				= 20
		Offset					= X:0 Y:0 Z:15
	End
End
Added new object "HeroHomingBeacon". This will spawn over the hero. The AI will make the hero give this object to the fortress, much like the One Ring. It is invisible.
system.ini
; 'Ping' for HeroHomingBeacon. Acts like an ring carrier until just before 
; the fortress walls
Object HeroHomingBeacon

  EvaEnemyObjectSightedEvent = None ; Not a real unit
  
; Draw = W3DScriptedModelDraw SpecialAnimStateFX
; DefaultModelConditionState
; Model = Icon
; End
; End

	ArmorSet
		Conditions	  = None
		Armor		   = PingArmor
		DamageFX		= NormalDamageFX
	End

 ; ***DESIGN parameters ***

  EditorSorting   = SYSTEM
  KindOf = NO_COLLIDE CREEP IGNORE_FOR_VICTORY IGNORE_FOR_EVA_SPEECH_POSITION;INERT

	ThreatLevel			= 0.0
	VisionRange		= 0
	ShroudClearingRange	= 0

 ; *** ENGINEERING Parameters ***

	Body = ActiveBody ModuleTag_Body;Can take damage, but won't die.  Can only die from ::kill() or other unresistable damage
		MaxHealth	  = 1.0
	End

	Behavior = DestroyDie ModuleTag_Die
	End

	Behavior = LifetimeUpdate ModuleTag_HatchTrigger
		MinLifetime = 60000.0
		MaxLifetime = 60000.0
	End
  
	Behavior = AttachUpdate ModuleTag_Attach
		ObjectFilter = ANY +HERO
		ScanRange = 20
		ParentStatus = HOLDING_THE_RING
		AlwaysTeleport = No
		AnchorToTopOfGeometry = Yes
	End
  
	Behavior = AIUpdateInterface	ModuleTag_AIUpdateInterface
		AutoAcquireEnemiesWhenIdle = No
		// MoodAttackCheckRate		= 500
	End
  
	LocomotorSet
		Locomotor = InvisiblePingLocomotor
		Condition = SET_NORMAL 
		Speed	 = 1000
	End
	Behavior = SlavedUpdate ModuleTag_Slave
		UseSlaverAsControlForEvaObjectSightedEvents = Yes
		DieOnMastersDeath	= Yes	//Die when my master dies!

	; GuardPositionOffset	= X:0 Y:0 Z:5
   ; GuardMaxRange = 10	 ;How far away from master I'm allowed when master is idle (doesn't wander)
   ; GuardWanderRange = 10  ;How far away I'm allowed to wander from master while guarding.
   ; ScoutRange = 10		;How far away from master I'm allowed when master is moving.
   ; ScoutWanderRange = 0  ;How far I'm allowed to wander from scout point.
	End
  
End
Added new armor code for the "HeroHomingBeacon" object above.
armor.ini
Armor PingArmor
  Armor = DEFAULT		   0%
  Armor = REFLECTED	   100%
End
Added new locomotor code for the "HeroHomingBeacon" object above.
locomotor.ini
Locomotor InvisiblePingLocomotor
	Surfaces			= AIR
	TurnTime			= 0
	TurnTimeDamaged	 = 0
	TurnThreshold	   = 5
	TurnThresholdHS	 = 30
	SlowTurnRadius		= 0.0;  From a standing starts, 30 foot radius.
	FastTurnRadius		= 0.0; Once the catapult gets moving, still uses a 30 foot radius to turn.	
	Acceleration		= 2000 ; Instant accelerate to full speed.
	Braking				= 2000 ; Instant brake from full speed.
	MinTurnSpeed		= 0%
	ZAxisBehavior	   = NO_Z_MOTIVE_FORCE
	Appearance		  = HOVER
	StickToGround	   = Yes
End
Added new command button code. This command button was made only for the AI to use.
commandbutton.ini
CommandButton Command_MaketheHomingCall_AI
	Command				= SPECIAL_POWER
	SpecialPower			= SpecialAbilityAIMaketheHomingCall
	TextLabel			= CONTROLBAR:WoundingArrow
	DescriptLabel			= CONTROLBAR:ToolTipWoundingArrow
	ButtonImage			= HSFaramirWoundingArrow
	ButtonBorderType		= ACTION
	InPalantir			= Yes
	AutoAbility			= Yes
End
Added the new command button above to every hero's command set, usually in a hidden slot, so that only the AI can use it. I'll use Faramir as an example.
commandset.ini
CommandSet GondorFaramirCommandSet
	1	= Command_ToggleStance
	2	= Command_ToggleFaramirWeapon
	3	= Command_SpecialAbilityWoundArrow
	4	= Command_FaramirFakeLeadershipButton
	5	= Command_SpecialAbilityCaptainOfGondor
	6	= Command_ToggleFaramirMounted 
	7	= Command_MaketheHomingCall_AI				  ;added!
	11	= Command_TransportEvacuateTheoden 
	12	= Command_CaptureBuilding
	13	= Command_AttackMove
	14	= Command_Stop
	16	= Command_SetStanceBattle
	17	= Command_SetStanceAggressive
	18	= Command_SetStanceHoldGround
End
Added to every hero's INI file. I'll use Faramir as an example.
faramir.ini
#include "..\..\..\..\includes\HeroAIInjuredBehavior.inc"
Added new upgrade.
upgrade.ini
Upgrade Upgrade_FortressHasBeenEntered
  Type			   = OBJECT
  BuildTime		= 0.0
  BuildCost		= 0
End
Ermm... This piece of code is already present. "HeroHomingBeacon" has been added to the "ObjectToDestroyForRingEntry" line. "Upgrade_FortressHasBeenEntered" has been added to the "UpgradeForRingEntry" line and "Upgrade_FortressRingHero" has been removed.
fortress.ini
Behavior = CitadelSlaughterHordeContain ModuleTag_SlaughterMe
		PassengerFilter					= RJ_GENERIC_FACTION_SLAUGHTERABLE
		ObjectStatusOfContained				= UNSELECTABLE ENCLOSED
		CashBackPercent					= 200
		ContainMax						  = 99; give it a huge capacity, just in case player sends his whole army in at once
		AllowEnemiesInside				= No
		AllowAlliesInside				= No
 		AllowNeutralInside				= No
 		AllowOwnPlayerInsideOverride			= Yes
		EnterSound					= MordorSlaughterhouseEnterSound
		EntryOffset					= X:125.0 Y:0.0 Z:0.0
		EntryPosition					= X:30.0 Y:0.0 Z:0.0		// entry position needs to be offset from the root transform, otherwise fortress obscures point.

		ExitOffset					= X:125.0 Y:0.0 Z:0.0
		StatusForRingEntry				= HOLDING_THE_RING
		UpgradeForRingEntry				= Upgrade_FortressHasBeenEntered Upgrade_RingHero;Upgrade_FortressRingHero;removed
		ObjectToDestroyForRingEntry			= NONE +TheDroppedRing +HeroHomingBeacon	 ;added!
		FXForRingEntry					= FX_OneRingFlare
	End
Added this piece of code.
fortressringfunc.inc
Behavior = ObjectCreationUpgrade RemoveEnteredStatus
		TriggeredBy	= Upgrade_FortressHasBeenEntered
		ConflictsWith	= Upgrade_FortressRingHero
		Delay		= 50.0
		ThingToSpawn	= FortressEntryConditionTimer
		FadeInTime	= 100
	End
Added new object "FortressEntryConditionTimer" below the "HeroHomingBeacon" object.
system.ini (again)
Object FortressEntryConditionTimer

  EvaEnemyObjectSightedEvent = None ; Not a real unit

; Draw = W3DScriptedModelDraw SpecialAnimStateFX
; DefaultModelConditionState
; Model = Icon
; End
; End

 ; ***DESIGN parameters ***

  EditorSorting   = SYSTEM

  KindOf = NO_COLLIDE CREEP IGNORE_FOR_VICTORY IGNORE_FOR_EVA_SPEECH_POSITION;INERT
	ThreatLevel			= 0.0
	VisionRange		= 0
	ShroudClearingRange	= 0

 ; *** ENGINEERING Parameters ***

	Body = HighlanderBody ModuleTag_Body;Can take damage, but won't die.  Can only die from ::kill() or other unresistable damage
		MaxHealth	  = 1.0
	End

	Behavior = DestroyDie ModuleTag_Die
	End

	Behavior = LifetimeUpdate ModuleTag_HatchTrigger
		MinLifetime = 1000.0
		MaxLifetime = 1000.0
	End
	
	// Fortress no longer has the 'has been entered' Flag.
	Behavior = RemoveUpgradeUpgrade ModuleTag_RemoveEnteredStatus
		TriggeredBy			= Upgrade_AllFactionUpgrade
		UpgradeToRemove			= Upgrade_RingHero Upgrade_FortressHasBeenEntered
		RemoveFromAllPlayerObjects	= Yes
		SuppressEvaEventForRemoval	= Yes; Hack -- this is to avoid the Eva event about 'Gollum stole our ring'
										 //when we are actually losing the upgrade because we built the ring hero
	End

	Behavior = AIUpdateInterface	ModuleTag_AIUpdateInterface
		AutoAcquireEnemiesWhenIdle = No
		// MoodAttackCheckRate		= 500
	End

	LocomotorSet
		Locomotor = InvisiblePingLocomotor
		Condition = SET_NORMAL 
		Speed	 = 1000
	End
	Behavior = SlavedUpdate ModuleTag_Slave
		UseSlaverAsControlForEvaObjectSightedEvents = Yes
		DieOnMastersDeath	= Yes	//Die when my master dies!
	End

End
Added these codes to the "TheDroppedRing" object.
crate.ini
Behavior = AttributeModifierAuraUpdate ModuleTag_RegisteratFortress1
		StartsActive			= Yes
		BonusName			= PrepareFortressForRing
		RefreshDelay			= 500
		Range				= 100
		TargetEnemy			= Yes
		ObjectFilter			= ANY +COMMANDCENTER
	End

	Behavior = AttributeModifierAuraUpdate ModuleTag_RegisteratFortress2
		StartsActive			= Yes
		BonusName			= PrepareFortressForRing
		RefreshDelay			= 500
		Range				= 100
;		TargetEnemy			= Yes
		ObjectFilter			= ANY +COMMANDCENTER
	End
Added new attribute modifier code for the codes above.
attributemodifier.ini
ModifierList PrepareFortressForRing
	Category = WEAPON
	Duration = 3000
	Upgrade  = Upgrade_FortressRingHero  Delay:1
End
This upgrade code is already present. 3 EvaEvent things below have been removed from the Upgrade_RingHero upgrade.
upgrade.ini
Upgrade Upgrade_RingHero
	DisplayName				= CONTROLBAR:RingHero
	Type					= PLAYER

; Announce it when people get the ring, and when they lose it...
;LocalPlayerGainsUpgradeEvaEvent		= LocalPlayerGainsRing	   ;removed
;AlliedPlayerGainsUpgradeEvaEvent	= AlliedPlayerGainsRing			  ;removed
;EnemyPlayerGainsUpgradeEvaEvent		= EnemyPlayerGainsRing	;removed

; LocalPlayerLosesUpgradeEvaEvent	= LocalPlayerLosesRing		; Ring mechanics have changed and this no longer makes sense - iby
	AlliedPlayerLosesUpgradeEvaEvent	= None				; For now
	EnemyPlayerLosesUpgradeEvaEvent		= None				; For now
End
Added new FX for when the "TheDroppedRing" is held and not a "HeroHomingBeacon." There would be an announcement everytime the AI made a hero retreat back to the fortress.
fxlist.ini
FXList FX_AnnounceFortressAcquiredRing
	EvaEvent
		 EvaEventOwner = LocalPlayerGainsRing
		 EvaEventAlly = AlliedPlayerGainsRing
		 EvaEventEnemy = EnemyPlayerGainsRing
	 RequiredSourceModelConditions = ONE_RING
	End
End
I relied on SEE's codes heavily for this, with a few changes here and there, and it seems to work just fine. When an AI-controlled hero's health is low, they will activate the hidden command button. An invisible object will then spawn over them and they will grab and take it back to the fortress, like the One Ring. Except they don't get the One Ring. This is really meant to make the AI-controlled hero retreat from battle and have some time to heal. Makes them seem a little smarter. :p
Posted Image

#7 Verm

Verm
  • Members
  • 11 posts

Posted 17 February 2010 - 07:27 AM

@oblivionator: Very big thanks to these codes, they will strongly increase my HeroMod I have to work until half past four but I cant wait at all to try these codes ^_^ :p




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users