KoMik Posted March 19, 2005 Share Posted March 19, 2005 ----------Is there a way to do one very simple and humanly action?-----------If enemy unit is badly wounded he drop his weapon and retreat out of map... function Runaway() if UnitCanFight( unit ) and UnitVP( unit ) <= 40 then UnitDropWeapon( unit ) UnitSetWishPose( unit, POSE_RUN ) WaitForUnit( unit ) UnitSetRetreatLogic( unit, "waypoint" ) WaitForUnitWaypoint( unit, "waypoint" ) UnitRemove( unit ) endend What makes UnitVP-script functionable? Link to comment Share on other sites More sharing options...
damocles Posted March 19, 2005 Share Posted March 19, 2005 There are two main problems with your script... 1) There is no function that can return the health of a unit (unless I've missed it). 2) Retreat logic only retreats sometimes - more often the unit would rather stand and fight. If you want to force run them, then use unitsetscriptlogic and unitmovetowaypoint. The only solution I can think of for the VP problem would be to use the onUnitDamageUnit function. Then keep an array of units that have been damaged as well as a corresponding array with how many times each unit has been damaged. Then if they have been damaged 4 times and are still able to fight, make the run away. A bit of a complicated approach, but it should work okay. Link to comment Share on other sites More sharing options...
KoMik Posted March 19, 2005 Author Share Posted March 19, 2005 --thanks damocles I will try that way :wise: Ok...here is a one simple humanly logic-script which I like using/making (I have test it more than 10times and it should work pretty well... give me info if it need fixing) I have noted that in orginal S^games enemy units never surrender so I make those happen with Sentinels. I use here ready made scripts and functions by Nival crew (there is lots of useful ready functions just waiting to pick up). If you want to copy-paste this script you should fix it a bit in editor (check orginal scripts). So... let's expect there is 6-units enemy group called es = CreateGroup( "leader", "e1", "e2", "e3", "e4", "e5" ) Next functions wait until the groupleader and 4sodiers is unconscious, sets last soldier to neutral diplomancy, unit drop weapon and play a hands behind head animation. Your squadmembers get 50 XP-points(I don't know how to give medalpoints. In Sentinels player units gain experience per killed basic-enemy about 10 points on level 0 and over 50 on level 5). If you shoot 'your prisoner' he dies immediately. Diplomancy for this script is 1=enemy. ---------------------------------------------------------- ---------------------------------------------------------- DelayGameStartEx() function usrLastManStanding() local GS Sleep(5) while TRUE do usrRefreshGroup() GS = GroupGetSize( es ) if GS == 1 and not UnitCanFight( GetUnit( "leader" ) then StartThread( Surrender ) return end end end function usrRefreshGroup() local CurNum = GroupGetSize( es ) local i for i = 0, CurNum-1 do if not (GroupGetUnit( es, i )) == nil then if not (UnitCanFight( GroupGetUnit( es, i ))) then GroupDeleteUnit( es, GroupGetUnit( es, i ) ) return end end end end function Surrender() WaitForPassCalc() prisoner = GroupGetUnit( es, 0 ) BeginSequence() UnitAIMode( prisoner, false ) UnitCancelAction( prisoner ) WaitForUnit( prisoner ) UnitHealCriticals( prisoner, -1 ) UnitSetSkillMaxValue( prisoner, ST_VP, 10 ) UnitSetSkill( prisoner, ST_VP, 10 ) SetDiplomacy( 0, 1, DS_NEUTRAL ) SetDiplomacy( 1, 0, DS_NEUTRAL ) GroupGiveXP( party, 20 ) UnitThrowWeaponOut( prisoner ) Sleep(20) UnitPlayAnimation( prisoner, 5462, false ) Sleep(20) UnitPlayAnimation( prisoner, 5463, true, false ) EndSequence() end DividedDeploy() hero = GetHero() party = GetParty() es = CreateGroup( "leader", "e1", "e2", "e3", "e4", "e5" ) usrLastManStanding() ------------------------------------------------------------ ------------------------------------------------------------ -----------------mixedbyKoMik--------------------------- One known problem: In small and tight rooms unit may play animation inside objects or walls. I would like to cancel the last unit to civilian side so it affect to Scenario Zone table properties/ReparationForCivils mount (how much player have to cost money from killed civilian) but I don't know how to do it... Other way to do it is make trigger PlayerTakeMoney after UnitIsUnconscious( prisoner ). Using this script with scenariogoals, tasks, threads and triggers give it more meaning. Link to comment Share on other sites More sharing options...
vs322 Posted May 18, 2005 Share Posted May 18, 2005 Hey all- found a way to get the VP of a character; here is a little script that I'm sure will be helpful: local Lad=pollyTlocal pMaxVP=UnitGetSkillMaxValue( Lad, ST_VP)local pCurVP=UnitGetSkill( Lad, ST_VP )out(UnitGetName(Lad), ' VPs: ', pCurVP, ' out of ', pMaxVP) (pollyT is just some unit that the script already knows about)I've been using this for when a character is unconscious, but not dead -enjoy!-vs Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now