Sacrifice survival - solved

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
ChaosRider
Posts: 1168
Joined: April 15th, 2012, 1:15 pm

Sacrifice survival - solved

Post by ChaosRider »

I have a problem with this addon cause unstoring units on new x,y doesnt work and thats the question for all of you who read this topic why it doesnt work? Any ideas? It was working in Wesnoth version 1.10. On Wesnoth v1.18 there is no error info and its not working.
Unstore code part:
Spoiler:
Whole code:
Spoiler:
Last edited by ChaosRider on April 16th, 2025, 6:37 pm, edited 1 time in total.
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
ChaosRider
Posts: 1168
Joined: April 15th, 2012, 1:15 pm

Re: Sacrifice survival

Post by ChaosRider »

How to round a number to total value? Maybe thats a reason why unstore doesnt work?
test.png
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
ChaosRider
Posts: 1168
Joined: April 15th, 2012, 1:15 pm

Re: Sacrifice survival

Post by ChaosRider »

Yup, that was a reason why units werent spawned after unstoring them. Now it works.
Below working code:

Code: Select all

[spoiler]
#define SEND_SACRIFIED_UNIT X Y
{IF_VAR ai_target equals "Take that fort!" (
    [then]
    {VARIABLE sacrificed.goto_x {X}}
    {VARIABLE sacrificed.goto_y {Y}}
    [/then]
)}
{VARIABLE ox {X}}
{VARIABLE_OP ox add 29.5} # 14*2+3/2
{VARIABLE_OP ox divide 3}
{VARIABLE oy {Y}}
{VARIABLE_OP oy add 29.5} # 14*2+3/2
{VARIABLE_OP oy divide 3}


			{VARIABLE temp_find_variable_x 0}
			[while]
				[variable]
					name=temp_check_variable
					equals=$null
				[/variable]
				[do]
					[if]
						[variable]
							name=temp_find_variable_x
							less_than=$ox
						[/variable]
						[then]
							{VARIABLE_OP temp_find_variable_x add 1}
						[/then]
						[else]
							{VARIABLE_OP temp_check_variable add 1}
							{VARIABLE_OP temp_find_variable_x sub 1}
						[/else]
					[/if]
				[/do]
			[/while]
			{CLEAR_VARIABLE temp_check_variable}
			

			{VARIABLE temp_find_variable_y 0}
			[while]
				[variable]
					name=temp_check_variable
					equals=$null
				[/variable]
				[do]
					[if]
						[variable]
							name=temp_find_variable_y
							less_than=$oy
						[/variable]
						[then]
							{VARIABLE_OP temp_find_variable_y add 1}
						[/then]
						[else]
							{VARIABLE_OP temp_check_variable add 1}
							{VARIABLE_OP temp_find_variable_y sub 1}
						[/else]
					[/if]
				[/do]
			[/while]
			{CLEAR_VARIABLE temp_check_variable}			

    [message]
		message="Variable X: $ox
		Rounded variable X: $temp_find_variable_x
Variable Y: $oy
		Rounded variable Y: $temp_find_variable_y"
    [/message]
[unstore_unit]
    variable=sacrificed
    find_vacant=yes
#    x,y=$ox,$oy
    x,y=$temp_find_variable_x,$temp_find_variable_y
    {COLOR_HARM}
    text="Reborn!"
[/unstore_unit]
#enddef
[/spoiler]
Creator of WOTG (+5500 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
Post Reply